| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ |
| 6 #define CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ | 6 #define CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 class WebContents; | 14 class WebContents; |
| 15 } // namespace content | 15 } // namespace content |
| 16 | 16 |
| 17 // Measures start up performance of the first active web contents. | 17 // Measures start up performance of the first active web contents. |
| 18 // This class is declared on all platforms, but only defined on non-Android | 18 // This class is declared on all platforms, but only defined on non-Android |
| 19 // platforms. Android code should not call any non-trivial methods on this | 19 // platforms. Android code should not call any non-trivial methods on this |
| 20 // class. | 20 // class. |
| 21 class FirstWebContentsProfiler : public content::WebContentsObserver { | 21 class FirstWebContentsProfiler : public content::WebContentsObserver { |
| 22 public: | 22 public: |
| 23 // Creates a profiler for the active web contents. If there are multiple | 23 // Creates a profiler for the active web contents. If there are multiple |
| 24 // browsers, the first one is chosen. The resulting FirstWebContentsProfiler | 24 // browsers, the first one is chosen. The resulting FirstWebContentsProfiler |
| 25 // owns itself. | 25 // owns itself. |
| 26 static void WebContentsStarted(content::WebContents* web_contents); | 26 static void Start(); |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 // Reasons for which profiling is deemed complete. Logged in UMA (do not re- | 29 // Reasons for which profiling is deemed complete. Logged in UMA (do not re- |
| 30 // order or re-assign). | 30 // order or re-assign). |
| 31 enum FinishReason { | 31 enum FinishReason { |
| 32 // All metrics were successfully gathered. | 32 // All metrics were successfully gathered. |
| 33 DONE = 0, | 33 DONE = 0, |
| 34 // Abandon if blocking UI was shown during startup. | 34 // Abandon if blocking UI was shown during startup. |
| 35 ABANDON_BLOCKING_UI = 1, | 35 ABANDON_BLOCKING_UI = 1, |
| 36 // Abandon if the content is hidden (lowers scheduling priority). | 36 // Abandon if the content is hidden (lowers scheduling priority). |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // Whether an attempt was made to collect the "MainNavigationStart" metric. | 73 // Whether an attempt was made to collect the "MainNavigationStart" metric. |
| 74 bool collected_main_navigation_start_metric_; | 74 bool collected_main_navigation_start_metric_; |
| 75 | 75 |
| 76 // Whether an attempt was made to collect the "MainNavigationFinished" metric. | 76 // Whether an attempt was made to collect the "MainNavigationFinished" metric. |
| 77 bool collected_main_navigation_finished_metric_; | 77 bool collected_main_navigation_finished_metric_; |
| 78 | 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler); | 79 DISALLOW_COPY_AND_ASSIGN(FirstWebContentsProfiler); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ | 82 #endif // CHROME_BROWSER_METRICS_FIRST_WEB_CONTENTS_PROFILER_H_ |
| OLD | NEW |