Commit 5bd0877d authored by Patrick Noland's avatar Patrick Noland Committed by Commit Bot

[EoC] Drop events with an invalid source id

There are scenarios where we fail to bootstrap the source id from Java.
This also means that we fail to setup the page for metrics reporting.
If the page is not set up, calls to RecordEventMetrics will crash.
Until we understand why the bootstrapping can fail and fix that, this
CL will cause us to drop events without a valid source id so that we
don't crash.

Bug: 832712
Change-Id: I4a01c8cf7a9eaae645960dc17dada8a4b5cdd3fa
Reviewed-on: https://chromium-review.googlesource.com/1033959
Commit-Queue: Filip Gorski <fgorski@chromium.org>
Reviewed-by: default avatarDonn Denman <donnd@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554767}
parent 057b1daf
...@@ -141,15 +141,6 @@ void ContextualSuggestionsBridge::ReportEvent( ...@@ -141,15 +141,6 @@ void ContextualSuggestionsBridge::ReportEvent(
ukm::SourceId ukm_source_id = ukm::SourceId ukm_source_id =
ukm::GetSourceIdForWebContentsDocument(web_contents); ukm::GetSourceIdForWebContentsDocument(web_contents);
// It's possible but unlikely to be in this state; it can happen if we are
// triggering a fetch for a WebContents that does not have a committed
// navigation. This can happen, e.g., if we switched tabs and a navigation
// took a very long time to commit. TODO(pnoland): Check against this
// possiblity by deferring event reporting and fetching until we observe a
// commit.
if (ukm_source_id == ukm::kInvalidSourceId)
return;
contextual_suggestions::ContextualSuggestionsEvent event = contextual_suggestions::ContextualSuggestionsEvent event =
static_cast<contextual_suggestions::ContextualSuggestionsEvent>( static_cast<contextual_suggestions::ContextualSuggestionsEvent>(
j_event_id); j_event_id);
......
...@@ -85,7 +85,13 @@ void ContextualContentSuggestionsServiceProxy::ClearState() { ...@@ -85,7 +85,13 @@ void ContextualContentSuggestionsServiceProxy::ClearState() {
void ContextualContentSuggestionsServiceProxy::ReportEvent( void ContextualContentSuggestionsServiceProxy::ReportEvent(
ukm::SourceId ukm_source_id, ukm::SourceId ukm_source_id,
ContextualSuggestionsEvent event) { ContextualSuggestionsEvent event) {
DCHECK(ukm_source_id != ukm::kInvalidSourceId); // TODO(pnoland): investigate how we can get into this state(one known
// example is if we switch tabs and there's no committed navigation in the new
// tab) and prevent it from happening. Replace the early return with a DCHECK
// once this is done.
if (ukm_source_id == ukm::kInvalidSourceId) {
return;
}
// Flush the previous page (if any) and setup the new page. // Flush the previous page (if any) and setup the new page.
if (ukm_source_id != last_ukm_source_id_) { if (ukm_source_id != last_ukm_source_id_) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment