| 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 "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
| 8 #include "base/environment.h" | 8 #include "base/environment.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 16 | 16 |
| 17 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| 18 #include <winternl.h> | 18 #include <winternl.h> |
| 19 #include "base/win/win_util.h" |
| 19 #include "base/win/windows_version.h" | 20 #include "base/win/windows_version.h" |
| 20 #endif | 21 #endif |
| 21 | 22 |
| 22 namespace startup_metric_utils { | 23 namespace startup_metric_utils { |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // Mark as volatile to defensively make sure usage is thread-safe. | 27 // Mark as volatile to defensively make sure usage is thread-safe. |
| 27 // Note that at the time of this writing, access is only on the UI thread. | 28 // Note that at the time of this writing, access is only on the UI thread. |
| 28 volatile bool g_non_browser_ui_displayed = false; | 29 volatile bool g_non_browser_ui_displayed = false; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 return false; | 140 return false; |
| 140 } | 141 } |
| 141 | 142 |
| 142 // Look for the struct housing information for the current process. | 143 // Look for the struct housing information for the current process. |
| 143 DWORD proc_id = ::GetCurrentProcessId(); | 144 DWORD proc_id = ::GetCurrentProcessId(); |
| 144 size_t index = 0; | 145 size_t index = 0; |
| 145 while (index < buffer.size()) { | 146 while (index < buffer.size()) { |
| 146 DCHECK_LE(index + sizeof(SYSTEM_PROCESS_INFORMATION_EX), buffer.size()); | 147 DCHECK_LE(index + sizeof(SYSTEM_PROCESS_INFORMATION_EX), buffer.size()); |
| 147 SYSTEM_PROCESS_INFORMATION_EX* proc_info = | 148 SYSTEM_PROCESS_INFORMATION_EX* proc_info = |
| 148 reinterpret_cast<SYSTEM_PROCESS_INFORMATION_EX*>(buffer.data() + index); | 149 reinterpret_cast<SYSTEM_PROCESS_INFORMATION_EX*>(buffer.data() + index); |
| 149 if (reinterpret_cast<DWORD>(proc_info->UniqueProcessId) == proc_id) { | 150 if (base::win::HandleToUint32(proc_info->UniqueProcessId) == proc_id) { |
| 150 *hard_fault_count = proc_info->HardFaultCount; | 151 *hard_fault_count = proc_info->HardFaultCount; |
| 151 return true; | 152 return true; |
| 152 } | 153 } |
| 153 // The list ends when NextEntryOffset is zero. This also prevents busy | 154 // The list ends when NextEntryOffset is zero. This also prevents busy |
| 154 // looping if the data is in fact invalid. | 155 // looping if the data is in fact invalid. |
| 155 if (proc_info->NextEntryOffset <= 0) | 156 if (proc_info->NextEntryOffset <= 0) |
| 156 return false; | 157 return false; |
| 157 index += proc_info->NextEntryOffset; | 158 index += proc_info->NextEntryOffset; |
| 158 } | 159 } |
| 159 | 160 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 564 |
| 564 base::TimeTicks MainEntryPointTicks() { | 565 base::TimeTicks MainEntryPointTicks() { |
| 565 return g_browser_main_entry_point_ticks.Get(); | 566 return g_browser_main_entry_point_ticks.Get(); |
| 566 } | 567 } |
| 567 | 568 |
| 568 StartupTemperature GetStartupTemperature() { | 569 StartupTemperature GetStartupTemperature() { |
| 569 return g_startup_temperature; | 570 return g_startup_temperature; |
| 570 } | 571 } |
| 571 | 572 |
| 572 } // namespace startup_metric_utils | 573 } // namespace startup_metric_utils |
| OLD | NEW |