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

Unified Diff: chrome/browser/page_load_metrics/observers/protocol_page_load_metrics_observer.cc

Issue 2457583007: [PageLoadMetrics] Create page load timing metrics for H2/QUIC/H1 pages (Closed)
Patch Set: Fix test Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/page_load_metrics/observers/protocol_page_load_metrics_observer.cc
diff --git a/chrome/browser/page_load_metrics/observers/protocol_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/protocol_page_load_metrics_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..274a5638340ee77bfd3c1f9b3c3fb11563c9d1bf
--- /dev/null
+++ b/chrome/browser/page_load_metrics/observers/protocol_page_load_metrics_observer.cc
@@ -0,0 +1,150 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/page_load_metrics/observers/protocol_page_load_metrics_observer.h"
+
+#include "chrome/browser/page_load_metrics/page_load_metrics_util.h"
+
+page_load_metrics::PageLoadMetricsObserver::ObservePolicy
+ProtocolPageLoadMetricsObserver::OnCommit(
+ content::NavigationHandle* navigation_handle) {
+ connection_info_ = navigation_handle->GetConnectionInfo();
+ return CONTINUE_OBSERVING;
+}
+
+void ProtocolPageLoadMetricsObserver::OnFirstContentfulPaint(
+ const page_load_metrics::PageLoadTiming& timing,
+ const page_load_metrics::PageLoadExtraInfo& extra_info) {
+ switch (connection_info_) {
+ case net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_SPDY2:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_SPDY3:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_HTTP2_14:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_HTTP2_15:
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP0_9:
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP1_0:
+ case net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS:
+ return;
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP1_1:
Charlie Harrison 2016/10/31 15:27:17 Did you consider merging 1.1 and 1.0 traffic?
jkarlin 2016/10/31 16:50:06 There are substantial differences between 1.1 and
Bryan McQuade 2016/11/05 00:24:02 If we're only going to log 1.1 I think we should r
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.H1.PaintTiming."
+ "ParseStartToFirstContentfulPaint",
+ timing.first_contentful_paint.value() - timing.parse_start.value());
+ break;
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP2:
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.H2.PaintTiming."
+ "ParseStartToFirstContentfulPaint",
+ timing.first_contentful_paint.value() - timing.parse_start.value());
+ break;
+ case net::HttpResponseInfo::CONNECTION_INFO_QUIC:
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.QUIC.PaintTiming."
+ "ParseStartToFirstContentfulPaint",
+ timing.first_contentful_paint.value() - timing.parse_start.value());
+ break;
+ }
+}
+
+void ProtocolPageLoadMetricsObserver::OnFirstMeaningfulPaint(
+ const page_load_metrics::PageLoadTiming& timing,
+ const page_load_metrics::PageLoadExtraInfo& extra_info) {
+ switch (connection_info_) {
+ case net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_SPDY2:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_SPDY3:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_HTTP2_14:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_HTTP2_15:
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP0_9:
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP1_0:
+ case net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS:
+ return;
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP1_1:
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.H1.Experimental.PaintTiming."
+ "ParseStartToFirstMeaningfulPaint",
+ timing.first_meaningful_paint.value() - timing.parse_start.value());
+ break;
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP2:
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.H2.Experimental.PaintTiming."
+ "ParseStartToFirstMeaningfulPaint",
+ timing.first_meaningful_paint.value() - timing.parse_start.value());
+ break;
+ case net::HttpResponseInfo::CONNECTION_INFO_QUIC:
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.QUIC.Experimental.PaintTiming."
+ "ParseStartToFirstMeaningfulPaint",
+ timing.first_meaningful_paint.value() - timing.parse_start.value());
+ break;
+ }
+}
+
+void ProtocolPageLoadMetricsObserver::OnDomContentLoadedEventStart(
+ const page_load_metrics::PageLoadTiming& timing,
+ const page_load_metrics::PageLoadExtraInfo& extra_info) {
+ switch (connection_info_) {
+ case net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_SPDY2:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_SPDY3:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_HTTP2_14:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_HTTP2_15:
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP0_9:
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP1_0:
+ case net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS:
+ return;
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP1_1:
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.H1.DocumentTiming."
+ "NavigationToDOMContentLoadedEventFired",
+ timing.dom_content_loaded_event_start.value());
+ break;
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP2:
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.H2.DocumentTiming."
+ "NavigationToDOMContentLoadedEventFired",
+ timing.dom_content_loaded_event_start.value());
+ break;
+ case net::HttpResponseInfo::CONNECTION_INFO_QUIC:
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.QUIC.DocumentTiming."
+ "NavigationToDOMContentLoadedEventFired",
+ timing.dom_content_loaded_event_start.value());
+ break;
+ }
+}
+
+void ProtocolPageLoadMetricsObserver::OnLoadEventStart(
+ const page_load_metrics::PageLoadTiming& timing,
+ const page_load_metrics::PageLoadExtraInfo& extra_info) {
+ switch (connection_info_) {
+ case net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_SPDY2:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_SPDY3:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_HTTP2_14:
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_HTTP2_15:
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP0_9:
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP1_0:
+ case net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS:
+ return;
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP1_1:
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.H1.DocumentTiming."
+ "NavigationToLoadEventFired",
+ timing.load_event_start.value());
+ break;
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP2:
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.H2.DocumentTiming."
+ "NavigationToLoadEventFired",
+ timing.load_event_start.value());
+ break;
+ case net::HttpResponseInfo::CONNECTION_INFO_QUIC:
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Clients.Protocol.QUIC.DocumentTiming."
+ "NavigationToLoadEventFired",
+ timing.load_event_start.value());
+ break;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698