Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

Issue 2331053003: Add common page filtering logic for page load metrics. (Closed)
Patch Set: fixup Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
diff --git a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
index 86a76e25c8ed3f35079a4c580c73489dbca8cff0..cd71a94875b29899f47dfe4112b9330b0fabdfa9 100644
--- a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
+++ b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
@@ -14,6 +14,7 @@
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
+#include "chrome/browser/page_load_metrics/browser_page_track_decider.h"
#include "chrome/browser/page_load_metrics/page_load_metrics_util.h"
#include "chrome/common/page_load_metrics/page_load_metrics_messages.h"
#include "chrome/common/page_load_metrics/page_load_timing.h"
@@ -27,6 +28,7 @@
#include "content/public/browser/web_contents_user_data.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h"
+#include "net/http/http_response_headers.h"
#include "ui/base/page_transition_types.h"
DEFINE_WEB_CONTENTS_USER_DATA_KEY(
@@ -1061,18 +1063,13 @@ void MetricsWebContentsObserver::OnTimingUpdated(
bool MetricsWebContentsObserver::ShouldTrackNavigation(
content::NavigationHandle* navigation_handle) const {
DCHECK(navigation_handle->IsInMainFrame());
- if (!navigation_handle->GetURL().SchemeIsHTTPOrHTTPS())
- return false;
- if (embedder_interface_->IsNewTabPageUrl(navigation_handle->GetURL()))
+
+ // Ignore same-page navigations.
+ if (navigation_handle->HasCommitted() && navigation_handle->IsSamePage())
Charlie Harrison 2016/09/14 13:20:05 Why can't this go into the tracker?
Bryan McQuade 2016/09/14 15:10:58 Good question. I decided that the concept of a sam
Charlie Harrison 2016/09/14 16:27:32 Great explanation, I just wonder if we want to be
Bryan McQuade 2016/09/15 22:28:10 Sure, we have code in place in the renderer to blo
return false;
- if (navigation_handle->HasCommitted()) {
- if (navigation_handle->IsSamePage() || navigation_handle->IsErrorPage())
- return false;
- const std::string& mime_type = web_contents()->GetContentsMimeType();
- if (mime_type != "text/html" && mime_type != "application/xhtml+xml")
- return false;
- }
- return true;
+
+ return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(),
+ navigation_handle).ShouldTrack();
}
} // namespace page_load_metrics

Powered by Google App Engine
This is Rietveld 408576698