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

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

Issue 2930013005: [Tab Metrics] Measure FP, FCP and FMP for Foreground Tab during Session Restore (Closed)
Patch Set: Created 3 years, 6 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/session_restore_foreground_tab_page_load_metrics_observer.cc
diff --git a/chrome/browser/page_load_metrics/observers/session_restore_foreground_tab_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/session_restore_foreground_tab_page_load_metrics_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ef26f331ccc9b1e267537434dff601d158968930
--- /dev/null
+++ b/chrome/browser/page_load_metrics/observers/session_restore_foreground_tab_page_load_metrics_observer.cc
@@ -0,0 +1,72 @@
+// Copyright 2017 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/session_restore_foreground_tab_page_load_metrics_observer.h"
+
+#include "base/metrics/histogram_macros.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/resource_coordinator/tab_manager.h"
+
+namespace internal {
+
+const char kHistogramSessionRestoreForegroundTabFirstPaint[] =
+ "TabManager.Experimental.SessionRestore.ForegroundTab.FirstPaint";
+const char kHistogramSessionRestoreForegroundTabFirstContentfulPaint[] =
+ "TabManager.Experimental.SessionRestore.ForegroundTab.FirstContentfulPaint";
+const char kHistogramSessionRestoreForegroundTabFirstMeaningfulPaint[] =
+ "TabManager.Experimental.SessionRestore.ForegroundTab.FirstMeaningfulPaint";
+
+} // namespace internal
+
+page_load_metrics::PageLoadMetricsObserver::ObservePolicy
+SessionRestoreForegroundTabPageLoadMetricsObserver::OnStart(
+ content::NavigationHandle* navigation_handle,
+ const GURL& currently_committed_url,
+ bool started_in_foreground) {
+ return (!IsDuringSessionRestore() || !started_in_foreground)
+ ? STOP_OBSERVING
+ : CONTINUE_OBSERVING;
+}
+
+page_load_metrics::PageLoadMetricsObserver::ObservePolicy
+SessionRestoreForegroundTabPageLoadMetricsObserver::OnHidden(
+ const page_load_metrics::mojom::PageLoadTiming& timing,
+ const page_load_metrics::PageLoadExtraInfo& info) {
+ return STOP_OBSERVING;
+}
+
+void SessionRestoreForegroundTabPageLoadMetricsObserver::OnFirstPaintInPage(
+ const page_load_metrics::mojom::PageLoadTiming& timing,
+ const page_load_metrics::PageLoadExtraInfo& extra_info) {
+ UMA_HISTOGRAM_TIMES(internal::kHistogramSessionRestoreForegroundTabFirstPaint,
+ timing.paint_timing->first_paint.value());
+}
+
+void SessionRestoreForegroundTabPageLoadMetricsObserver::
+ OnFirstContentfulPaintInPage(
+ const page_load_metrics::mojom::PageLoadTiming& timing,
+ const page_load_metrics::PageLoadExtraInfo& extra_info) {
+ UMA_HISTOGRAM_TIMES(
+ internal::kHistogramSessionRestoreForegroundTabFirstContentfulPaint,
+ timing.paint_timing->first_contentful_paint.value());
+}
+
+void SessionRestoreForegroundTabPageLoadMetricsObserver::
+ OnFirstMeaningfulPaintInMainFrameDocument(
+ const page_load_metrics::mojom::PageLoadTiming& timing,
+ const page_load_metrics::PageLoadExtraInfo& extra_info) {
+ UMA_HISTOGRAM_TIMES(
+ internal::kHistogramSessionRestoreForegroundTabFirstMeaningfulPaint,
+ timing.paint_timing->first_meaningful_paint.value());
+}
+
+bool SessionRestoreForegroundTabPageLoadMetricsObserver::
+ IsDuringSessionRestore() const {
+ resource_coordinator::TabManager* tab_manager =
+ g_browser_process->GetTabManager();
+ if (tab_manager)
fmeawad 2017/06/09 21:22:27 Are we expecting to always have a tab_manager, if
ducbui 2017/06/10 00:40:16 I think the check is necessary because the tab_man
fmeawad 2017/06/12 14:56:40 I see, then maybe exclude this code on non-support
+ return tab_manager->IsDuringSessionRestore();
+
+ return false;
+}

Powered by Google App Engine
This is Rietveld 408576698