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 "chrome/browser/page_load_metrics/observers/stale_while_revalidate_metr ics_observer.h" | 5 #include "chrome/browser/page_load_metrics/observers/stale_while_revalidate_metr ics_observer.h" |
6 | 6 |
7 #include "components/page_load_metrics/browser/page_load_metrics_util.h" | 7 #include "components/page_load_metrics/browser/page_load_metrics_util.h" |
8 #include "components/page_load_metrics/common/page_load_timing.h" | 8 #include "components/page_load_metrics/common/page_load_timing.h" |
9 #include "content/public/browser/navigation_handle.h" | 9 #include "content/public/browser/navigation_handle.h" |
10 #include "net/base/stale_while_revalidate_experiment_domains.h" | 10 #include "net/base/stale_while_revalidate_experiment_domains.h" |
11 | 11 |
12 namespace chrome { | 12 namespace chrome { |
13 | 13 |
14 StaleWhileRevalidateMetricsObserver::StaleWhileRevalidateMetricsObserver() | 14 StaleWhileRevalidateMetricsObserver::StaleWhileRevalidateMetricsObserver() |
15 : is_interesting_domain_(false) {} | 15 : is_interesting_domain_(false) {} |
16 | 16 |
17 void StaleWhileRevalidateMetricsObserver::OnCommit( | 17 void StaleWhileRevalidateMetricsObserver::OnCommit( |
18 content::NavigationHandle* navigation_handle) { | 18 content::NavigationHandle* navigation_handle) { |
19 is_interesting_domain_ = net::IsHostInStaleWhileRevalidateExperimentDomain( | 19 is_interesting_domain_ = net::IsHostInStaleWhileRevalidateExperimentDomain( |
20 navigation_handle->GetURL().host()); | 20 navigation_handle->GetURL().host()); |
21 } | 21 } |
22 | 22 |
23 void StaleWhileRevalidateMetricsObserver::OnComplete( | 23 void StaleWhileRevalidateMetricsObserver::OnComplete( |
24 const page_load_metrics::PageLoadTiming& timing, | 24 const page_load_metrics::PageLoadTiming& timing, |
25 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 25 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
26 using page_load_metrics::EventOccurredInForeground; | |
27 | |
26 if (!is_interesting_domain_) | 28 if (!is_interesting_domain_) |
27 return; | 29 return; |
28 | 30 |
29 if (!timing.load_event_start.is_zero()) { | 31 // A page load that started in the background usually means a prerender. The |
32 // performance metrics for a prerender aren't directly comparable to normal | |
33 // foreground page loads, so just drop them. | |
34 if (!extra_info.started_in_foreground) | |
35 return; | |
36 | |
37 if (EventOccurredInForeground(timing.load_event_start, extra_info)) { | |
Bryan McQuade
2015/12/09 20:35:23
I agree that we should do this, but can you make s
Charlie Harrison
2015/12/09 22:46:43
Sorry this shouldn't be included in this change.
| |
30 PAGE_LOAD_HISTOGRAM( | 38 PAGE_LOAD_HISTOGRAM( |
31 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." | 39 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." |
32 "NavigationToLoadEventFired", | 40 "NavigationToLoadEventFired", |
33 timing.load_event_start); | 41 timing.load_event_start); |
34 } | 42 } |
35 if (!timing.first_layout.is_zero()) { | 43 if (EventOccurredInForeground(timing.first_layout, extra_info)) { |
36 PAGE_LOAD_HISTOGRAM( | 44 PAGE_LOAD_HISTOGRAM( |
37 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." | 45 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." |
38 "NavigationToFirstLayout", | 46 "NavigationToFirstLayout", |
39 timing.first_layout); | 47 timing.first_layout); |
40 } | 48 } |
41 if (!timing.first_text_paint.is_zero()) { | 49 if (EventOccurredInForeground(timing.first_text_paint, extra_info)) { |
42 PAGE_LOAD_HISTOGRAM( | 50 PAGE_LOAD_HISTOGRAM( |
43 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." | 51 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." |
44 "NavigationToFirstTextPaint", | 52 "NavigationToFirstTextPaint", |
45 timing.first_text_paint); | 53 timing.first_text_paint); |
46 } | 54 } |
47 } | 55 } |
48 | 56 |
49 } // namespace chrome | 57 } // namespace chrome |
OLD | NEW |