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