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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_
6 #define CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "content/public/browser/web_contents_observer.h"
10
11 namespace content {
12 class WebContents;
13 } // namespace content
14
15 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.
16 public:
17 // Called by the FirstWebContentsProfiler when it is finished collecting
18 // metrics. The delegate should take this opportunity to destroy the
19 // FirstWebContentsProfiler.
20 virtual void ProfilerFinishedCollectingMetrics() = 0;
21 };
22
23 // Measures start up performance of the first active web contents.
24 class FirstWebContentsProfiler : public content::WebContentsObserver {
25 public:
26 // Creates a profiler for the active web contents. If there are multiple
27 // browsers, the first one is chosen. If there are no browsers, returns
28 // nullptr.
29 static scoped_ptr<FirstWebContentsProfiler> CreateProfilerForFirstWebContents(
30 FirstWebContentsProfilerDelegate* delegate);
31
32 // These metrics are currently experimental, and are only collected in the
33 // dev and canary channels.
34 static bool ShouldCollectMetrics();
35
36 private:
37 FirstWebContentsProfiler(content::WebContents* web_contents,
38 FirstWebContentsProfilerDelegate* delegate);
39
40 // 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
41 void DidFirstVisuallyNonEmptyPaint() override;
42 void DocumentOnLoadCompletedInMainFrame() override;
43 void WebContentsDestroyed() override;
44
45 // Whether this instance has finished collecting all of its metrics.
46 bool IsFinishedCollectingMetrics();
47
48 // Informs the delegate that this instance has finished collecting all of its
49 // metrics.
50 void FinishedCollectingMetrics();
51
52 // Whether the "NonEmptyPaint" metric has been collected.
53 bool collected_paint_metric_;
54
55 // Whether the "MainFrameLoad" metric has been collected.
56 bool collected_load_metric_;
57
58 // |delegate_| owns |this|.
59 FirstWebContentsProfilerDelegate* delegate_;
60
61 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler);
62 };
63
64 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698