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

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

Issue 1558203003: Add Startup.TimeSinceLastStartup histogram. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@uptime
Patch Set: Created 4 years, 11 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> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 10
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 13
14 class PrefRegistrySimple;
15 class PrefService;
16
14 // Utility functions to support metric collection for browser startup. Timings 17 // Utility functions to support metric collection for browser startup. Timings
15 // should use TimeTicks whenever possible. OS-provided timings are still 18 // should use TimeTicks whenever possible. OS-provided timings are still
16 // received as Time out of cross-platform support necessity but are converted to 19 // received as Time out of cross-platform support necessity but are converted to
17 // TimeTicks as soon as possible in an attempt to reduce the potential skew 20 // TimeTicks as soon as possible in an attempt to reduce the potential skew
18 // between the two basis. See crbug.com/544131 for reasoning. 21 // between the two basis. See crbug.com/544131 for reasoning.
19 22
20 namespace startup_metric_utils { 23 namespace startup_metric_utils {
21 24
22 // An enumeration of startup temperatures. This must be kept in sync with the 25 // An enumeration of startup temperatures. This must be kept in sync with the
23 // UMA StartupType enumeration defined in histograms.xml. 26 // UMA StartupType enumeration defined in histograms.xml.
(...skipping 11 matching lines...) Expand all
35 // This must be last. 38 // This must be last.
36 STARTUP_TEMPERATURE_MAX 39 STARTUP_TEMPERATURE_MAX
37 }; 40 };
38 41
39 #if defined(OS_WIN) 42 #if defined(OS_WIN)
40 // Gets the hard fault count of the current process through |hard_fault_count|. 43 // Gets the hard fault count of the current process through |hard_fault_count|.
41 // Returns true on success. 44 // Returns true on success.
42 bool GetHardFaultCountForCurrentProcess(uint32_t* hard_fault_count); 45 bool GetHardFaultCountForCurrentProcess(uint32_t* hard_fault_count);
43 #endif // defined(OS_WIN) 46 #endif // defined(OS_WIN)
44 47
48 // Registers startup metric related prefs in |registry|.
49 void RegisterPrefs(PrefRegistrySimple* registry);
50
45 // Returns true if any UI other than the browser window has been displayed 51 // Returns true if any UI other than the browser window has been displayed
46 // so far. Useful to test if UI has been displayed before the first browser 52 // so far. Useful to test if UI has been displayed before the first browser
47 // window was shown, which would invalidate any surrounding timing metrics. 53 // window was shown, which would invalidate any surrounding timing metrics.
48 bool WasNonBrowserUIDisplayed(); 54 bool WasNonBrowserUIDisplayed();
49 55
50 // Call this when displaying UI that might potentially delay the appearance 56 // Call this when displaying UI that might potentially delay the appearance
51 // of the initial browser window on Chrome startup. 57 // of the initial browser window on Chrome startup.
52 // 58 //
53 // Note on usage: This function is idempotent and its overhead is low enough 59 // Note on usage: This function is idempotent and its overhead is low enough
54 // in comparison with UI display that it's OK to call it on every 60 // in comparison with UI display that it's OK to call it on every
(...skipping 12 matching lines...) Expand all
67 // Call this with the time when the executable is loaded and main() is entered. 73 // Call this with the time when the executable is loaded and main() is entered.
68 // Can be different from |RecordMainEntryPointTime| when the startup process is 74 // Can be different from |RecordMainEntryPointTime| when the startup process is
69 // contained in a separate dll, such as with chrome.exe / chrome.dll on Windows. 75 // contained in a separate dll, such as with chrome.exe / chrome.dll on Windows.
70 void RecordExeMainEntryPointTime(const base::Time& time); 76 void RecordExeMainEntryPointTime(const base::Time& time);
71 77
72 // Call this with the time recorded just before the message loop is started. 78 // Call this with the time recorded just before the message loop is started.
73 // |is_first_run| - is the current launch part of a first run. 79 // |is_first_run| - is the current launch part of a first run.
74 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks, 80 void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks,
75 bool is_first_run); 81 bool is_first_run);
76 82
83 // Logs the the Startup.TimeSinceLastStartup histogram. Obtains the timestamp of
84 // the last startup from |pref_service| and overwrites it with the timestamp of
85 // the current startup. If the startup temperature has been set by
86 // RecordBrowserMainMessageLoopStart, the time since last startup is also logged
87 // to an histogram suffixed with the startup temperature.
88 void RecordTimeSinceLastStartup(PrefService* pref_service);
89
77 // Call this with the time when the first browser window became visible. 90 // Call this with the time when the first browser window became visible.
78 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks); 91 void RecordBrowserWindowDisplay(const base::TimeTicks& ticks);
79 92
80 // Call this with the time delta that the browser spent opening its tabs. 93 // Call this with the time delta that the browser spent opening its tabs.
81 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta); 94 void RecordBrowserOpenTabsDelta(const base::TimeDelta& delta);
82 95
83 // Call this with a renderer main entry time. The value provided for the first 96 // Call this with a renderer main entry time. The value provided for the first
84 // call to this function is used to compute 97 // call to this function is used to compute
85 // Startup.LoadTime.BrowserMainToRendererMain. Further calls to this 98 // Startup.LoadTime.BrowserMainToRendererMain. Further calls to this
86 // function are ignored. 99 // function are ignored.
(...skipping 21 matching lines...) Expand all
108 base::TimeTicks MainEntryPointTicks(); 121 base::TimeTicks MainEntryPointTicks();
109 122
110 // Returns the startup type. This is only currently supported on the Windows 123 // Returns the startup type. This is only currently supported on the Windows
111 // platform and will simply return UNCERTAIN_STARTUP_TYPE on other platforms. 124 // platform and will simply return UNCERTAIN_STARTUP_TYPE on other platforms.
112 // This is only valid after a call to RecordBrowserMainMessageLoopStart(). 125 // This is only valid after a call to RecordBrowserMainMessageLoopStart().
113 StartupTemperature GetStartupTemperature(); 126 StartupTemperature GetStartupTemperature();
114 127
115 } // namespace startup_metric_utils 128 } // namespace startup_metric_utils
116 129
117 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_ 130 #endif // COMPONENTS_STARTUP_METRIC_UTILS_BROWSER_STARTUP_METRIC_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698