OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_UKM_PAGE_LOAD_METRICS_OBSERVE
R_H_ |
| 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_UKM_PAGE_LOAD_METRICS_OBSERVE
R_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "chrome/browser/page_load_metrics/page_load_metrics_observer.h" |
| 10 |
| 11 // If URL-Keyed-Metrics (UKM) is enabled in the system, this is used to |
| 12 // populate it with top-level page-load metrics. |
| 13 class UkmPageLoadMetricsObserver |
| 14 : public page_load_metrics::PageLoadMetricsObserver { |
| 15 public: |
| 16 // Returns a UkmPageLoadMetricsObserver, or nullptr if it is not needed. |
| 17 static std::unique_ptr<page_load_metrics::PageLoadMetricsObserver> |
| 18 CreateIfNeeded(); |
| 19 |
| 20 UkmPageLoadMetricsObserver(); |
| 21 |
| 22 // page_load_metrics::PageLoadMetricsObserver implementation: |
| 23 ObservePolicy OnStart(content::NavigationHandle* navigation_handle, |
| 24 const GURL& currently_committed_url, |
| 25 bool started_in_foreground) override; |
| 26 |
| 27 ObservePolicy FlushMetricsOnAppEnterBackground( |
| 28 const page_load_metrics::PageLoadTiming& timing, |
| 29 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 30 |
| 31 ObservePolicy OnHidden( |
| 32 const page_load_metrics::PageLoadTiming& timing, |
| 33 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 34 |
| 35 void OnComplete(const page_load_metrics::PageLoadTiming& timing, |
| 36 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 37 |
| 38 private: |
| 39 void SendMetricsToUkm(const page_load_metrics::PageLoadTiming& timing, |
| 40 const page_load_metrics::PageLoadExtraInfo& info); |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(UkmPageLoadMetricsObserver); |
| 43 }; |
| 44 |
| 45 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_UKM_PAGE_LOAD_METRICS_OBSE
RVER_H_ |
OLD | NEW |