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

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

Issue 2283073002: Cleanup startup_metric_utils.h/.cc. (Closed)
Patch Set: Created 4 years, 3 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 <stdint.h>
9 #include <string>
10
11 #include "base/time/time.h" 8 #include "base/time/time.h"
12 #include "build/build_config.h"
13 9
14 class PrefRegistrySimple; 10 class PrefRegistrySimple;
15 class PrefService; 11 class PrefService;
16 12
17 // Utility functions to support metric collection for browser startup. Timings 13 // Utility functions to support metric collection for browser startup. Timings
18 // should use TimeTicks whenever possible. OS-provided timings are still 14 // should use TimeTicks whenever possible. OS-provided timings are still
19 // 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
20 // 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
21 // between the two basis. See crbug.com/544131 for reasoning. 17 // between the two basis. See crbug.com/544131 for reasoning.
22 18
23 namespace startup_metric_utils { 19 namespace startup_metric_utils {
24 20
25 // An enumeration of startup temperatures. This must be kept in sync with the
26 // UMA StartupType enumeration defined in histograms.xml.
27 enum StartupTemperature {
28 // The startup was a cold start: nearly all of the binaries and resources were
29 // brought into memory using hard faults.
30 COLD_STARTUP_TEMPERATURE = 0,
31 // The startup was a warm start: the binaries and resources were mostly
32 // already resident in memory and effectively no hard faults were observed.
33 WARM_STARTUP_TEMPERATURE = 1,
34 // The startup type couldn't quite be classified as warm or cold, but rather
35 // was somewhere in between.
36 LUKEWARM_STARTUP_TEMPERATURE = 2,
37 // This must be after all meaningful values. All new values should be added
38 // above this one.
39 STARTUP_TEMPERATURE_COUNT,
40 // Startup temperature wasn't yet determined.
41 UNDETERMINED_STARTUP_TEMPERATURE
42 };
43
44 #if defined(OS_WIN)
45 // Gets the hard fault count of the current process through |hard_fault_count|.
46 // Returns true on success.
47 bool GetHardFaultCountForCurrentProcess(uint32_t* hard_fault_count);
48 #endif // defined(OS_WIN)
49
50 // Registers startup related prefs in |registry|. 21 // Registers startup related prefs in |registry|.
51 void RegisterPrefs(PrefRegistrySimple* registry); 22 void RegisterPrefs(PrefRegistrySimple* registry);
52 23
53 // Returns true if any UI other than the browser window has been displayed 24 // Returns true if any UI other than the browser window has been displayed
54 // so far. Useful to test if UI has been displayed before the first browser 25 // so far. Useful to test if UI has been displayed before the first browser
55 // window was shown, which would invalidate any surrounding timing metrics. 26 // window was shown, which would invalidate any surrounding timing metrics.
56 bool WasNonBrowserUIDisplayed(); 27 bool WasNonBrowserUIDisplayed();
57 28
58 // Call this when displaying UI that might potentially delay startup events. 29 // Call this when displaying UI that might potentially delay startup events.
59 // 30 //
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 80
110 // Call this with the time when the first web contents successfully committed 81 // Call this with the time when the first web contents successfully committed
111 // its navigation for the main frame. 82 // its navigation for the main frame.
112 void RecordFirstWebContentsMainNavigationFinished(const base::TimeTicks& ticks); 83 void RecordFirstWebContentsMainNavigationFinished(const base::TimeTicks& ticks);
113 84
114 // Returns the TimeTicks corresponding to main entry as recorded by 85 // Returns the TimeTicks corresponding to main entry as recorded by
115 // RecordMainEntryPointTime. Returns a null TimeTicks if a value has not been 86 // RecordMainEntryPointTime. Returns a null TimeTicks if a value has not been
116 // recorded yet. This method is expected to be called from the UI thread. 87 // recorded yet. This method is expected to be called from the UI thread.
117 base::TimeTicks MainEntryPointTicks(); 88 base::TimeTicks MainEntryPointTicks();
118 89
119 // Returns the startup type. This is only currently supported on the Windows
120 // platform and will simply return UNCERTAIN_STARTUP_TYPE on other platforms.
121 // This is only valid after a call to RecordBrowserMainMessageLoopStart().
122 StartupTemperature GetStartupTemperature();
123
124 } // namespace startup_metric_utils 90 } // namespace startup_metric_utils
125 91
126 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ 92 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698