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