| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ | 5 #ifndef COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ |
| 6 #define COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ | 6 #define COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ |
| 7 | 7 |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 | 9 |
| 10 class PrefRegistrySimple; | 10 class PrefRegistrySimple; |
| 11 class PrefService; | 11 class PrefService; |
| 12 | 12 |
| 13 // Utility functions to support metric collection for browser startup. Timings | 13 // Utility functions to support metric collection for browser startup. Timings |
| 14 // should use TimeTicks whenever possible. OS-provided timings are still | 14 // should use TimeTicks whenever possible. OS-provided timings are still |
| 15 // received as Time out of cross-platform support necessity but are converted to | 15 // received as Time out of cross-platform support necessity but are converted to |
| 16 // TimeTicks as soon as possible in an attempt to reduce the potential skew | 16 // TimeTicks as soon as possible in an attempt to reduce the potential skew |
| 17 // between the two basis. See crbug.com/544131 for reasoning. | 17 // between the two basis. See crbug.com/544131 for reasoning. |
| 18 | 18 |
| 19 namespace startup_metric_utils { | 19 namespace startup_metric_utils { |
| 20 | 20 |
| 21 // Identifies the workload of profiled WebContents, used to refine startup |
| 22 // metrics. |
| 23 enum class WebContentsWorkload { |
| 24 // Only loading a single tab. |
| 25 SINGLE_TAB, |
| 26 // Loading multiple tabs (of which the profiled WebContents is foreground). |
| 27 MULTI_TABS, |
| 28 }; |
| 29 |
| 21 // Registers startup related prefs in |registry|. | 30 // Registers startup related prefs in |registry|. |
| 22 void RegisterPrefs(PrefRegistrySimple* registry); | 31 void RegisterPrefs(PrefRegistrySimple* registry); |
| 23 | 32 |
| 24 // Returns true if any UI other than the browser window has been displayed | 33 // Returns true if any UI other than the browser window has been displayed |
| 25 // so far. Useful to test if UI has been displayed before the first browser | 34 // so far. Useful to test if UI has been displayed before the first browser |
| 26 // window was shown, which would invalidate any surrounding timing metrics. | 35 // window was shown, which would invalidate any surrounding timing metrics. |
| 27 bool WasNonBrowserUIDisplayed(); | 36 bool WasNonBrowserUIDisplayed(); |
| 28 | 37 |
| 29 // Call this when displaying UI that might potentially delay startup events. | 38 // Call this when displaying UI that might potentially delay startup events. |
| 30 // | 39 // |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 77 |
| 69 // Call this with the time when the first web contents loaded its main frame, | 78 // Call this with the time when the first web contents loaded its main frame, |
| 70 // only if the first web contents was unimpended in its attempt to do so. | 79 // only if the first web contents was unimpended in its attempt to do so. |
| 71 void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks); | 80 void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks); |
| 72 | 81 |
| 73 // Call this with the time when the first web contents had a non-empty paint, | 82 // Call this with the time when the first web contents had a non-empty paint, |
| 74 // only if the first web contents was unimpended in its attempt to do so. | 83 // only if the first web contents was unimpended in its attempt to do so. |
| 75 void RecordFirstWebContentsNonEmptyPaint(const base::TimeTicks& ticks); | 84 void RecordFirstWebContentsNonEmptyPaint(const base::TimeTicks& ticks); |
| 76 | 85 |
| 77 // Call this with the time when the first web contents began navigating its main | 86 // Call this with the time when the first web contents began navigating its main |
| 78 // frame. | 87 // frame. Adds a suffix to its metrics according to |workload|. |
| 79 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks); | 88 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks, |
| 89 WebContentsWorkload workload); |
| 80 | 90 |
| 81 // Call this with the time when the first web contents successfully committed | 91 // Call this with the time when the first web contents successfully committed |
| 82 // its navigation for the main frame. | 92 // its navigation for the main frame. |
| 83 void RecordFirstWebContentsMainNavigationFinished(const base::TimeTicks& ticks); | 93 void RecordFirstWebContentsMainNavigationFinished(const base::TimeTicks& ticks); |
| 84 | 94 |
| 85 // Returns the TimeTicks corresponding to main entry as recorded by | 95 // Returns the TimeTicks corresponding to main entry as recorded by |
| 86 // RecordMainEntryPointTime. Returns a null TimeTicks if a value has not been | 96 // RecordMainEntryPointTime. Returns a null TimeTicks if a value has not been |
| 87 // recorded yet. This method is expected to be called from the UI thread. | 97 // recorded yet. This method is expected to be called from the UI thread. |
| 88 base::TimeTicks MainEntryPointTicks(); | 98 base::TimeTicks MainEntryPointTicks(); |
| 89 | 99 |
| 90 } // namespace startup_metric_utils | 100 } // namespace startup_metric_utils |
| 91 | 101 |
| 92 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ | 102 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ |
| OLD | NEW |