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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" 5 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/metrics/user_metrics.h" 16 #include "base/metrics/user_metrics.h"
17 #include "chrome/browser/page_load_metrics/browser_page_track_decider.h"
17 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" 18 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h"
18 #include "chrome/common/page_load_metrics/page_load_metrics_messages.h" 19 #include "chrome/common/page_load_metrics/page_load_metrics_messages.h"
19 #include "chrome/common/page_load_metrics/page_load_timing.h" 20 #include "chrome/common/page_load_metrics/page_load_timing.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/navigation_details.h" 22 #include "content/public/browser/navigation_details.h"
22 #include "content/public/browser/navigation_handle.h" 23 #include "content/public/browser/navigation_handle.h"
23 #include "content/public/browser/render_frame_host.h" 24 #include "content/public/browser/render_frame_host.h"
24 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
26 #include "content/public/browser/web_contents_observer.h" 27 #include "content/public/browser/web_contents_observer.h"
27 #include "content/public/browser/web_contents_user_data.h" 28 #include "content/public/browser/web_contents_user_data.h"
28 #include "ipc/ipc_message.h" 29 #include "ipc/ipc_message.h"
29 #include "ipc/ipc_message_macros.h" 30 #include "ipc/ipc_message_macros.h"
31 #include "net/http/http_response_headers.h"
30 #include "ui/base/page_transition_types.h" 32 #include "ui/base/page_transition_types.h"
31 33
32 DEFINE_WEB_CONTENTS_USER_DATA_KEY( 34 DEFINE_WEB_CONTENTS_USER_DATA_KEY(
33 page_load_metrics::MetricsWebContentsObserver); 35 page_load_metrics::MetricsWebContentsObserver);
34 36
35 namespace page_load_metrics { 37 namespace page_load_metrics {
36 38
37 namespace internal { 39 namespace internal {
38 40
39 const char kErrorEvents[] = "PageLoad.Internal.ErrorCode"; 41 const char kErrorEvents[] = "PageLoad.Internal.ErrorCode";
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 // If the page load tracker cannot update its timing, something is wrong 1056 // If the page load tracker cannot update its timing, something is wrong
1055 // with the IPC (it's from another load, or it's invalid in some other way). 1057 // with the IPC (it's from another load, or it's invalid in some other way).
1056 // We expect this to be a rare occurrence. 1058 // We expect this to be a rare occurrence.
1057 RecordInternalError(ERR_BAD_TIMING_IPC); 1059 RecordInternalError(ERR_BAD_TIMING_IPC);
1058 } 1060 }
1059 } 1061 }
1060 1062
1061 bool MetricsWebContentsObserver::ShouldTrackNavigation( 1063 bool MetricsWebContentsObserver::ShouldTrackNavigation(
1062 content::NavigationHandle* navigation_handle) const { 1064 content::NavigationHandle* navigation_handle) const {
1063 DCHECK(navigation_handle->IsInMainFrame()); 1065 DCHECK(navigation_handle->IsInMainFrame());
1064 if (!navigation_handle->GetURL().SchemeIsHTTPOrHTTPS()) 1066
1067 // Ignore same-page navigations.
1068 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
1065 return false; 1069 return false;
1066 if (embedder_interface_->IsNewTabPageUrl(navigation_handle->GetURL())) 1070
1067 return false; 1071 return BrowserPageTrackDecider(embedder_interface_.get(), web_contents(),
1068 if (navigation_handle->HasCommitted()) { 1072 navigation_handle).ShouldTrack();
1069 if (navigation_handle->IsSamePage() || navigation_handle->IsErrorPage())
1070 return false;
1071 const std::string& mime_type = web_contents()->GetContentsMimeType();
1072 if (mime_type != "text/html" && mime_type != "application/xhtml+xml")
1073 return false;
1074 }
1075 return true;
1076 } 1073 }
1077 1074
1078 } // namespace page_load_metrics 1075 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698