Index: chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc |
diff --git a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc |
index 4c343f28538f32e08faf7f66bf642ef99bab2c7c..9602e4a3abefbcb2ba2adeca1e1436f30152e5ee 100644 |
--- a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc |
+++ b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc |
@@ -19,6 +19,7 @@ |
#include "chrome/browser/about_flags.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/chrome_browser_main.h" |
+#include "chrome/browser/enumerate_modules_model_win.h" |
#include "chrome/browser/mac/bluetooth_utility.h" |
#include "chrome/browser/shell_integration.h" |
#include "components/flags_ui/pref_service_flags_storage.h" |
@@ -136,6 +137,54 @@ void RecordMicroArchitectureStats() { |
base::SysInfo::NumberOfProcessors()); |
} |
+#if defined(OS_WIN) |
+// Gathers third party module information. |
+void GatherThirdPartyModuleMetricsOnBlockingPool() { |
+ // Get the module list. If it's not yet ready post a delayed task to try again |
+ // in a bit. |
+ auto modules = EnumerateModulesModel::GetInstance(); |
+ std::unique_ptr<base::ListValue> list(modules->GetModuleList()); |
+ if (list.get() == nullptr) { |
+ content::BrowserThread::GetBlockingPool()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&GatherThirdPartyModuleMetricsOnBlockingPool), |
+ base::TimeDelta::FromSeconds(1)); |
grt (UTC plus 2)
2016/06/06 01:38:57
please do something better than polling for the re
|
+ return; |
+ } |
+ |
+ // Process the module list. |
+ size_t microsoft_modules = 0; |
+ for (size_t i = 0; i < list->GetSize(); ++i) { |
+ base::DictionaryValue* module = nullptr; |
+ 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
|
+ |
+ base::string16 signer; |
+ CHECK(module->GetString("digital_signer", &signer)); |
+ if (signer.find(L"Microsoft") != signer.npos) |
+ ++microsoft_modules; |
+ } |
+ |
+ // Report the total number of modules present. |
+ UMA_HISTOGRAM_CUSTOM_COUNTS("ThirdPartyModules.Modules.Microsoft", |
+ microsoft_modules, 1, 500, 50); |
+ UMA_HISTOGRAM_CUSTOM_COUNTS("ThirdPartyModules.Modules.Total", |
+ list->GetSize(), 1, 500, 50); |
+} |
+ |
+// Initiates recording of third party modules. The actual module enumeration |
+// ends up being performed on the file thread, while the results are eventually |
+// retrieved and processed on the blocking pool. |
+void InitiateThirdPartyModuleMetricsOnUIThread() { |
+ // The module scanning wants to be kicked off from the UI thread. |
+ auto modules = EnumerateModulesModel::GetInstance(); |
+ modules->ScanNow(); |
+ content::BrowserThread::GetBlockingPool()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&GatherThirdPartyModuleMetricsOnBlockingPool), |
+ base::TimeDelta::FromSeconds(1)); |
+} |
+#endif // defined(OS_WIN) |
+ |
// Called on the blocking pool some time after startup to avoid slowing down |
// startup with metrics that aren't trivial to compute. |
void RecordStartupMetricsOnBlockingPool() { |
@@ -355,6 +404,16 @@ void ChromeBrowserMainExtraPartsMetrics::PostBrowserStart() { |
base::Bind(&RecordStartupMetricsOnBlockingPool), |
base::TimeDelta::FromSeconds(kStartupMetricsGatheringDelaySeconds)); |
+#if defined(OS_WIN) |
+ // Initiate third party module gathering on the UI thread. The actual |
+ // reporting will end up happening in the blocking pool. |
+ content::BrowserThread::PostDelayedTask( |
+ content::BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&InitiateThirdPartyModuleMetricsOnUIThread), |
+ base::TimeDelta::FromSeconds(kStartupMetricsGatheringDelaySeconds)); |
+#endif // defined(OS_WIN) |
+ |
display_count_ = display::Screen::GetScreen()->GetNumDisplays(); |
UMA_HISTOGRAM_COUNTS_100("Hardware.Display.Count.OnStartup", display_count_); |
display::Screen::GetScreen()->AddObserver(this); |