OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" | 5 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/cpu.h" | 11 #include "base/cpu.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/metrics/sparse_histogram.h" | 14 #include "base/metrics/sparse_histogram.h" |
15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "chrome/browser/about_flags.h" | 19 #include "chrome/browser/about_flags.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/chrome_browser_main.h" | 21 #include "chrome/browser/chrome_browser_main.h" |
22 #include "chrome/browser/enumerate_modules_model_win.h" | |
22 #include "chrome/browser/mac/bluetooth_utility.h" | 23 #include "chrome/browser/mac/bluetooth_utility.h" |
23 #include "chrome/browser/shell_integration.h" | 24 #include "chrome/browser/shell_integration.h" |
24 #include "components/flags_ui/pref_service_flags_storage.h" | 25 #include "components/flags_ui/pref_service_flags_storage.h" |
25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
26 #include "ui/base/touch/touch_device.h" | 27 #include "ui/base/touch/touch_device.h" |
27 #include "ui/base/ui_base_switches.h" | 28 #include "ui/base/ui_base_switches.h" |
28 #include "ui/display/screen.h" | 29 #include "ui/display/screen.h" |
29 #include "ui/events/event_switches.h" | 30 #include "ui/events/event_switches.h" |
30 | 31 |
31 #if !defined(OS_ANDROID) | 32 #if !defined(OS_ANDROID) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 } else { | 130 } else { |
130 UMA_HISTOGRAM_ENUMERATION("Android.ArmFpu", | 131 UMA_HISTOGRAM_ENUMERATION("Android.ArmFpu", |
131 UMA_ANDROID_ARM_FPU_VFPV3_D16, | 132 UMA_ANDROID_ARM_FPU_VFPV3_D16, |
132 UMA_ANDROID_ARM_FPU_COUNT); | 133 UMA_ANDROID_ARM_FPU_COUNT); |
133 } | 134 } |
134 #endif // defined(OS_ANDROID) && defined(__arm__) | 135 #endif // defined(OS_ANDROID) && defined(__arm__) |
135 UMA_HISTOGRAM_SPARSE_SLOWLY("Platform.LogicalCpuCount", | 136 UMA_HISTOGRAM_SPARSE_SLOWLY("Platform.LogicalCpuCount", |
136 base::SysInfo::NumberOfProcessors()); | 137 base::SysInfo::NumberOfProcessors()); |
137 } | 138 } |
138 | 139 |
140 #if defined(OS_WIN) | |
141 // Gathers third party module information. | |
142 void GatherThirdPartyModuleMetricsOnBlockingPool() { | |
143 // Get the module list. If it's not yet ready post a delayed task to try again | |
144 // in a bit. | |
145 auto modules = EnumerateModulesModel::GetInstance(); | |
146 std::unique_ptr<base::ListValue> list(modules->GetModuleList()); | |
147 if (list.get() == nullptr) { | |
148 content::BrowserThread::GetBlockingPool()->PostDelayedTask( | |
149 FROM_HERE, | |
150 base::Bind(&GatherThirdPartyModuleMetricsOnBlockingPool), | |
151 base::TimeDelta::FromSeconds(1)); | |
grt (UTC plus 2)
2016/06/06 01:38:57
please do something better than polling for the re
| |
152 return; | |
153 } | |
154 | |
155 // Process the module list. | |
156 size_t microsoft_modules = 0; | |
157 for (size_t i = 0; i < list->GetSize(); ++i) { | |
158 base::DictionaryValue* module = nullptr; | |
159 CHECK(list->GetDictionary(i, &module)); | |
rkaplow
2016/06/03 18:17:31
DCHECK here and below
rkaplow
2016/06/03 18:24:31
that is, should DCHECK on the result (since it sti
| |
160 | |
161 base::string16 signer; | |
162 CHECK(module->GetString("digital_signer", &signer)); | |
163 if (signer.find(L"Microsoft") != signer.npos) | |
164 ++microsoft_modules; | |
165 } | |
166 | |
167 // Report the total number of modules present. | |
168 UMA_HISTOGRAM_CUSTOM_COUNTS("ThirdPartyModules.Modules.Microsoft", | |
169 microsoft_modules, 1, 500, 50); | |
170 UMA_HISTOGRAM_CUSTOM_COUNTS("ThirdPartyModules.Modules.Total", | |
171 list->GetSize(), 1, 500, 50); | |
172 } | |
173 | |
174 // Initiates recording of third party modules. The actual module enumeration | |
175 // ends up being performed on the file thread, while the results are eventually | |
176 // retrieved and processed on the blocking pool. | |
177 void InitiateThirdPartyModuleMetricsOnUIThread() { | |
178 // The module scanning wants to be kicked off from the UI thread. | |
179 auto modules = EnumerateModulesModel::GetInstance(); | |
180 modules->ScanNow(); | |
181 content::BrowserThread::GetBlockingPool()->PostDelayedTask( | |
182 FROM_HERE, | |
183 base::Bind(&GatherThirdPartyModuleMetricsOnBlockingPool), | |
184 base::TimeDelta::FromSeconds(1)); | |
185 } | |
186 #endif // defined(OS_WIN) | |
187 | |
139 // Called on the blocking pool some time after startup to avoid slowing down | 188 // Called on the blocking pool some time after startup to avoid slowing down |
140 // startup with metrics that aren't trivial to compute. | 189 // startup with metrics that aren't trivial to compute. |
141 void RecordStartupMetricsOnBlockingPool() { | 190 void RecordStartupMetricsOnBlockingPool() { |
142 #if defined(OS_WIN) | 191 #if defined(OS_WIN) |
143 GoogleUpdateSettings::RecordChromeUpdatePolicyHistograms(); | 192 GoogleUpdateSettings::RecordChromeUpdatePolicyHistograms(); |
144 | 193 |
145 const base::win::OSInfo& os_info = *base::win::OSInfo::GetInstance(); | 194 const base::win::OSInfo& os_info = *base::win::OSInfo::GetInstance(); |
146 UMA_HISTOGRAM_ENUMERATION("Windows.GetVersionExVersion", os_info.version(), | 195 UMA_HISTOGRAM_ENUMERATION("Windows.GetVersionExVersion", os_info.version(), |
147 base::win::VERSION_WIN_LAST); | 196 base::win::VERSION_WIN_LAST); |
148 UMA_HISTOGRAM_ENUMERATION("Windows.Kernel32Version", | 197 UMA_HISTOGRAM_ENUMERATION("Windows.Kernel32Version", |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 #if defined(OS_MACOSX) | 397 #if defined(OS_MACOSX) |
349 RecordMacMetrics(); | 398 RecordMacMetrics(); |
350 #endif // defined(OS_MACOSX) | 399 #endif // defined(OS_MACOSX) |
351 | 400 |
352 const int kStartupMetricsGatheringDelaySeconds = 45; | 401 const int kStartupMetricsGatheringDelaySeconds = 45; |
353 content::BrowserThread::GetBlockingPool()->PostDelayedTask( | 402 content::BrowserThread::GetBlockingPool()->PostDelayedTask( |
354 FROM_HERE, | 403 FROM_HERE, |
355 base::Bind(&RecordStartupMetricsOnBlockingPool), | 404 base::Bind(&RecordStartupMetricsOnBlockingPool), |
356 base::TimeDelta::FromSeconds(kStartupMetricsGatheringDelaySeconds)); | 405 base::TimeDelta::FromSeconds(kStartupMetricsGatheringDelaySeconds)); |
357 | 406 |
407 #if defined(OS_WIN) | |
408 // Initiate third party module gathering on the UI thread. The actual | |
409 // reporting will end up happening in the blocking pool. | |
410 content::BrowserThread::PostDelayedTask( | |
411 content::BrowserThread::UI, | |
412 FROM_HERE, | |
413 base::Bind(&InitiateThirdPartyModuleMetricsOnUIThread), | |
414 base::TimeDelta::FromSeconds(kStartupMetricsGatheringDelaySeconds)); | |
415 #endif // defined(OS_WIN) | |
416 | |
358 display_count_ = display::Screen::GetScreen()->GetNumDisplays(); | 417 display_count_ = display::Screen::GetScreen()->GetNumDisplays(); |
359 UMA_HISTOGRAM_COUNTS_100("Hardware.Display.Count.OnStartup", display_count_); | 418 UMA_HISTOGRAM_COUNTS_100("Hardware.Display.Count.OnStartup", display_count_); |
360 display::Screen::GetScreen()->AddObserver(this); | 419 display::Screen::GetScreen()->AddObserver(this); |
361 is_screen_observer_ = true; | 420 is_screen_observer_ = true; |
362 | 421 |
363 #if !defined(OS_ANDROID) | 422 #if !defined(OS_ANDROID) |
364 FirstWebContentsProfiler::Start(); | 423 FirstWebContentsProfiler::Start(); |
365 #endif // !defined(OS_ANDROID) | 424 #endif // !defined(OS_ANDROID) |
366 } | 425 } |
367 | 426 |
(...skipping 19 matching lines...) Expand all Loading... | |
387 } | 446 } |
388 } | 447 } |
389 | 448 |
390 namespace chrome { | 449 namespace chrome { |
391 | 450 |
392 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { | 451 void AddMetricsExtraParts(ChromeBrowserMainParts* main_parts) { |
393 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); | 452 main_parts->AddParts(new ChromeBrowserMainExtraPartsMetrics()); |
394 } | 453 } |
395 | 454 |
396 } // namespace chrome | 455 } // namespace chrome |
OLD | NEW |