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

Unified Diff: chrome/browser/metrics/first_web_contents_profiler.h

Issue 760763002: Add startup metrics that measure the performance of the first web contents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from asvitkine, rkaplow. Created 6 years 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/first_web_contents_profiler.h
diff --git a/chrome/browser/metrics/first_web_contents_profiler.h b/chrome/browser/metrics/first_web_contents_profiler.h
new file mode 100644
index 0000000000000000000000000000000000000000..c1aa331c368b1368fbe65e9fa9d98c0eb8b8a072
--- /dev/null
+++ b/chrome/browser/metrics/first_web_contents_profiler.h
@@ -0,0 +1,64 @@
+// Copyright 2014 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.
+
+#ifndef CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_
+#define CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "content/public/browser/web_contents_observer.h"
+
+namespace content {
+class WebContents;
+} // namespace content
+
+class FirstWebContentsProfilerDelegate {
Alexei Svitkine (slow) 2014/12/03 20:05:57 Nit: Any reason to not just nest it under FirstWeb
erikchen 2014/12/03 21:38:41 sounds reasonable to me.
+ public:
+ // Called by the FirstWebContentsProfiler when it is finished collecting
+ // metrics. The delegate should take this opportunity to destroy the
+ // FirstWebContentsProfiler.
+ virtual void ProfilerFinishedCollectingMetrics() = 0;
+};
+
+// Measures start up performance of the first active web contents.
+class FirstWebContentsProfiler : public content::WebContentsObserver {
+ public:
+ // Creates a profiler for the active web contents. If there are multiple
+ // browsers, the first one is chosen. If there are no browsers, returns
+ // nullptr.
+ static scoped_ptr<FirstWebContentsProfiler> CreateProfilerForFirstWebContents(
+ FirstWebContentsProfilerDelegate* delegate);
+
+ // These metrics are currently experimental, and are only collected in the
+ // dev and canary channels.
+ static bool ShouldCollectMetrics();
+
+ private:
+ FirstWebContentsProfiler(content::WebContents* web_contents,
+ FirstWebContentsProfilerDelegate* delegate);
+
+ // WebContentsObserver overrides.
Alexei Svitkine (slow) 2014/12/03 20:05:57 Nit: I think for new code, the preferred notation
erikchen 2014/12/03 21:38:41 sure, done. I kept the old style for chrome/browse
+ void DidFirstVisuallyNonEmptyPaint() override;
+ void DocumentOnLoadCompletedInMainFrame() override;
+ void WebContentsDestroyed() override;
+
+ // Whether this instance has finished collecting all of its metrics.
+ bool IsFinishedCollectingMetrics();
+
+ // Informs the delegate that this instance has finished collecting all of its
+ // metrics.
+ void FinishedCollectingMetrics();
+
+ // Whether the "NonEmptyPaint" metric has been collected.
+ bool collected_paint_metric_;
+
+ // Whether the "MainFrameLoad" metric has been collected.
+ bool collected_load_metric_;
+
+ // |delegate_| owns |this|.
+ FirstWebContentsProfilerDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler);
+};
+
+#endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_

Powered by Google App Engine
This is Rietveld 408576698