| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_AMP_PAGE_LOAD_METRICS_OBSERVE
R_H_ | 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_AMP_PAGE_LOAD_METRICS_OBSERVE
R_H_ |
| 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_AMP_PAGE_LOAD_METRICS_OBSERVE
R_H_ | 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_AMP_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 content { | 11 namespace content { |
| 12 class NavigationHandle; | 12 class NavigationHandle; |
| 13 } | 13 } |
| 14 | 14 |
| 15 namespace page_load_metrics { | |
| 16 struct PageLoadExtraInfo; | |
| 17 struct PageLoadTiming; | |
| 18 } | |
| 19 | |
| 20 // Observer responsible for recording page load metrics relevant to page served | 15 // Observer responsible for recording page load metrics relevant to page served |
| 21 // from the AMP cache. When AMP pages are served in a same page navigation, UMA | 16 // from the AMP cache. When AMP pages are served in a same page navigation, UMA |
| 22 // is not recorded; this is typical for AMP pages navigated to from google.com. | 17 // is not recorded; this is typical for AMP pages navigated to from google.com. |
| 23 // Navigations to AMP pages from the google search app or directly to the amp | 18 // Navigations to AMP pages from the google search app or directly to the amp |
| 24 // cache page will be tracked. Refreshing an AMP page served from google.com | 19 // cache page will be tracked. Refreshing an AMP page served from google.com |
| 25 // will be tracked. | 20 // will be tracked. |
| 26 class AMPPageLoadMetricsObserver | 21 class AMPPageLoadMetricsObserver |
| 27 : public page_load_metrics::PageLoadMetricsObserver { | 22 : public page_load_metrics::PageLoadMetricsObserver { |
| 28 public: | 23 public: |
| 29 enum class AMPViewType { | 24 enum class AMPViewType { |
| 30 NONE, | 25 NONE, |
| 31 AMP_CACHE, | 26 AMP_CACHE, |
| 32 GOOGLE_SEARCH_AMP_VIEWER, | 27 GOOGLE_SEARCH_AMP_VIEWER, |
| 33 GOOGLE_NEWS_AMP_VIEWER, | 28 GOOGLE_NEWS_AMP_VIEWER, |
| 34 }; | 29 }; |
| 35 | 30 |
| 36 static AMPViewType GetAMPViewType(const GURL& url); | 31 static AMPViewType GetAMPViewType(const GURL& url); |
| 37 | 32 |
| 38 AMPPageLoadMetricsObserver(); | 33 AMPPageLoadMetricsObserver(); |
| 39 ~AMPPageLoadMetricsObserver() override; | 34 ~AMPPageLoadMetricsObserver() override; |
| 40 | 35 |
| 41 // page_load_metrics::PageLoadMetricsObserver: | 36 // page_load_metrics::PageLoadMetricsObserver: |
| 42 ObservePolicy OnCommit(content::NavigationHandle* navigation_handle) override; | 37 ObservePolicy OnCommit(content::NavigationHandle* navigation_handle) override; |
| 43 void OnDomContentLoadedEventStart( | 38 void OnDomContentLoadedEventStart( |
| 44 const page_load_metrics::PageLoadTiming& timing, | 39 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 45 const page_load_metrics::PageLoadExtraInfo& info) override; | 40 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 46 void OnLoadEventStart( | 41 void OnLoadEventStart( |
| 47 const page_load_metrics::PageLoadTiming& timing, | 42 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 48 const page_load_metrics::PageLoadExtraInfo& info) override; | 43 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 49 void OnFirstLayout(const page_load_metrics::PageLoadTiming& timing, | 44 void OnFirstLayout(const page_load_metrics::mojom::PageLoadTiming& timing, |
| 50 const page_load_metrics::PageLoadExtraInfo& info) override; | 45 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 51 void OnFirstContentfulPaintInPage( | 46 void OnFirstContentfulPaintInPage( |
| 52 const page_load_metrics::PageLoadTiming& timing, | 47 const page_load_metrics::mojom::PageLoadTiming& timing, |
| 53 const page_load_metrics::PageLoadExtraInfo& info) override; | 48 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 54 void OnParseStart(const page_load_metrics::PageLoadTiming& timing, | 49 void OnParseStart(const page_load_metrics::mojom::PageLoadTiming& timing, |
| 55 const page_load_metrics::PageLoadExtraInfo& info) override; | 50 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 56 | 51 |
| 57 private: | 52 private: |
| 58 AMPViewType view_type_ = AMPViewType::NONE; | 53 AMPViewType view_type_ = AMPViewType::NONE; |
| 59 | 54 |
| 60 DISALLOW_COPY_AND_ASSIGN(AMPPageLoadMetricsObserver); | 55 DISALLOW_COPY_AND_ASSIGN(AMPPageLoadMetricsObserver); |
| 61 }; | 56 }; |
| 62 | 57 |
| 63 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_AMP_PAGE_LOAD_METRICS_OBSE
RVER_H_ | 58 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_AMP_PAGE_LOAD_METRICS_OBSE
RVER_H_ |
| OLD | NEW |