OLD | NEW |
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" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/browser/navigation_details.h" | 12 #include "content/public/browser/navigation_details.h" |
13 #include "content/public/browser/navigation_handle.h" | 13 #include "content/public/browser/navigation_handle.h" |
14 #include "content/public/browser/render_frame_host.h" | 14 #include "content/public/browser/render_frame_host.h" |
15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
16 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
17 #include "content/public/browser/web_contents_user_data.h" | 17 #include "content/public/browser/web_contents_user_data.h" |
18 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
19 #include "ipc/ipc_message_macros.h" | 19 #include "ipc/ipc_message_macros.h" |
20 | 20 |
21 DEFINE_WEB_CONTENTS_USER_DATA_KEY( | 21 DEFINE_WEB_CONTENTS_USER_DATA_KEY( |
22 page_load_metrics::MetricsWebContentsObserver); | 22 page_load_metrics::MetricsWebContentsObserver); |
23 | 23 |
24 namespace page_load_metrics { | 24 namespace page_load_metrics { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
| 28 // The url we see from the renderer side is not always the same as what |
| 29 // we see from the browser side (e.g. chrome://newtab). We want to be |
| 30 // sure here that we aren't logging UMA for internal pages. |
| 31 bool IsRelevantNavigation( |
| 32 content::NavigationHandle* navigation_handle, |
| 33 const GURL& browser_url, |
| 34 const std::string& mime_type) { |
| 35 DCHECK(navigation_handle->HasCommitted()); |
| 36 return navigation_handle->IsInMainFrame() && |
| 37 !navigation_handle->IsSamePage() && |
| 38 !navigation_handle->IsErrorPage() && |
| 39 navigation_handle->GetURL().SchemeIsHTTPOrHTTPS() && |
| 40 browser_url.SchemeIsHTTPOrHTTPS() && |
| 41 (mime_type == "text/html" || mime_type == "application/xhtml+xml"); |
| 42 } |
| 43 |
28 bool IsValidPageLoadTiming(const PageLoadTiming& timing) { | 44 bool IsValidPageLoadTiming(const PageLoadTiming& timing) { |
29 if (timing.IsEmpty()) | 45 if (timing.IsEmpty()) |
30 return false; | 46 return false; |
31 | 47 |
32 // If we have a non-empty timing, it should always have a navigation start. | 48 // If we have a non-empty timing, it should always have a navigation start. |
33 DCHECK(!timing.navigation_start.is_null()); | 49 DCHECK(!timing.navigation_start.is_null()); |
34 | 50 |
35 // If we have a DOM content loaded event, we should have a response start. | 51 // If we have a DOM content loaded event, we should have a response start. |
36 DCHECK_IMPLIES( | 52 DCHECK_IMPLIES( |
37 !timing.dom_content_loaded_event_start.is_zero(), | 53 !timing.dom_content_loaded_event_start.is_zero(), |
(...skipping 11 matching lines...) Expand all Loading... |
49 } | 65 } |
50 | 66 |
51 return true; | 67 return true; |
52 } | 68 } |
53 | 69 |
54 base::Time WallTimeFromTimeTicks(base::TimeTicks time) { | 70 base::Time WallTimeFromTimeTicks(base::TimeTicks time) { |
55 return base::Time::FromDoubleT( | 71 return base::Time::FromDoubleT( |
56 (time - base::TimeTicks::UnixEpoch()).InSecondsF()); | 72 (time - base::TimeTicks::UnixEpoch()).InSecondsF()); |
57 } | 73 } |
58 | 74 |
| 75 void RecordInternalError(InternalErrorLoadEvent event) { |
| 76 UMA_HISTOGRAM_ENUMERATION( |
| 77 "PageLoad.Events.InternalError", event, ERR_LAST_ENTRY); |
| 78 } |
| 79 |
59 } // namespace | 80 } // namespace |
60 | 81 |
61 #define PAGE_LOAD_HISTOGRAM(name, sample) \ | 82 #define PAGE_LOAD_HISTOGRAM(name, sample) \ |
62 UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, \ | 83 UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, \ |
63 base::TimeDelta::FromMilliseconds(10), \ | 84 base::TimeDelta::FromMilliseconds(10), \ |
64 base::TimeDelta::FromMinutes(10), 100) | 85 base::TimeDelta::FromMinutes(10), 100) |
65 | 86 |
66 PageLoadTracker::PageLoadTracker(bool in_foreground) | 87 PageLoadTracker::PageLoadTracker(bool in_foreground) |
67 : has_commit_(false), started_in_foreground_(in_foreground) { | 88 : has_commit_(false), started_in_foreground_(in_foreground) {} |
68 RecordEvent(PAGE_LOAD_STARTED); | |
69 } | |
70 | 89 |
71 PageLoadTracker::~PageLoadTracker() { | 90 PageLoadTracker::~PageLoadTracker() { |
72 // Even a load that failed a provisional load should log | |
73 // that it aborted before first layout. | |
74 if (timing_.first_layout.is_zero()) | |
75 RecordEvent(PAGE_LOAD_ABORTED_BEFORE_FIRST_LAYOUT); | |
76 | |
77 if (has_commit_) | 91 if (has_commit_) |
78 RecordTimingHistograms(); | 92 RecordTimingHistograms(); |
79 } | 93 } |
80 | 94 |
81 void PageLoadTracker::WebContentsHidden() { | 95 void PageLoadTracker::WebContentsHidden() { |
82 // Only log the first time we background in a given page load. | 96 // Only log the first time we background in a given page load. |
83 if (background_time_.is_null()) { | 97 if (started_in_foreground_ && background_time_.is_null()) |
84 background_time_ = base::TimeTicks::Now(); | 98 background_time_ = base::TimeTicks::Now(); |
85 } | 99 } |
| 100 |
| 101 void PageLoadTracker::WebContentsShown() { |
| 102 // Only log the first time we foreground in a given page load. |
| 103 // Don't log foreground time if we started foregrounded. |
| 104 if (!started_in_foreground_ && foreground_time_.is_null()) |
| 105 foreground_time_ = base::TimeTicks::Now(); |
86 } | 106 } |
87 | 107 |
88 void PageLoadTracker::Commit() { | 108 void PageLoadTracker::Commit() { |
89 has_commit_ = true; | 109 has_commit_ = true; |
| 110 // We log the event that this load started. Because we don't know if a load is |
| 111 // relevant or if it will commit before now, we have to log this event at |
| 112 // commit time. |
| 113 RecordCommittedEvent(COMMITTED_LOAD_STARTED, !started_in_foreground_); |
90 } | 114 } |
91 | 115 |
92 bool PageLoadTracker::UpdateTiming(const PageLoadTiming& timing) { | 116 bool PageLoadTracker::UpdateTiming(const PageLoadTiming& new_timing) { |
93 // Throw away IPCs that are not relevant to the current navigation. | 117 // Throw away IPCs that are not relevant to the current navigation. |
94 if (!timing_.navigation_start.is_null() && | 118 // Two timing structures cannot refer to the same navigation if they indicate |
95 timing_.navigation_start != timing.navigation_start) { | 119 // that a navigation started at different times, so a new timing struct with a |
96 // TODO(csharrison) uma log a counter here | 120 // different start time from an earlier struct is considered invalid. |
97 return false; | 121 bool valid_timing_descendent = |
98 } | 122 timing_.navigation_start.is_null() || |
99 if (IsValidPageLoadTiming(timing)) { | 123 timing_.navigation_start == new_timing.navigation_start; |
100 timing_ = timing; | 124 if (IsValidPageLoadTiming(new_timing) && valid_timing_descendent) { |
| 125 timing_ = new_timing; |
101 return true; | 126 return true; |
102 } | 127 } |
103 return false; | 128 return false; |
104 } | 129 } |
105 | 130 |
| 131 bool PageLoadTracker::HasBackgrounded() { |
| 132 return !started_in_foreground_ || !background_time_.is_null(); |
| 133 } |
| 134 |
106 void PageLoadTracker::RecordTimingHistograms() { | 135 void PageLoadTracker::RecordTimingHistograms() { |
107 DCHECK(has_commit_); | 136 DCHECK(has_commit_); |
| 137 if (timing_.IsEmpty()) { |
| 138 RecordInternalError(ERR_NO_IPCS_RECEIVED); |
| 139 return; |
| 140 } |
108 // This method is similar to how blink converts TimeTicks to epoch time. | 141 // This method is similar to how blink converts TimeTicks to epoch time. |
109 // There may be slight inaccuracies due to inter-process timestamps, but | 142 // There may be slight inaccuracies due to inter-process timestamps, but |
110 // this solution is the best we have right now. | 143 // this solution is the best we have right now. |
111 base::TimeDelta background_delta; | 144 base::TimeDelta background_delta; |
112 if (started_in_foreground_) { | 145 if (started_in_foreground_) { |
113 background_delta = background_time_.is_null() | 146 background_delta = background_time_.is_null() |
114 ? base::TimeDelta::Max() | 147 ? base::TimeDelta::Max() |
115 : WallTimeFromTimeTicks(background_time_) - timing_.navigation_start; | 148 : WallTimeFromTimeTicks(background_time_) - timing_.navigation_start; |
116 } | 149 } |
117 | 150 |
118 if (!timing_.dom_content_loaded_event_start.is_zero()) { | 151 if (!timing_.dom_content_loaded_event_start.is_zero()) { |
119 if (timing_.dom_content_loaded_event_start < background_delta) { | 152 if (timing_.dom_content_loaded_event_start < background_delta) { |
120 PAGE_LOAD_HISTOGRAM( | 153 PAGE_LOAD_HISTOGRAM( |
121 "PageLoad.Timing2.NavigationToDOMContentLoadedEventFired", | 154 "PageLoad.Timing2.NavigationToDOMContentLoadedEventFired", |
122 timing_.dom_content_loaded_event_start); | 155 timing_.dom_content_loaded_event_start); |
123 } else { | 156 } else { |
124 PAGE_LOAD_HISTOGRAM( | 157 PAGE_LOAD_HISTOGRAM( |
125 "PageLoad.Timing2.NavigationToDOMContentLoadedEventFired.BG", | 158 "PageLoad.Timing2.NavigationToDOMContentLoadedEventFired.Background", |
126 timing_.dom_content_loaded_event_start); | 159 timing_.dom_content_loaded_event_start); |
127 } | 160 } |
128 } | 161 } |
129 if (!timing_.load_event_start.is_zero()) { | 162 if (!timing_.load_event_start.is_zero()) { |
130 if (timing_.load_event_start < background_delta) { | 163 if (timing_.load_event_start < background_delta) { |
131 PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToLoadEventFired", | 164 PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToLoadEventFired", |
132 timing_.load_event_start); | 165 timing_.load_event_start); |
133 } else { | 166 } else { |
134 PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToLoadEventFired.BG", | 167 PAGE_LOAD_HISTOGRAM( |
135 timing_.load_event_start); | 168 "PageLoad.Timing2.NavigationToLoadEventFired.Background", |
| 169 timing_.load_event_start); |
136 } | 170 } |
137 } | 171 } |
138 if (!timing_.first_layout.is_zero()) { | 172 if (timing_.first_layout.is_zero()) { |
| 173 RecordCommittedEvent(COMMITTED_LOAD_FAILED_BEFORE_FIRST_LAYOUT, |
| 174 HasBackgrounded()); |
| 175 } else { |
139 if (timing_.first_layout < background_delta) { | 176 if (timing_.first_layout < background_delta) { |
140 PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToFirstLayout", | 177 PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToFirstLayout", |
141 timing_.first_layout); | 178 timing_.first_layout); |
142 RecordEvent(PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_FOREGROUND); | 179 RecordCommittedEvent(COMMITTED_LOAD_SUCCESSFUL_FIRST_LAYOUT, false); |
143 } else { | 180 } else { |
144 PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToFirstLayout.BG", | 181 PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToFirstLayout.Background", |
145 timing_.first_layout); | 182 timing_.first_layout); |
146 RecordEvent(PAGE_LOAD_SUCCESSFUL_FIRST_LAYOUT_BACKGROUND); | 183 RecordCommittedEvent(COMMITTED_LOAD_SUCCESSFUL_FIRST_LAYOUT, true); |
147 } | 184 } |
148 } | 185 } |
149 if (!timing_.first_text_paint.is_zero()) { | 186 if (!timing_.first_text_paint.is_zero()) { |
150 if (timing_.first_text_paint < background_delta) { | 187 if (timing_.first_text_paint < background_delta) { |
151 PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToFirstTextPaint", | 188 PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToFirstTextPaint", |
152 timing_.first_text_paint); | 189 timing_.first_text_paint); |
153 } else { | 190 } else { |
154 PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToFirstTextPaint.BG", | 191 PAGE_LOAD_HISTOGRAM( |
155 timing_.first_text_paint); | 192 "PageLoad.Timing2.NavigationToFirstTextPaint.Background", |
| 193 timing_.first_text_paint); |
156 } | 194 } |
157 } | 195 } |
| 196 // Log time to first foreground / time to first background. Log counts that we |
| 197 // started a relevant page load in the foreground / background. |
| 198 if (!background_time_.is_null()) { |
| 199 PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToFirstBackground", |
| 200 background_delta); |
| 201 } else if (!foreground_time_.is_null()) { |
| 202 PAGE_LOAD_HISTOGRAM( |
| 203 "PageLoad.Timing2.NavigationToFirstForeground", |
| 204 WallTimeFromTimeTicks(foreground_time_) - timing_.navigation_start); |
| 205 } |
158 } | 206 } |
159 | 207 |
160 void PageLoadTracker::RecordEvent(PageLoadEvent event) { | 208 void PageLoadTracker::RecordProvisionalEvent(ProvisionalLoadEvent event) { |
161 UMA_HISTOGRAM_ENUMERATION( | 209 if (HasBackgrounded()) { |
162 "PageLoad.EventCounts", event, PAGE_LOAD_LAST_ENTRY); | 210 UMA_HISTOGRAM_ENUMERATION("PageLoad.Events.Provisional.Background", event, |
| 211 PROVISIONAL_LOAD_LAST_ENTRY); |
| 212 } else { |
| 213 UMA_HISTOGRAM_ENUMERATION("PageLoad.Events.Provisional", event, |
| 214 PROVISIONAL_LOAD_LAST_ENTRY); |
| 215 } |
| 216 } |
| 217 |
| 218 // RecordCommittedEvent needs a backgrounded input because we need to special |
| 219 // case a few events that need either precise timing measurements, or different |
| 220 // logic than simply "Did I background before logging this event?" |
| 221 void PageLoadTracker::RecordCommittedEvent(CommittedLoadEvent event, |
| 222 bool backgrounded) { |
| 223 if (backgrounded) { |
| 224 UMA_HISTOGRAM_ENUMERATION("PageLoad.Events.Committed.Background", event, |
| 225 COMMITTED_LOAD_LAST_ENTRY); |
| 226 } else { |
| 227 UMA_HISTOGRAM_ENUMERATION("PageLoad.Events.Committed", event, |
| 228 COMMITTED_LOAD_LAST_ENTRY); |
| 229 } |
163 } | 230 } |
164 | 231 |
165 MetricsWebContentsObserver::MetricsWebContentsObserver( | 232 MetricsWebContentsObserver::MetricsWebContentsObserver( |
166 content::WebContents* web_contents) | 233 content::WebContents* web_contents) |
167 : content::WebContentsObserver(web_contents), in_foreground_(false) {} | 234 : content::WebContentsObserver(web_contents), in_foreground_(false) {} |
168 | 235 |
169 MetricsWebContentsObserver::~MetricsWebContentsObserver() {} | 236 MetricsWebContentsObserver::~MetricsWebContentsObserver() {} |
170 | 237 |
171 bool MetricsWebContentsObserver::OnMessageReceived( | 238 bool MetricsWebContentsObserver::OnMessageReceived( |
172 const IPC::Message& message, | 239 const IPC::Message& message, |
(...skipping 23 matching lines...) Expand all Loading... |
196 void MetricsWebContentsObserver::DidFinishNavigation( | 263 void MetricsWebContentsObserver::DidFinishNavigation( |
197 content::NavigationHandle* navigation_handle) { | 264 content::NavigationHandle* navigation_handle) { |
198 if (!navigation_handle->IsInMainFrame()) | 265 if (!navigation_handle->IsInMainFrame()) |
199 return; | 266 return; |
200 | 267 |
201 scoped_ptr<PageLoadTracker> finished_nav( | 268 scoped_ptr<PageLoadTracker> finished_nav( |
202 provisional_loads_.take_and_erase(navigation_handle)); | 269 provisional_loads_.take_and_erase(navigation_handle)); |
203 DCHECK(finished_nav); | 270 DCHECK(finished_nav); |
204 | 271 |
205 // Handle a pre-commit error here. Navigations that result in an error page | 272 // Handle a pre-commit error here. Navigations that result in an error page |
206 // will be ignored. | 273 // will be ignored. Note that downloads/204s will result in HasCommitted() |
| 274 // returning false. |
207 if (!navigation_handle->HasCommitted()) { | 275 if (!navigation_handle->HasCommitted()) { |
208 finished_nav->RecordEvent(PAGE_LOAD_FAILED_BEFORE_COMMIT); | 276 net::Error error = navigation_handle->GetNetErrorCode(); |
209 if (navigation_handle->GetNetErrorCode() == net::ERR_ABORTED) | 277 finished_nav->RecordProvisionalEvent( |
210 finished_nav->RecordEvent(PAGE_LOAD_ABORTED_BEFORE_COMMIT); | 278 error == net::OK ? PROVISIONAL_LOAD_STOPPED |
| 279 : error == net::ERR_ABORTED ? PROVISIONAL_LOAD_ERR_ABORTED |
| 280 : PROVISIONAL_LOAD_ERR_FAILED_NON_ABORT); |
211 return; | 281 return; |
212 } | 282 } |
| 283 finished_nav->RecordProvisionalEvent(PROVISIONAL_LOAD_COMMITTED); |
213 | 284 |
214 // Don't treat a same-page nav as a new page load. | 285 // Don't treat a same-page nav as a new page load. |
215 if (navigation_handle->IsSamePage()) | 286 if (navigation_handle->IsSamePage()) |
216 return; | 287 return; |
217 | 288 |
218 // Eagerly log the previous UMA even if we don't care about the current | 289 // Eagerly log the previous UMA even if we don't care about the current |
219 // navigation. | 290 // navigation. |
220 committed_load_.reset(); | 291 committed_load_.reset(); |
221 | 292 |
222 if (!IsRelevantNavigation(navigation_handle)) | 293 const GURL& browser_url = web_contents()->GetLastCommittedURL(); |
| 294 const std::string& mime_type = web_contents()->GetContentsMimeType(); |
| 295 DCHECK(!browser_url.is_empty()); |
| 296 DCHECK(!mime_type.empty()); |
| 297 if (!IsRelevantNavigation(navigation_handle, browser_url, mime_type)) |
223 return; | 298 return; |
224 | 299 |
225 committed_load_ = finished_nav.Pass(); | 300 committed_load_ = finished_nav.Pass(); |
226 committed_load_->Commit(); | 301 committed_load_->Commit(); |
227 } | 302 } |
228 | 303 |
229 void MetricsWebContentsObserver::WasShown() { | 304 void MetricsWebContentsObserver::WasShown() { |
230 in_foreground_ = true; | 305 in_foreground_ = true; |
| 306 if (committed_load_) |
| 307 committed_load_->WebContentsShown(); |
| 308 for (const auto& kv : provisional_loads_) { |
| 309 kv.second->WebContentsShown(); |
| 310 } |
231 } | 311 } |
232 | 312 |
233 void MetricsWebContentsObserver::WasHidden() { | 313 void MetricsWebContentsObserver::WasHidden() { |
234 in_foreground_ = false; | 314 in_foreground_ = false; |
235 if (committed_load_) | 315 if (committed_load_) |
236 committed_load_->WebContentsHidden(); | 316 committed_load_->WebContentsHidden(); |
237 for (const auto& kv : provisional_loads_) { | 317 for (const auto& kv : provisional_loads_) { |
238 kv.second->WebContentsHidden(); | 318 kv.second->WebContentsHidden(); |
239 } | 319 } |
240 } | 320 } |
241 | 321 |
242 // This will occur when the process for the main RenderFrameHost exits, either | 322 // This will occur when the process for the main RenderFrameHost exits, either |
243 // normally or from a crash. We eagerly log data from the last committed load if | 323 // normally or from a crash. We eagerly log data from the last committed load if |
244 // we have one. | 324 // we have one. |
245 void MetricsWebContentsObserver::RenderProcessGone( | 325 void MetricsWebContentsObserver::RenderProcessGone( |
246 base::TerminationStatus status) { | 326 base::TerminationStatus status) { |
247 committed_load_.reset(); | 327 committed_load_.reset(); |
248 } | 328 } |
249 | 329 |
250 void MetricsWebContentsObserver::OnTimingUpdated( | 330 void MetricsWebContentsObserver::OnTimingUpdated( |
251 content::RenderFrameHost* render_frame_host, | 331 content::RenderFrameHost* render_frame_host, |
252 const PageLoadTiming& timing) { | 332 const PageLoadTiming& timing) { |
253 if (!committed_load_) | 333 bool error = false; |
254 return; | 334 if (!committed_load_) { |
| 335 RecordInternalError(ERR_IPC_WITH_NO_COMMITTED_LOAD); |
| 336 error = true; |
| 337 } |
255 | 338 |
256 // We may receive notifications from frames that have been navigated away | 339 // We may receive notifications from frames that have been navigated away |
257 // from. We simply ignore them. | 340 // from. We simply ignore them. |
258 if (render_frame_host != web_contents()->GetMainFrame()) | 341 if (render_frame_host != web_contents()->GetMainFrame()) { |
259 return; | 342 RecordInternalError(ERR_IPC_FROM_WRONG_FRAME); |
| 343 error = true; |
| 344 } |
260 | 345 |
261 // For urls like chrome://newtab, the renderer and browser disagree, | 346 // For urls like chrome://newtab, the renderer and browser disagree, |
262 // so we have to double check that the renderer isn't sending data from a | 347 // so we have to double check that the renderer isn't sending data from a |
263 // bad url like https://www.google.com/_/chrome/newtab. | 348 // bad url like https://www.google.com/_/chrome/newtab. |
264 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) | 349 if (!web_contents()->GetLastCommittedURL().SchemeIsHTTPOrHTTPS()) { |
| 350 RecordInternalError(ERR_IPC_FROM_BAD_URL_SCHEME); |
| 351 error = true; |
| 352 } |
| 353 |
| 354 if (error) |
265 return; | 355 return; |
266 | 356 |
267 committed_load_->UpdateTiming(timing); | 357 if (!committed_load_->UpdateTiming(timing)) { |
268 } | 358 // If the page load tracker cannot update its timing, something is wrong |
269 | 359 // with the IPC (it's from another load, or it's invalid in some other way). |
270 bool MetricsWebContentsObserver::IsRelevantNavigation( | 360 // We expect this to be a rare occurrence. |
271 content::NavigationHandle* navigation_handle) { | 361 RecordInternalError(ERR_BAD_TIMING_IPC); |
272 // The url we see from the renderer side is not always the same as what | 362 } |
273 // we see from the browser side (e.g. chrome://newtab). We want to be | |
274 // sure here that we aren't logging UMA for internal pages. | |
275 const GURL& browser_url = web_contents()->GetLastCommittedURL(); | |
276 return navigation_handle->IsInMainFrame() && | |
277 !navigation_handle->IsSamePage() && | |
278 !navigation_handle->IsErrorPage() && | |
279 navigation_handle->GetURL().SchemeIsHTTPOrHTTPS() && | |
280 browser_url.SchemeIsHTTPOrHTTPS(); | |
281 } | 363 } |
282 | 364 |
283 } // namespace page_load_metrics | 365 } // namespace page_load_metrics |
OLD | NEW |