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; |
(...skipping 12 matching lines...) Expand all Loading... | |
23 enum class WebContentsWorkload { | 23 enum class WebContentsWorkload { |
24 // Only loading a single tab. | 24 // Only loading a single tab. |
25 SINGLE_TAB, | 25 SINGLE_TAB, |
26 // Loading multiple tabs (of which the profiled WebContents is foreground). | 26 // Loading multiple tabs (of which the profiled WebContents is foreground). |
27 MULTI_TABS, | 27 MULTI_TABS, |
28 }; | 28 }; |
29 | 29 |
30 // Registers startup related prefs in |registry|. | 30 // Registers startup related prefs in |registry|. |
31 void RegisterPrefs(PrefRegistrySimple* registry); | 31 void RegisterPrefs(PrefRegistrySimple* registry); |
32 | 32 |
33 // Returns true if any UI other than the browser window has been displayed | 33 // Returns true when browser UI was not launched normally: some other UI was |
34 // so far. Useful to test if UI has been displayed before the first browser | 34 // shown first or browser was launched in background mode. |
35 // window was shown, which would invalidate any surrounding timing metrics. | 35 bool WasMainWindowStartupInterrupted(); |
36 bool WasNonBrowserUIDisplayed(); | |
37 | 36 |
38 // Call this when displaying UI that might potentially delay startup events. | 37 // Call this when displaying UI that might potentially delay startup events. |
39 // | 38 // |
40 // Note on usage: This function is idempotent and its overhead is low enough | 39 // Note on usage: This function is idempotent and its overhead is low enough |
41 // in comparison with UI display that it's OK to call it on every | 40 // in comparison with UI display that it's OK to call it on every |
42 // UI invocation regardless of whether the browser window has already | 41 // UI invocation regardless of whether the browser window has already |
43 // been displayed or not. | 42 // been displayed or not. |
44 void SetNonBrowserUIDisplayed(); | 43 void SetNonBrowserUIDisplayed(); |
45 | 44 |
45 // Call this when background mode gets enabled, as it might delay startup | |
46 // events. | |
47 void SetBackgroundModeEnabled(); | |
48 | |
46 // Call this with the creation time of the startup (initial/main) process. | 49 // Call this with the creation time of the startup (initial/main) process. |
47 void RecordStartupProcessCreationTime(const base::Time& time); | 50 void RecordStartupProcessCreationTime(const base::Time time); |
gab
2017/04/19 18:45:43
nit: no "const" when passing by value
themblsha
2017/04/20 10:42:23
pkasting did a great explanation why it should be
| |
48 | 51 |
49 // Call this with a time recorded as early as possible in the startup process. | 52 // Call this with a time recorded as early as possible in the startup process. |
50 // On Android, the entry point time is the time at which the Java code starts. | 53 // On Android, the entry point time is the time at which the Java code starts. |
51 // In Mojo, the entry point time is the time at which the shell starts. | 54 // In Mojo, the entry point time is the time at which the shell starts. |
52 void RecordMainEntryPointTime(const base::Time& time); | 55 void RecordMainEntryPointTime(const base::Time time); |
53 | 56 |
54 // Call this with the time when the executable is loaded and main() is entered. | 57 // Call this with the time when the executable is loaded and main() is entered. |
55 // Can be different from |RecordMainEntryPointTime| when the startup process is | 58 // Can be different from |RecordMainEntryPointTime| when the startup process is |
56 // contained in a separate dll, such as with chrome.exe / chrome.dll on Windows. | 59 // contained in a separate dll, such as with chrome.exe / chrome.dll on Windows. |
57 void RecordExeMainEntryPointTicks(const base::TimeTicks& time); | 60 void RecordExeMainEntryPointTicks(const base::TimeTicks time); |
58 | 61 |
59 // Call this with the time recorded just before the message loop is started. | 62 // Call this with the time recorded just before the message loop is started. |
60 // |is_first_run| - is the current launch part of a first run. |pref_service| is | 63 // |is_first_run| - is the current launch part of a first run. |pref_service| is |
61 // used to store state for stats that span multiple startups. | 64 // used to store state for stats that span multiple startups. |
62 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, | 65 void RecordBrowserMainMessageLoopStart(const base::TimeTicks ticks, |
63 bool is_first_run, | 66 bool is_first_run, |
64 PrefService* pref_service); | 67 PrefService* pref_service); |
65 | 68 |
66 // Call this with the time when the first browser window became visible. | 69 // Call this with the time when the first browser window became visible. |
67 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks); | 70 void RecordBrowserWindowDisplay(const base::TimeTicks ticks); |
68 | 71 |
69 // Call this with the time delta that the browser spent opening its tabs. | 72 // Call this with the time delta that the browser spent opening its tabs. |
70 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta); | 73 void RecordBrowserOpenTabsDelta(const base::TimeDelta delta); |
71 | 74 |
72 // Call this with a renderer main entry time. The value provided for the first | 75 // Call this with a renderer main entry time. The value provided for the first |
73 // call to this function is used to compute | 76 // call to this function is used to compute |
74 // Startup.LoadTime.BrowserMainToRendererMain. Further calls to this | 77 // Startup.LoadTime.BrowserMainToRendererMain. Further calls to this |
75 // function are ignored. | 78 // function are ignored. |
76 void RecordRendererMainEntryTime(const base::TimeTicks& ticks); | 79 void RecordRendererMainEntryTime(const base::TimeTicks ticks); |
77 | 80 |
78 // Call this with the time when the first web contents loaded its main frame, | 81 // Call this with the time when the first web contents loaded its main frame, |
79 // only if the first web contents was unimpended in its attempt to do so. | 82 // only if the first web contents was unimpended in its attempt to do so. |
80 void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks); | 83 void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks ticks); |
81 | 84 |
82 // Call this with the time when the first web contents had a non-empty paint, | 85 // Call this with the time when the first web contents had a non-empty paint, |
83 // only if the first web contents was unimpended in its attempt to do so. | 86 // only if the first web contents was unimpended in its attempt to do so. |
84 void RecordFirstWebContentsNonEmptyPaint(const base::TimeTicks& ticks); | 87 void RecordFirstWebContentsNonEmptyPaint(const base::TimeTicks ticks); |
85 | 88 |
86 // Call this with the time when the first web contents began navigating its main | 89 // Call this with the time when the first web contents began navigating its main |
87 // frame. Adds a suffix to its metrics according to |workload|. | 90 // frame. Adds a suffix to its metrics according to |workload|. |
88 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks& ticks, | 91 void RecordFirstWebContentsMainNavigationStart(const base::TimeTicks ticks, |
89 WebContentsWorkload workload); | 92 WebContentsWorkload workload); |
90 | 93 |
91 // Call this with the time when the first web contents successfully committed | 94 // Call this with the time when the first web contents successfully committed |
92 // its navigation for the main frame. | 95 // its navigation for the main frame. |
93 void RecordFirstWebContentsMainNavigationFinished(const base::TimeTicks& ticks); | 96 void RecordFirstWebContentsMainNavigationFinished(const base::TimeTicks ticks); |
97 | |
98 // Call this with the time when the Browser window painted its children for the | |
99 // first time. | |
100 void RecordBrowserWindowFirstPaint(const base::TimeTicks ticks); | |
101 | |
102 // Call this with the time when the Browser window painted its children for the | |
103 // first time and we got a CompositingEnded after that. | |
104 void RecordBrowserWindowFirstPaintCompositingEnded(const base::TimeTicks ticks); | |
94 | 105 |
95 // Returns the TimeTicks corresponding to main entry as recorded by | 106 // Returns the TimeTicks corresponding to main entry as recorded by |
96 // RecordMainEntryPointTime. Returns a null TimeTicks if a value has not been | 107 // RecordMainEntryPointTime. Returns a null TimeTicks if a value has not been |
97 // recorded yet. This method is expected to be called from the UI thread. | 108 // recorded yet. This method is expected to be called from the UI thread. |
98 base::TimeTicks MainEntryPointTicks(); | 109 base::TimeTicks MainEntryPointTicks(); |
99 | 110 |
100 } // namespace startup_metric_utils | 111 } // namespace startup_metric_utils |
101 | 112 |
102 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ | 113 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ |
OLD | NEW |