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

Unified Diff: chrome/browser/metrics/browser_window_histogram_helper.cc

Issue 2773973002: Add Startup.BrowserView.FirstPaint / .CompositingEnded histograms. (Closed)
Patch Set: BrowserView --> BrowserWindow, use factory method for class creation. Created 3 years, 8 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/metrics/browser_window_histogram_helper.cc
diff --git a/chrome/browser/metrics/browser_window_histogram_helper.cc b/chrome/browser/metrics/browser_window_histogram_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..18a762b6b68fb71ccb8ef0e1555dedbcc670455b
--- /dev/null
+++ b/chrome/browser/metrics/browser_window_histogram_helper.cc
@@ -0,0 +1,57 @@
+// 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/metrics/browser_window_histogram_helper.h"
+
+#include "components/startup_metric_utils/browser/startup_metric_utils.h"
+#include "ui/compositor/compositor.h"
+
+BrowserWindowHistogramHelper::BrowserWindowHistogramHelper(
+ ui::Compositor* compositor)
+ : scoped_observer_(this) {
+ startup_metric_utils::RecordBrowserWindowFirstPaint(base::TimeTicks::Now());
+
+#if defined(OS_MACOSX)
+ if (!compositor) {
+ // In Cocoa version of Chromium UI is rendered inside the main process using
Alexei Svitkine (slow) 2017/04/18 16:01:31 Nit: Add a , after Chromium
themblsha 2017/04/19 15:06:09 Done.
+ // CoreAnimation compositor, and at this point everything is already visible
+ // to the user.
+ startup_metric_utils::RecordBrowserWindowFirstPaintCompositingEnded(
+ base::TimeTicks::Now());
+ return;
+ }
+#endif // OS_MACOSX
+
+ scoped_observer_.Add(compositor);
+}
+
+BrowserWindowHistogramHelper::~BrowserWindowHistogramHelper() {}
+
+// static
+std::unique_ptr<BrowserWindowHistogramHelper>
+BrowserWindowHistogramHelper::OnBrowserPainted(ui::Compositor* compositor) {
Alexei Svitkine (slow) 2017/04/18 16:01:31 Can this be named in some way that makes it clear
themblsha 2017/04/19 15:06:09 Done.
+ static bool did_first_paint = false;
+ if (did_first_paint)
+ return std::unique_ptr<BrowserWindowHistogramHelper>();
+
+ did_first_paint = true;
+
+ return std::unique_ptr<BrowserWindowHistogramHelper>(
Alexei Svitkine (slow) 2017/04/18 16:01:32 Nit: MakeUnique
themblsha 2017/04/19 15:06:09 I was unable to make it work with private construc
+ new BrowserWindowHistogramHelper(compositor));
+}
+
+// OnCompositingEnded was removed crbug.com/671202, this is the next best thing.
+void BrowserWindowHistogramHelper::OnCompositingStarted(
+ ui::Compositor* compositor,
+ base::TimeTicks start_time) {
+ startup_metric_utils::RecordBrowserWindowFirstPaintCompositingEnded(
+ base::TimeTicks::Now());
+
+ scoped_observer_.RemoveAll();
+}
+
+void BrowserWindowHistogramHelper::OnCompositingShuttingDown(
+ ui::Compositor* compositor) {
+ scoped_observer_.RemoveAll();
+}

Powered by Google App Engine
This is Rietveld 408576698