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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 enum StartupTemperature { | 25 enum StartupTemperature { |
26 // The startup was a cold start: nearly all of the binaries and resources were | 26 // The startup was a cold start: nearly all of the binaries and resources were |
27 // brought into memory using hard faults. | 27 // brought into memory using hard faults. |
28 COLD_STARTUP_TEMPERATURE = 0, | 28 COLD_STARTUP_TEMPERATURE = 0, |
29 // The startup was a warm start: the binaries and resources were mostly | 29 // The startup was a warm start: the binaries and resources were mostly |
30 // already resident in memory and effectively no hard faults were observed. | 30 // already resident in memory and effectively no hard faults were observed. |
31 WARM_STARTUP_TEMPERATURE = 1, | 31 WARM_STARTUP_TEMPERATURE = 1, |
32 // The startup type couldn't quite be classified as warm or cold, but rather | 32 // The startup type couldn't quite be classified as warm or cold, but rather |
33 // was somewhere in between. | 33 // was somewhere in between. |
34 LUKEWARM_STARTUP_TEMPERATURE = 2, | 34 LUKEWARM_STARTUP_TEMPERATURE = 2, |
35 // This must be after all meaningful values. | 35 // This must be after all meaningful values. All new values should be added |
| 36 // above this one. |
36 STARTUP_TEMPERATURE_COUNT, | 37 STARTUP_TEMPERATURE_COUNT, |
37 // Startup temperature wasn't yet determined. | 38 // Startup temperature wasn't yet determined. |
38 UNDETERMINED_STARTUP_TEMPERATURE | 39 UNDETERMINED_STARTUP_TEMPERATURE |
39 }; | 40 }; |
40 | 41 |
41 // Registers startup related prefs in |registry|. | 42 // Registers startup related prefs in |registry|. |
42 void RegisterPrefs(PrefRegistrySimple* registry); | 43 void RegisterPrefs(PrefRegistrySimple* registry); |
43 | 44 |
44 // Returns true if any UI other than the browser window has been displayed | 45 // Returns true if any UI other than the browser window has been displayed |
45 // so far. Useful to test if UI has been displayed before the first browser | 46 // so far. Useful to test if UI has been displayed before the first browser |
(...skipping 15 matching lines...) Expand all Loading... |
61 // On Android, the entry point time is the time at which the Java code starts. | 62 // On Android, the entry point time is the time at which the Java code starts. |
62 // In Mojo, the entry point time is the time at which the shell starts. | 63 // In Mojo, the entry point time is the time at which the shell starts. |
63 void RecordMainEntryPointTime(const base::Time& time); | 64 void RecordMainEntryPointTime(const base::Time& time); |
64 | 65 |
65 // Call this with the time when the executable is loaded and main() is entered. | 66 // Call this with the time when the executable is loaded and main() is entered. |
66 // Can be different from |RecordMainEntryPointTime| when the startup process is | 67 // Can be different from |RecordMainEntryPointTime| when the startup process is |
67 // contained in a separate dll, such as with chrome.exe / chrome.dll on Windows. | 68 // contained in a separate dll, such as with chrome.exe / chrome.dll on Windows. |
68 void RecordExeMainEntryPointTime(const base::Time& time); | 69 void RecordExeMainEntryPointTime(const base::Time& time); |
69 | 70 |
70 // Call this with the time recorded just before the message loop is started. | 71 // Call this with the time recorded just before the message loop is started. |
71 // |is_first_run| - is the current launch part of a first run. | 72 // |is_first_run| - is the current launch part of a first run. |pref_service| is |
| 73 // an optional parameter which, if provided, will be used to store state for |
| 74 // stats that span multiple startups; in its absence those stats will not be |
| 75 // recorded. |
72 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, | 76 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, |
73 bool is_first_run); | 77 bool is_first_run, |
74 | 78 PrefService* pref_service); |
75 // Logs the Startup.TimeSinceLastStartup histogram. Obtains the timestamp of the | |
76 // last startup from |pref_service| and overwrites it with the timestamp of the | |
77 // current startup. If the startup temperature has been set by | |
78 // RecordBrowserMainMessageLoopStart, the time since last startup is also logged | |
79 // to an histogram suffixed with the startup temperature. | |
80 void RecordTimeSinceLastStartup(PrefService* pref_service); | |
81 | |
82 // Logs the Startup.SameVersionStartupCount histogram. Relies on |pref_service| | |
83 // to know information about the previous startups and store information for | |
84 // future ones. | |
85 void RecordStartupCount(PrefService* pref_service); | |
86 | 79 |
87 // Call this with the time when the first browser window became visible. | 80 // Call this with the time when the first browser window became visible. |
88 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks); | 81 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks); |
89 | 82 |
90 // Call this with the time delta that the browser spent opening its tabs. | 83 // Call this with the time delta that the browser spent opening its tabs. |
91 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta); | 84 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta); |
92 | 85 |
93 // Call this with the time when the first web contents loaded its main frame, | 86 // Call this with the time when the first web contents loaded its main frame, |
94 // only if the first web contents was unimpended in its attempt to do so. | 87 // only if the first web contents was unimpended in its attempt to do so. |
95 void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks); | 88 void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks); |
(...skipping 26 matching lines...) Expand all Loading... |
122 base::TimeTicks MainEntryPointTicks(); | 115 base::TimeTicks MainEntryPointTicks(); |
123 | 116 |
124 // Returns the startup type. This is only currently supported on the Windows | 117 // Returns the startup type. This is only currently supported on the Windows |
125 // platform and will simply return UNCERTAIN_STARTUP_TYPE on other platforms. | 118 // platform and will simply return UNCERTAIN_STARTUP_TYPE on other platforms. |
126 // This is only valid after a call to RecordBrowserMainMessageLoopStart(). | 119 // This is only valid after a call to RecordBrowserMainMessageLoopStart(). |
127 StartupTemperature GetStartupTemperature(); | 120 StartupTemperature GetStartupTemperature(); |
128 | 121 |
129 } // namespace startup_metric_utils | 122 } // namespace startup_metric_utils |
130 | 123 |
131 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ | 124 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ |
OLD | NEW |