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

Side by Side Diff: components/page_load_metrics/browser/metrics_web_contents_observer.cc

Issue 1350673003: Remove WebContentsObserver::DidCommitNavigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 2 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 "components/page_load_metrics/browser/metrics_web_contents_observer.h" 5 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "components/page_load_metrics/common/page_load_metrics_messages.h" 9 #include "components/page_load_metrics/common/page_load_metrics_messages.h"
10 #include "components/page_load_metrics/common/page_load_timing.h" 10 #include "components/page_load_metrics/common/page_load_timing.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 64 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
65 bool handled = true; 65 bool handled = true;
66 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(MetricsWebContentsObserver, message, 66 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(MetricsWebContentsObserver, message,
67 render_frame_host) 67 render_frame_host)
68 IPC_MESSAGE_HANDLER(PageLoadMetricsMsg_TimingUpdated, OnTimingUpdated) 68 IPC_MESSAGE_HANDLER(PageLoadMetricsMsg_TimingUpdated, OnTimingUpdated)
69 IPC_MESSAGE_UNHANDLED(handled = false) 69 IPC_MESSAGE_UNHANDLED(handled = false)
70 IPC_END_MESSAGE_MAP() 70 IPC_END_MESSAGE_MAP()
71 return handled; 71 return handled;
72 } 72 }
73 73
74 void MetricsWebContentsObserver::DidCommitNavigation( 74 void MetricsWebContentsObserver::DidFinishNavigation(
75 content::NavigationHandle* navigation_handle) { 75 content::NavigationHandle* navigation_handle) {
76 if (!navigation_handle->HasCommitted())
Charlie Harrison 2015/09/22 19:39:45 Will this ever be called while the previous naviga
clamy 2015/09/22 23:04:45 Yes it can be called when a previous navigation is
77 return;
76 if (navigation_handle->IsInMainFrame() && !navigation_handle->IsSamePage()) 78 if (navigation_handle->IsInMainFrame() && !navigation_handle->IsSamePage())
77 RecordTimingHistograms(); 79 RecordTimingHistograms();
78 if (IsRelevantNavigation(navigation_handle)) 80 if (IsRelevantNavigation(navigation_handle))
79 current_timing_.reset(new PageLoadTiming()); 81 current_timing_.reset(new PageLoadTiming());
80 } 82 }
81 83
82 // This will occur when the process for the main RenderFrameHost exits. 84 // This will occur when the process for the main RenderFrameHost exits.
83 // This will happen with a normal exit or a crash. 85 // This will happen with a normal exit or a crash.
84 void MetricsWebContentsObserver::RenderProcessGone( 86 void MetricsWebContentsObserver::RenderProcessGone(
85 base::TerminationStatus status) { 87 base::TerminationStatus status) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 143 }
142 144
143 bool MetricsWebContentsObserver::IsRelevantNavigation( 145 bool MetricsWebContentsObserver::IsRelevantNavigation(
144 content::NavigationHandle* navigation_handle) { 146 content::NavigationHandle* navigation_handle) {
145 // The url we see from the renderer side is not always the same as what 147 // The url we see from the renderer side is not always the same as what
146 // we see from the browser side (e.g. chrome://newtab). We want to be 148 // we see from the browser side (e.g. chrome://newtab). We want to be
147 // sure here that we aren't logging UMA for internal pages. 149 // sure here that we aren't logging UMA for internal pages.
148 const GURL& browser_url = web_contents()->GetLastCommittedURL(); 150 const GURL& browser_url = web_contents()->GetLastCommittedURL();
149 return navigation_handle->IsInMainFrame() && 151 return navigation_handle->IsInMainFrame() &&
150 !navigation_handle->IsSamePage() && 152 !navigation_handle->IsSamePage() &&
151 navigation_handle->HasCommittedDocument() && 153 !navigation_handle->IsErrorPage() &&
152 navigation_handle->GetURL().SchemeIsHTTPOrHTTPS() && 154 navigation_handle->GetURL().SchemeIsHTTPOrHTTPS() &&
153 browser_url.SchemeIsHTTPOrHTTPS(); 155 browser_url.SchemeIsHTTPOrHTTPS();
154 } 156 }
155 157
156 } // namespace page_load_metrics 158 } // namespace page_load_metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698