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 { |
| 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 private: |
| 33 FirstWebContentsProfiler(content::WebContents* web_contents, |
| 34 FirstWebContentsProfilerDelegate* delegate); |
| 35 |
| 36 // WebContentsObserver overrides. |
| 37 void DidFirstVisuallyNonEmptyPaint() override; |
| 38 void DocumentOnLoadCompletedInMainFrame() override; |
| 39 void WebContentsDestroyed() override; |
| 40 |
| 41 // Whether this instance has finished collecting all of its metrics. |
| 42 bool IsFinishedCollectingMetrics(); |
| 43 |
| 44 // Informs the delegate that this instance has finished collecting all of its |
| 45 // metrics. |
| 46 void FinishedCollectingMetrics(); |
| 47 |
| 48 // Whether the "NonEmptyPaint" metric has been collected. |
| 49 bool collected_paint_metric_; |
| 50 |
| 51 // Whether the "MainFrameLoad" metric has been collected. |
| 52 bool collected_load_metric_; |
| 53 |
| 54 // |delegate_| owns |this|. |
| 55 FirstWebContentsProfilerDelegate* delegate_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler); |
| 58 }; |
| 59 |
| 60 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ |
OLD | NEW |