Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: components/startup_metric_utils/browser/startup_metric_utils.h

Issue 1667903003: [Merge M48] Add Startup.TimeSinceLastStartup histogram. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2564
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 11
12 class PrefRegistrySimple;
13 class PrefService;
14
12 // Utility functions to support metric collection for browser startup. Timings 15 // Utility functions to support metric collection for browser startup. Timings
13 // should use TimeTicks whenever possible. OS-provided timings are still 16 // should use TimeTicks whenever possible. OS-provided timings are still
14 // received as Time out of cross-platform support necessity but are converted to 17 // received as Time out of cross-platform support necessity but are converted to
15 // TimeTicks as soon as possible in an attempt to reduce the potential skew 18 // TimeTicks as soon as possible in an attempt to reduce the potential skew
16 // between the two basis. See crbug.com/544131 for reasoning. 19 // between the two basis. See crbug.com/544131 for reasoning.
17 20
18 namespace startup_metric_utils { 21 namespace startup_metric_utils {
19 22
20 // An enumeration of startup temperatures. This must be kept in sync with the 23 // An enumeration of startup temperatures. This must be kept in sync with the
21 // UMA StartupType enumeration defined in histograms.xml. 24 // UMA StartupType enumeration defined in histograms.xml.
22 enum StartupTemperature { 25 enum StartupTemperature {
23 // The startup was a cold start: nearly all of the Chrome binaries and 26 // The startup was a cold start: nearly all of the Chrome binaries and
24 // resources were brought into memory using hard faults. 27 // resources were brought into memory using hard faults.
25 COLD_STARTUP_TEMPERATURE = 0, 28 COLD_STARTUP_TEMPERATURE = 0,
26 // The startup was a warm start: the Chrome binaries and resources were 29 // The startup was a warm start: the Chrome binaries and resources were
27 // mostly already resident in memory and effectively no hard faults were 30 // mostly already resident in memory and effectively no hard faults were
28 // observed. 31 // observed.
29 WARM_STARTUP_TEMPERATURE = 1, 32 WARM_STARTUP_TEMPERATURE = 1,
30 // The startup type couldn't quite be classified as warm or cold, but rather 33 // The startup type couldn't quite be classified as warm or cold, but rather
31 // was somewhere in between. 34 // was somewhere in between.
32 LUKEWARM_STARTUP_TEMPERATURE = 2, 35 LUKEWARM_STARTUP_TEMPERATURE = 2,
33 // This must be after all meaningful values. 36 // This must be after all meaningful values.
34 STARTUP_TEMPERATURE_COUNT, 37 STARTUP_TEMPERATURE_COUNT,
35 // Startup temperature wasn't yet determined. 38 // Startup temperature wasn't yet determined.
36 UNDETERMINED_STARTUP_TEMPERATURE 39 UNDETERMINED_STARTUP_TEMPERATURE
37 }; 40 };
38 41
42 // Registers startup related prefs in |registry|.
43 void RegisterPrefs(PrefRegistrySimple* registry);
44
39 // 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
40 // 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
41 // window was shown, which would invalidate any surrounding timing metrics. 47 // window was shown, which would invalidate any surrounding timing metrics.
42 bool WasNonBrowserUIDisplayed(); 48 bool WasNonBrowserUIDisplayed();
43 49
44 // Call this when displaying UI that might potentially delay the appearance 50 // Call this when displaying UI that might potentially delay the appearance
45 // of the initial browser window on Chrome startup. 51 // of the initial browser window on Chrome startup.
46 // 52 //
47 // Note on usage: This function is idempotent and its overhead is low enough 53 // Note on usage: This function is idempotent and its overhead is low enough
48 // in comparison with UI display that it's OK to call it on every 54 // in comparison with UI display that it's OK to call it on every
(...skipping 12 matching lines...) Expand all
61 // Call this with the time when the executable is loaded and main() is entered. 67 // Call this with the time when the executable is loaded and main() is entered.
62 // Can be different from |RecordMainEntryPointTime| when the startup process is 68 // Can be different from |RecordMainEntryPointTime| when the startup process is
63 // contained in a separate dll, such as with chrome.exe / chrome.dll on Windows. 69 // contained in a separate dll, such as with chrome.exe / chrome.dll on Windows.
64 void RecordExeMainEntryPointTime(const base::Time& time); 70 void RecordExeMainEntryPointTime(const base::Time& time);
65 71
66 // Call this with the time recorded just before the message loop is started. 72 // Call this with the time recorded just before the message loop is started.
67 // |is_first_run| - is the current launch part of a first run. 73 // |is_first_run| - is the current launch part of a first run.
68 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, 74 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks,
69 bool is_first_run); 75 bool is_first_run);
70 76
77 // Logs the Startup.TimeSinceLastStartup histogram. Obtains the timestamp of the
78 // last startup from |pref_service| and overwrites it with the timestamp of the
79 // current startup. If the startup temperature has been set by
80 // RecordBrowserMainMessageLoopStart, the time since last startup is also logged
81 // to an histogram suffixed with the startup temperature.
82 void RecordTimeSinceLastStartup(PrefService* pref_service);
83
71 // Call this with the time when the first browser window became visible. 84 // Call this with the time when the first browser window became visible.
72 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks); 85 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks);
73 86
74 // Call this with the time delta that the browser spent opening its tabs. 87 // Call this with the time delta that the browser spent opening its tabs.
75 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta); 88 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta);
76 89
77 // Call this with the time when the first web contents loaded its main frame, 90 // Call this with the time when the first web contents loaded its main frame,
78 // only if the first web contents was unimpended in its attempt to do so. 91 // only if the first web contents was unimpended in its attempt to do so.
79 void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks); 92 void RecordFirstWebContentsMainFrameLoad(const base::TimeTicks& ticks);
80 93
(...skipping 25 matching lines...) Expand all
106 base::TimeTicks MainEntryPointTicks(); 119 base::TimeTicks MainEntryPointTicks();
107 120
108 // Returns the startup type. This is only currently supported on the Windows 121 // Returns the startup type. This is only currently supported on the Windows
109 // platform and will simply return UNCERTAIN_STARTUP_TYPE on other platforms. 122 // platform and will simply return UNCERTAIN_STARTUP_TYPE on other platforms.
110 // This is only valid after a call to RecordBrowserMainMessageLoopStart(). 123 // This is only valid after a call to RecordBrowserMainMessageLoopStart().
111 StartupTemperature GetStartupTemperature(); 124 StartupTemperature GetStartupTemperature();
112 125
113 } // namespace startup_metric_utils 126 } // namespace startup_metric_utils
114 127
115 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ 128 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_
OLDNEW
« no previous file with comments | « components/startup_metric_utils/browser/BUILD.gn ('k') | components/startup_metric_utils/browser/startup_metric_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698