Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_ | |
| OLD | NEW |