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 | 10 |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 // Name constants are exposed here so they can be referenced from tests. | 13 // Name constants are exposed here so they can be referenced from tests. |
14 extern const char kUkmPageLoadEventName[]; | 14 extern const char kUkmPageLoadEventName[]; |
| 15 extern const char kUkmParseStartName[]; |
| 16 extern const char kUkmDomContentLoadedName[]; |
| 17 extern const char kUkmLoadEventName[]; |
15 extern const char kUkmFirstContentfulPaintName[]; | 18 extern const char kUkmFirstContentfulPaintName[]; |
| 19 extern const char kUkmFirstMeaningfulPaintName[]; |
| 20 extern const char kUkmForegroundDurationName[]; |
16 | 21 |
17 } // namespace internal | 22 } // namespace internal |
18 | 23 |
19 // If URL-Keyed-Metrics (UKM) is enabled in the system, this is used to | 24 // If URL-Keyed-Metrics (UKM) is enabled in the system, this is used to |
20 // populate it with top-level page-load metrics. | 25 // populate it with top-level page-load metrics. |
21 class UkmPageLoadMetricsObserver | 26 class UkmPageLoadMetricsObserver |
22 : public page_load_metrics::PageLoadMetricsObserver { | 27 : public page_load_metrics::PageLoadMetricsObserver { |
23 public: | 28 public: |
24 // Returns a UkmPageLoadMetricsObserver, or nullptr if it is not needed. | 29 // Returns a UkmPageLoadMetricsObserver, or nullptr if it is not needed. |
25 static std::unique_ptr<page_load_metrics::PageLoadMetricsObserver> | 30 static std::unique_ptr<page_load_metrics::PageLoadMetricsObserver> |
(...skipping 21 matching lines...) Expand all Loading... |
47 | 52 |
48 void OnComplete(const page_load_metrics::PageLoadTiming& timing, | 53 void OnComplete(const page_load_metrics::PageLoadTiming& timing, |
49 const page_load_metrics::PageLoadExtraInfo& info) override; | 54 const page_load_metrics::PageLoadExtraInfo& info) override; |
50 | 55 |
51 private: | 56 private: |
52 // Records page load timing related metrics available in PageLoadTiming, such | 57 // Records page load timing related metrics available in PageLoadTiming, such |
53 // as first contentful paint. | 58 // as first contentful paint. |
54 void RecordTimingMetrics(const page_load_metrics::PageLoadTiming& timing); | 59 void RecordTimingMetrics(const page_load_metrics::PageLoadTiming& timing); |
55 | 60 |
56 // Records metrics based on the PageLoadExtraInfo struct, as well as updating | 61 // Records metrics based on the PageLoadExtraInfo struct, as well as updating |
57 // the URL. | 62 // the URL. |app_background_time| should be set to a timestamp if the app was |
| 63 // backgrounded, otherwise it should be set to a null TimeTicks. |
58 void RecordPageLoadExtraInfoMetrics( | 64 void RecordPageLoadExtraInfoMetrics( |
59 const page_load_metrics::PageLoadExtraInfo& info); | 65 const page_load_metrics::PageLoadExtraInfo& info, |
| 66 base::TimeTicks app_background_time); |
60 | 67 |
61 // Unique UKM identifier for the page load we are recording metrics for. | 68 // Unique UKM identifier for the page load we are recording metrics for. |
62 const int32_t source_id_; | 69 const int32_t source_id_; |
63 | 70 |
64 DISALLOW_COPY_AND_ASSIGN(UkmPageLoadMetricsObserver); | 71 DISALLOW_COPY_AND_ASSIGN(UkmPageLoadMetricsObserver); |
65 }; | 72 }; |
66 | 73 |
67 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_UKM_PAGE_LOAD_METRICS_OBSE
RVER_H_ | 74 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_UKM_PAGE_LOAD_METRICS_OBSE
RVER_H_ |
OLD | NEW |