Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: chrome/browser/page_load_metrics/observers/amp_page_load_metrics_observer.h

Issue 2888673002: Add support for counting same-document AMP loads. (Closed)
Patch Set: rebase, and small updates Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 enum class AMPViewType { 29 enum class AMPViewType {
Ilya Sherman 2017/05/17 19:26:43 Please document that this enum is used to back an
Bryan McQuade 2017/05/17 22:29:37 Done, thanks!
30 NONE, 30 NONE,
31 AMP_CACHE, 31 AMP_CACHE,
32 GOOGLE_SEARCH_AMP_VIEWER, 32 GOOGLE_SEARCH_AMP_VIEWER,
33 GOOGLE_NEWS_AMP_VIEWER, 33 GOOGLE_NEWS_AMP_VIEWER,
34
35 // New values should be added before this final entry.
36 AMP_VIEW_TYPE_LAST
34 }; 37 };
35 38
36 static AMPViewType GetAMPViewType(const GURL& url); 39 static AMPViewType GetAMPViewType(const GURL& url);
37 40
38 AMPPageLoadMetricsObserver(); 41 AMPPageLoadMetricsObserver();
39 ~AMPPageLoadMetricsObserver() override; 42 ~AMPPageLoadMetricsObserver() override;
40 43
41 // page_load_metrics::PageLoadMetricsObserver: 44 // page_load_metrics::PageLoadMetricsObserver:
42 ObservePolicy OnCommit(content::NavigationHandle* navigation_handle) override; 45 ObservePolicy OnCommit(content::NavigationHandle* navigation_handle) override;
46 void OnCommitSameDocumentNavigation(
47 content::NavigationHandle* navigation_handle) override;
43 void OnDomContentLoadedEventStart( 48 void OnDomContentLoadedEventStart(
44 const page_load_metrics::PageLoadTiming& timing, 49 const page_load_metrics::PageLoadTiming& timing,
45 const page_load_metrics::PageLoadExtraInfo& info) override; 50 const page_load_metrics::PageLoadExtraInfo& info) override;
46 void OnLoadEventStart( 51 void OnLoadEventStart(
47 const page_load_metrics::PageLoadTiming& timing, 52 const page_load_metrics::PageLoadTiming& timing,
48 const page_load_metrics::PageLoadExtraInfo& info) override; 53 const page_load_metrics::PageLoadExtraInfo& info) override;
49 void OnFirstLayout(const page_load_metrics::PageLoadTiming& timing, 54 void OnFirstLayout(const page_load_metrics::PageLoadTiming& timing,
50 const page_load_metrics::PageLoadExtraInfo& info) override; 55 const page_load_metrics::PageLoadExtraInfo& info) override;
51 void OnFirstContentfulPaintInPage( 56 void OnFirstContentfulPaintInPage(
52 const page_load_metrics::PageLoadTiming& timing, 57 const page_load_metrics::PageLoadTiming& timing,
53 const page_load_metrics::PageLoadExtraInfo& info) override; 58 const page_load_metrics::PageLoadExtraInfo& info) override;
54 void OnParseStart(const page_load_metrics::PageLoadTiming& timing, 59 void OnParseStart(const page_load_metrics::PageLoadTiming& timing,
55 const page_load_metrics::PageLoadExtraInfo& info) override; 60 const page_load_metrics::PageLoadExtraInfo& info) override;
56 61
57 private: 62 private:
63 GURL current_url_;
58 AMPViewType view_type_ = AMPViewType::NONE; 64 AMPViewType view_type_ = AMPViewType::NONE;
59 65
60 DISALLOW_COPY_AND_ASSIGN(AMPPageLoadMetricsObserver); 66 DISALLOW_COPY_AND_ASSIGN(AMPPageLoadMetricsObserver);
61 }; 67 };
62 68
63 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_AMP_PAGE_LOAD_METRICS_OBSE RVER_H_ 69 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_AMP_PAGE_LOAD_METRICS_OBSE RVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698