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 "chrome/browser/page_load_metrics/page_load_metrics_util.h" | 7 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" |
8 #include "chrome/common/page_load_metrics/page_load_timing.h" | 8 #include "chrome/common/page_load_metrics/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) {} | |
16 | 15 |
17 void StaleWhileRevalidateMetricsObserver::OnCommit( | 16 page_load_metrics::PageLoadMetricsObserver::ObservePolicy |
| 17 StaleWhileRevalidateMetricsObserver::OnCommit( |
18 content::NavigationHandle* navigation_handle) { | 18 content::NavigationHandle* navigation_handle) { |
19 is_interesting_domain_ = net::IsHostInStaleWhileRevalidateExperimentDomain( | 19 return net::IsHostInStaleWhileRevalidateExperimentDomain( |
20 navigation_handle->GetURL().host()); | 20 navigation_handle->GetURL().host()) |
| 21 ? CONTINUE_OBSERVING |
| 22 : STOP_OBSERVING; |
21 } | 23 } |
22 | 24 |
23 void StaleWhileRevalidateMetricsObserver::OnComplete( | 25 void StaleWhileRevalidateMetricsObserver::OnComplete( |
24 const page_load_metrics::PageLoadTiming& timing, | 26 const page_load_metrics::PageLoadTiming& timing, |
25 const page_load_metrics::PageLoadExtraInfo& extra_info) { | 27 const page_load_metrics::PageLoadExtraInfo& extra_info) { |
26 using page_load_metrics::WasStartedInForegroundOptionalEventInForeground; | 28 using page_load_metrics::WasStartedInForegroundOptionalEventInForeground; |
27 | 29 |
28 if (!is_interesting_domain_) | |
29 return; | |
30 | |
31 if (WasStartedInForegroundOptionalEventInForeground(timing.load_event_start, | 30 if (WasStartedInForegroundOptionalEventInForeground(timing.load_event_start, |
32 extra_info)) { | 31 extra_info)) { |
33 PAGE_LOAD_HISTOGRAM( | 32 PAGE_LOAD_HISTOGRAM( |
34 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." | 33 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." |
35 "NavigationToLoadEventFired", | 34 "NavigationToLoadEventFired", |
36 timing.load_event_start.value()); | 35 timing.load_event_start.value()); |
37 } | 36 } |
38 if (WasStartedInForegroundOptionalEventInForeground(timing.first_layout, | 37 if (WasStartedInForegroundOptionalEventInForeground(timing.first_layout, |
39 extra_info)) { | 38 extra_info)) { |
40 PAGE_LOAD_HISTOGRAM( | 39 PAGE_LOAD_HISTOGRAM( |
41 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." | 40 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." |
42 "NavigationToFirstLayout", | 41 "NavigationToFirstLayout", |
43 timing.first_layout.value()); | 42 timing.first_layout.value()); |
44 } | 43 } |
45 if (WasStartedInForegroundOptionalEventInForeground(timing.first_text_paint, | 44 if (WasStartedInForegroundOptionalEventInForeground(timing.first_text_paint, |
46 extra_info)) { | 45 extra_info)) { |
47 PAGE_LOAD_HISTOGRAM( | 46 PAGE_LOAD_HISTOGRAM( |
48 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." | 47 "PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2." |
49 "NavigationToFirstTextPaint", | 48 "NavigationToFirstTextPaint", |
50 timing.first_text_paint.value()); | 49 timing.first_text_paint.value()); |
51 } | 50 } |
52 } | 51 } |
53 | 52 |
54 } // namespace chrome | 53 } // namespace chrome |
OLD | NEW |