| 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 { | 15 namespace page_load_metrics { |
| 16 struct PageLoadExtraInfo; | 16 struct PageLoadExtraInfo; |
| 17 struct PageLoadTiming; | 17 struct PageLoadTiming; |
| 18 } | 18 } |
| 19 | 19 |
| 20 // Observer responsible for recording page load metrics relevant to page served | 20 // 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 | 21 // 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. | 22 // 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 | 23 // 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 | 24 // cache page will be tracked. Refreshing an AMP page served from google.com |
| 25 // will be tracked. | 25 // will be tracked. |
| 26 class AMPPageLoadMetricsObserver | 26 class AMPPageLoadMetricsObserver |
| 27 : public page_load_metrics::PageLoadMetricsObserver { | 27 : public page_load_metrics::PageLoadMetricsObserver { |
| 28 public: | 28 public: |
| 29 // If you add elements to this enum, make sure you update the enum value in |
| 30 // enums.xml. Only add elements to the end to prevent inconsistencies between |
| 31 // versions. |
| 29 enum class AMPViewType { | 32 enum class AMPViewType { |
| 30 NONE, | 33 NONE, |
| 31 AMP_CACHE, | 34 AMP_CACHE, |
| 32 GOOGLE_SEARCH_AMP_VIEWER, | 35 GOOGLE_SEARCH_AMP_VIEWER, |
| 33 GOOGLE_NEWS_AMP_VIEWER, | 36 GOOGLE_NEWS_AMP_VIEWER, |
| 37 |
| 38 // New values should be added before this final entry. |
| 39 AMP_VIEW_TYPE_LAST |
| 34 }; | 40 }; |
| 35 | 41 |
| 36 static AMPViewType GetAMPViewType(const GURL& url); | 42 static AMPViewType GetAMPViewType(const GURL& url); |
| 37 | 43 |
| 38 AMPPageLoadMetricsObserver(); | 44 AMPPageLoadMetricsObserver(); |
| 39 ~AMPPageLoadMetricsObserver() override; | 45 ~AMPPageLoadMetricsObserver() override; |
| 40 | 46 |
| 41 // page_load_metrics::PageLoadMetricsObserver: | 47 // page_load_metrics::PageLoadMetricsObserver: |
| 42 ObservePolicy OnCommit(content::NavigationHandle* navigation_handle) override; | 48 ObservePolicy OnCommit(content::NavigationHandle* navigation_handle) override; |
| 49 void OnCommitSameDocumentNavigation( |
| 50 content::NavigationHandle* navigation_handle) override; |
| 43 void OnDomContentLoadedEventStart( | 51 void OnDomContentLoadedEventStart( |
| 44 const page_load_metrics::PageLoadTiming& timing, | 52 const page_load_metrics::PageLoadTiming& timing, |
| 45 const page_load_metrics::PageLoadExtraInfo& info) override; | 53 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 46 void OnLoadEventStart( | 54 void OnLoadEventStart( |
| 47 const page_load_metrics::PageLoadTiming& timing, | 55 const page_load_metrics::PageLoadTiming& timing, |
| 48 const page_load_metrics::PageLoadExtraInfo& info) override; | 56 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 49 void OnFirstLayout(const page_load_metrics::PageLoadTiming& timing, | 57 void OnFirstLayout(const page_load_metrics::PageLoadTiming& timing, |
| 50 const page_load_metrics::PageLoadExtraInfo& info) override; | 58 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 51 void OnFirstContentfulPaintInPage( | 59 void OnFirstContentfulPaintInPage( |
| 52 const page_load_metrics::PageLoadTiming& timing, | 60 const page_load_metrics::PageLoadTiming& timing, |
| 53 const page_load_metrics::PageLoadExtraInfo& info) override; | 61 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 54 void OnParseStart(const page_load_metrics::PageLoadTiming& timing, | 62 void OnParseStart(const page_load_metrics::PageLoadTiming& timing, |
| 55 const page_load_metrics::PageLoadExtraInfo& info) override; | 63 const page_load_metrics::PageLoadExtraInfo& info) override; |
| 56 | 64 |
| 57 private: | 65 private: |
| 66 GURL current_url_; |
| 58 AMPViewType view_type_ = AMPViewType::NONE; | 67 AMPViewType view_type_ = AMPViewType::NONE; |
| 59 | 68 |
| 60 DISALLOW_COPY_AND_ASSIGN(AMPPageLoadMetricsObserver); | 69 DISALLOW_COPY_AND_ASSIGN(AMPPageLoadMetricsObserver); |
| 61 }; | 70 }; |
| 62 | 71 |
| 63 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_AMP_PAGE_LOAD_METRICS_OBSE
RVER_H_ | 72 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_AMP_PAGE_LOAD_METRICS_OBSE
RVER_H_ |
| OLD | NEW |