| Index: components/startup_metric_utils/browser/startup_metric_utils.cc
|
| diff --git a/components/startup_metric_utils/browser/startup_metric_utils.cc b/components/startup_metric_utils/browser/startup_metric_utils.cc
|
| index 914c960dc377f4a668a67ab2a758fd8f6a6d25e4..6594376949548637e720e4a3df86c084f118d862 100644
|
| --- a/components/startup_metric_utils/browser/startup_metric_utils.cc
|
| +++ b/components/startup_metric_utils/browser/startup_metric_utils.cc
|
| @@ -135,6 +135,30 @@ typedef NTSTATUS (WINAPI *NtQuerySystemInformationPtr)(
|
| g_startup_temperature); \
|
| }
|
|
|
| +// Returns the system uptime on process launch.
|
| +base::TimeDelta GetSystemUptimeOnProcessLaunch() {
|
| + // Process launch time is not available on Android.
|
| + if (g_process_creation_ticks.Get().is_null())
|
| + return base::TimeDelta();
|
| +
|
| + // base::SysInfo::Uptime returns the time elapsed between system boot and now.
|
| + // Substract the time elapsed between process launch and now to get the time
|
| + // elapsed between system boot and process launch.
|
| + return base::SysInfo::Uptime() -
|
| + (base::TimeTicks::Now() - g_process_creation_ticks.Get());
|
| +}
|
| +
|
| +void RecordSystemUptimeHistogram() {
|
| + const base::TimeDelta system_uptime_on_process_launch =
|
| + GetSystemUptimeOnProcessLaunch();
|
| + if (system_uptime_on_process_launch.is_zero())
|
| + return;
|
| +
|
| + UMA_HISTOGRAM_WITH_STARTUP_TEMPERATURE(UMA_HISTOGRAM_LONG_TIMES_100,
|
| + "Startup.SystemUptime",
|
| + GetSystemUptimeOnProcessLaunch());
|
| +}
|
| +
|
| // On Windows, records the number of hard-faults that have occurred in the
|
| // current chrome.exe process since it was started. This is a nop on other
|
| // platforms.
|
| @@ -395,6 +419,7 @@ void RecordBrowserMainMessageLoopStart(const base::TimeTicks& ticks,
|
| bool is_first_run) {
|
| AddStartupEventsForTelemetry();
|
| RecordHardFaultHistogram(is_first_run);
|
| + RecordSystemUptimeHistogram();
|
| RecordMainEntryTimeHistogram();
|
|
|
| const base::TimeTicks& process_creation_ticks =
|
|
|