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

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

Issue 2761353002: Fixing reporting of AMP page load information (Closed)
Patch Set: changed re-verrsioning to AMPCache2 Created 3 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/observers/amp_page_load_metrics_observer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/page_load_metrics/observers/amp_page_load_metrics_obser ver.h" 5 #include "chrome/browser/page_load_metrics/observers/amp_page_load_metrics_obser ver.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/optional.h" 9 #include "base/optional.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h" 12 #include "chrome/browser/page_load_metrics/page_load_metrics_util.h"
13 #include "chrome/common/page_load_metrics/page_load_timing.h" 13 #include "chrome/common/page_load_metrics/page_load_timing.h"
14 #include "components/google/core/browser/google_util.h" 14 #include "components/google/core/browser/google_util.h"
15 #include "content/public/browser/navigation_handle.h" 15 #include "content/public/browser/navigation_handle.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace { 18 namespace {
19 19
20 const char kHistogramAMPDOMContentLoadedEventFired[] = 20 const char kHistogramAMPDOMContentLoadedEventFired[] =
21 "PageLoad.Clients.AMPCache.DocumentTiming." 21 "PageLoad.Clients.AMPCache2.DocumentTiming."
22 "NavigationToDOMContentLoadedEventFired"; 22 "NavigationToDOMContentLoadedEventFired";
23 const char kHistogramAMPFirstLayout[] = 23 const char kHistogramAMPFirstLayout[] =
24 "PageLoad.Clients.AMPCache.DocumentTiming.NavigationToFirstLayout"; 24 "PageLoad.Clients.AMPCache2.DocumentTiming.NavigationToFirstLayout";
25 const char kHistogramAMPLoadEventFired[] = 25 const char kHistogramAMPLoadEventFired[] =
26 "PageLoad.Clients.AMPCache.DocumentTiming.NavigationToLoadEventFired"; 26 "PageLoad.Clients.AMPCache2.DocumentTiming.NavigationToLoadEventFired";
27 const char kHistogramAMPFirstContentfulPaint[] = 27 const char kHistogramAMPFirstContentfulPaint[] =
28 "PageLoad.Clients.AMPCache.PaintTiming.NavigationToFirstContentfulPaint"; 28 "PageLoad.Clients.AMPCache2.PaintTiming."
29 "NavigationToFirstContentfulPaint";
29 const char kHistogramAMPParseStart[] = 30 const char kHistogramAMPParseStart[] =
30 "PageLoad.Clients.AMPCache.ParseTiming.NavigationToParseStart"; 31 "PageLoad.Clients.AMPCache2.ParseTiming.NavigationToParseStart";
31 32
32 // Host pattern for AMP Cache URLs. 33 // Host pattern for AMP Cache URLs.
33 // See https://developers.google.com/amp/cache/overview#amp-cache-url-format 34 // See https://developers.google.com/amp/cache/overview#amp-cache-url-format
34 // for a definition of the format of AMP Cache URLs. 35 // for a definition of the format of AMP Cache URLs.
35 const char kAmpCacheHost[] = "cdn.ampproject.org"; 36 const char kAmpCacheHost[] = "cdn.ampproject.org";
36 37
37 // Pattern for the path of Google AMP Viewer URLs. 38 // Pattern for the path of Google AMP Viewer URLs.
38 const char kGoogleAmpViewerPathPattern[] = "/amp/"; 39 const char kGoogleAmpViewerPathPattern[] = "/amp/";
39 40
40 bool IsAMPCacheURL(const GURL& url) { 41 bool IsAMPCacheURL(const GURL& url) {
(...skipping 25 matching lines...) Expand all
66 timing.dom_content_loaded_event_start, info)) { 67 timing.dom_content_loaded_event_start, info)) {
67 return; 68 return;
68 } 69 }
69 PAGE_LOAD_HISTOGRAM(kHistogramAMPDOMContentLoadedEventFired, 70 PAGE_LOAD_HISTOGRAM(kHistogramAMPDOMContentLoadedEventFired,
70 timing.dom_content_loaded_event_start.value()); 71 timing.dom_content_loaded_event_start.value());
71 } 72 }
72 73
73 void AMPPageLoadMetricsObserver::OnLoadEventStart( 74 void AMPPageLoadMetricsObserver::OnLoadEventStart(
74 const page_load_metrics::PageLoadTiming& timing, 75 const page_load_metrics::PageLoadTiming& timing,
75 const page_load_metrics::PageLoadExtraInfo& info) { 76 const page_load_metrics::PageLoadExtraInfo& info) {
76 if (!WasStartedInForegroundOptionalEventInForeground( 77 if (!WasStartedInForegroundOptionalEventInForeground(timing.load_event_start,
77 timing.dom_content_loaded_event_start, info)) { 78 info)) {
78 return; 79 return;
79 } 80 }
80 PAGE_LOAD_HISTOGRAM(kHistogramAMPLoadEventFired, 81 PAGE_LOAD_HISTOGRAM(kHistogramAMPLoadEventFired,
81 timing.load_event_start.value()); 82 timing.load_event_start.value());
82 } 83 }
83 84
84 void AMPPageLoadMetricsObserver::OnFirstLayout( 85 void AMPPageLoadMetricsObserver::OnFirstLayout(
85 const page_load_metrics::PageLoadTiming& timing, 86 const page_load_metrics::PageLoadTiming& timing,
86 const page_load_metrics::PageLoadExtraInfo& info) { 87 const page_load_metrics::PageLoadExtraInfo& info) {
87 if (!WasStartedInForegroundOptionalEventInForeground( 88 if (!WasStartedInForegroundOptionalEventInForeground(timing.first_layout,
88 timing.dom_content_loaded_event_start, info)) { 89 info)) {
89 return; 90 return;
90 } 91 }
91 PAGE_LOAD_HISTOGRAM(kHistogramAMPFirstLayout, timing.first_layout.value()); 92 PAGE_LOAD_HISTOGRAM(kHistogramAMPFirstLayout, timing.first_layout.value());
92 } 93 }
93 94
94 void AMPPageLoadMetricsObserver::OnFirstContentfulPaint( 95 void AMPPageLoadMetricsObserver::OnFirstContentfulPaint(
95 const page_load_metrics::PageLoadTiming& timing, 96 const page_load_metrics::PageLoadTiming& timing,
96 const page_load_metrics::PageLoadExtraInfo& info) { 97 const page_load_metrics::PageLoadExtraInfo& info) {
97 if (!WasStartedInForegroundOptionalEventInForeground( 98 if (!WasStartedInForegroundOptionalEventInForeground(
98 timing.dom_content_loaded_event_start, info)) { 99 timing.first_contentful_paint, info)) {
99 return; 100 return;
100 } 101 }
101 PAGE_LOAD_HISTOGRAM(kHistogramAMPFirstContentfulPaint, 102 PAGE_LOAD_HISTOGRAM(kHistogramAMPFirstContentfulPaint,
102 timing.first_contentful_paint.value()); 103 timing.first_contentful_paint.value());
103 } 104 }
104 105
105 void AMPPageLoadMetricsObserver::OnParseStart( 106 void AMPPageLoadMetricsObserver::OnParseStart(
106 const page_load_metrics::PageLoadTiming& timing, 107 const page_load_metrics::PageLoadTiming& timing,
107 const page_load_metrics::PageLoadExtraInfo& info) { 108 const page_load_metrics::PageLoadExtraInfo& info) {
108 if (!WasStartedInForegroundOptionalEventInForeground( 109 if (!WasStartedInForegroundOptionalEventInForeground(timing.parse_start,
109 timing.dom_content_loaded_event_start, info)) { 110 info)) {
110 return; 111 return;
111 } 112 }
112 PAGE_LOAD_HISTOGRAM(kHistogramAMPParseStart, timing.parse_start.value()); 113 PAGE_LOAD_HISTOGRAM(kHistogramAMPParseStart, timing.parse_start.value());
113 } 114 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/observers/amp_page_load_metrics_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698