| 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 #include "components/startup_metric_utils/browser/startup_metric_utils.h" | 5 #include "components/startup_metric_utils/browser/startup_metric_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 |
| 7 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 8 #include "base/environment.h" | 10 #include "base/environment.h" |
| 9 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 14 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
| 15 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 18 #include "build/build_config.h" |
| 16 | 19 |
| 17 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 18 #include <winternl.h> | 21 #include <winternl.h> |
| 19 #include "base/win/win_util.h" | 22 #include "base/win/win_util.h" |
| 20 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
| 21 #endif | 24 #endif |
| 22 | 25 |
| 23 namespace startup_metric_utils { | 26 namespace startup_metric_utils { |
| 24 | 27 |
| 25 namespace { | 28 namespace { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 223 |
| 221 // Record time of main entry so it can be read from Telemetry performance tests. | 224 // Record time of main entry so it can be read from Telemetry performance tests. |
| 222 // TODO(jeremy): Remove once crbug.com/317481 is fixed. | 225 // TODO(jeremy): Remove once crbug.com/317481 is fixed. |
| 223 void RecordMainEntryTimeHistogram() { | 226 void RecordMainEntryTimeHistogram() { |
| 224 const int kLowWordMask = 0xFFFFFFFF; | 227 const int kLowWordMask = 0xFFFFFFFF; |
| 225 const int kLower31BitsMask = 0x7FFFFFFF; | 228 const int kLower31BitsMask = 0x7FFFFFFF; |
| 226 DCHECK(!g_browser_main_entry_point_time.Get().is_null()); | 229 DCHECK(!g_browser_main_entry_point_time.Get().is_null()); |
| 227 const base::TimeDelta browser_main_entry_time_absolute = | 230 const base::TimeDelta browser_main_entry_time_absolute = |
| 228 g_browser_main_entry_point_time.Get() - base::Time::UnixEpoch(); | 231 g_browser_main_entry_point_time.Get() - base::Time::UnixEpoch(); |
| 229 | 232 |
| 230 const uint64 browser_main_entry_time_raw_ms = | 233 const uint64_t browser_main_entry_time_raw_ms = |
| 231 browser_main_entry_time_absolute.InMilliseconds(); | 234 browser_main_entry_time_absolute.InMilliseconds(); |
| 232 | 235 |
| 233 const base::TimeDelta browser_main_entry_time_raw_ms_high_word = | 236 const base::TimeDelta browser_main_entry_time_raw_ms_high_word = |
| 234 base::TimeDelta::FromMilliseconds( | 237 base::TimeDelta::FromMilliseconds( |
| 235 (browser_main_entry_time_raw_ms >> 32) & kLowWordMask); | 238 (browser_main_entry_time_raw_ms >> 32) & kLowWordMask); |
| 236 // Shift by one because histograms only support non-negative values. | 239 // Shift by one because histograms only support non-negative values. |
| 237 const base::TimeDelta browser_main_entry_time_raw_ms_low_word = | 240 const base::TimeDelta browser_main_entry_time_raw_ms_low_word = |
| 238 base::TimeDelta::FromMilliseconds( | 241 base::TimeDelta::FromMilliseconds( |
| 239 (browser_main_entry_time_raw_ms >> 1) & kLower31BitsMask); | 242 (browser_main_entry_time_raw_ms >> 1) & kLower31BitsMask); |
| 240 | 243 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 264 | 267 |
| 265 // Environment variable that stores the timestamp when the executable's main() | 268 // Environment variable that stores the timestamp when the executable's main() |
| 266 // function was entered in TimeTicks. This is required because chrome.exe and | 269 // function was entered in TimeTicks. This is required because chrome.exe and |
| 267 // chrome.dll don't share the same static storage. | 270 // chrome.dll don't share the same static storage. |
| 268 const char kChromeMainTicksEnvVar[] = "CHROME_MAIN_TICKS"; | 271 const char kChromeMainTicksEnvVar[] = "CHROME_MAIN_TICKS"; |
| 269 | 272 |
| 270 // Returns the time of main entry recorded from RecordExeMainEntryTime. | 273 // Returns the time of main entry recorded from RecordExeMainEntryTime. |
| 271 base::TimeTicks ExeMainEntryPointTicks() { | 274 base::TimeTicks ExeMainEntryPointTicks() { |
| 272 scoped_ptr<base::Environment> env(base::Environment::Create()); | 275 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 273 std::string ticks_string; | 276 std::string ticks_string; |
| 274 int64 time_int = 0; | 277 int64_t time_int = 0; |
| 275 if (env->GetVar(kChromeMainTicksEnvVar, &ticks_string) && | 278 if (env->GetVar(kChromeMainTicksEnvVar, &ticks_string) && |
| 276 base::StringToInt64(ticks_string, &time_int)) { | 279 base::StringToInt64(ticks_string, &time_int)) { |
| 277 return base::TimeTicks::FromInternalValue(time_int); | 280 return base::TimeTicks::FromInternalValue(time_int); |
| 278 } | 281 } |
| 279 return base::TimeTicks(); | 282 return base::TimeTicks(); |
| 280 } | 283 } |
| 281 | 284 |
| 282 void AddStartupEventsForTelemetry() | 285 void AddStartupEventsForTelemetry() |
| 283 { | 286 { |
| 284 DCHECK(!g_browser_main_entry_point_ticks.Get().is_null()); | 287 DCHECK(!g_browser_main_entry_point_ticks.Get().is_null()); |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 | 544 |
| 542 base::TimeTicks MainEntryPointTicks() { | 545 base::TimeTicks MainEntryPointTicks() { |
| 543 return g_browser_main_entry_point_ticks.Get(); | 546 return g_browser_main_entry_point_ticks.Get(); |
| 544 } | 547 } |
| 545 | 548 |
| 546 StartupTemperature GetStartupTemperature() { | 549 StartupTemperature GetStartupTemperature() { |
| 547 return g_startup_temperature; | 550 return g_startup_temperature; |
| 548 } | 551 } |
| 549 | 552 |
| 550 } // namespace startup_metric_utils | 553 } // namespace startup_metric_utils |
| OLD | NEW |