OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/metrics_log.h" | 5 #include "chrome/browser/metrics/metrics_log.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/bind.h" | |
12 #include "base/file_util.h" | 13 #include "base/file_util.h" |
13 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/perftimer.h" | 16 #include "base/perftimer.h" |
16 #include "base/prefs/pref_registry_simple.h" | 17 #include "base/prefs/pref_registry_simple.h" |
17 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
18 #include "base/profiler/alternate_timer.h" | 19 #include "base/profiler/alternate_timer.h" |
19 #include "base/string_util.h" | 20 #include "base/string_util.h" |
20 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
21 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
37 #include "chrome/common/logging_chrome.h" | 38 #include "chrome/common/logging_chrome.h" |
38 #include "chrome/common/metrics/proto/omnibox_event.pb.h" | 39 #include "chrome/common/metrics/proto/omnibox_event.pb.h" |
39 #include "chrome/common/metrics/proto/profiler_event.pb.h" | 40 #include "chrome/common/metrics/proto/profiler_event.pb.h" |
40 #include "chrome/common/metrics/proto/system_profile.pb.h" | 41 #include "chrome/common/metrics/proto/system_profile.pb.h" |
41 #include "chrome/common/metrics/variations/variations_util.h" | 42 #include "chrome/common/metrics/variations/variations_util.h" |
42 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
43 #include "chrome/installer/util/google_update_settings.h" | 44 #include "chrome/installer/util/google_update_settings.h" |
44 #include "content/public/browser/gpu_data_manager.h" | 45 #include "content/public/browser/gpu_data_manager.h" |
45 #include "content/public/common/content_client.h" | 46 #include "content/public/common/content_client.h" |
46 #include "content/public/common/gpu_info.h" | 47 #include "content/public/common/gpu_info.h" |
48 #include "device/bluetooth/bluetooth_adapter.h" | |
49 #include "device/bluetooth/bluetooth_adapter_factory.h" | |
47 #include "googleurl/src/gurl.h" | 50 #include "googleurl/src/gurl.h" |
48 #include "ui/gfx/screen.h" | 51 #include "ui/gfx/screen.h" |
49 #include "webkit/plugins/webplugininfo.h" | 52 #include "webkit/plugins/webplugininfo.h" |
50 | 53 |
51 #if defined(OS_ANDROID) | 54 #if defined(OS_ANDROID) |
52 #include "base/android/build_info.h" | 55 #include "base/android/build_info.h" |
53 #endif | 56 #endif |
54 | 57 |
55 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) | 58 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) |
56 | 59 |
57 #if defined(OS_WIN) | 60 #if defined(OS_WIN) |
58 #include "base/win/metro.h" | 61 #include "base/win/metro.h" |
59 | 62 |
60 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 63 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
61 extern "C" IMAGE_DOS_HEADER __ImageBase; | 64 extern "C" IMAGE_DOS_HEADER __ImageBase; |
62 #endif | 65 #endif |
63 | 66 |
67 #if defined(OS_CHROMEOS) | |
68 #include "device/bluetooth/bluetooth_device_experimental_chromeos.h" | |
69 #endif | |
70 | |
64 using content::GpuDataManager; | 71 using content::GpuDataManager; |
65 using metrics::OmniboxEventProto; | 72 using metrics::OmniboxEventProto; |
66 using metrics::PerfDataProto; | 73 using metrics::PerfDataProto; |
67 using metrics::ProfilerEventProto; | 74 using metrics::ProfilerEventProto; |
68 using metrics::SystemProfileProto; | 75 using metrics::SystemProfileProto; |
69 using tracked_objects::ProcessDataSnapshot; | 76 using tracked_objects::ProcessDataSnapshot; |
70 typedef chrome_variations::ActiveGroupId ActiveGroupId; | 77 typedef chrome_variations::ActiveGroupId ActiveGroupId; |
71 typedef SystemProfileProto::GoogleUpdate::ProductInfo ProductInfo; | 78 typedef SystemProfileProto::GoogleUpdate::ProductInfo ProductInfo; |
72 | 79 |
73 namespace { | 80 namespace { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 reinterpret_cast<LPARAM>(&si))) { | 303 reinterpret_cast<LPARAM>(&si))) { |
297 hardware->set_max_dpi_x(si.max_dpi_x); | 304 hardware->set_max_dpi_x(si.max_dpi_x); |
298 hardware->set_max_dpi_y(si.max_dpi_y); | 305 hardware->set_max_dpi_y(si.max_dpi_y); |
299 } | 306 } |
300 ReleaseDC(GetDesktopWindow(), desktop_dc); | 307 ReleaseDC(GetDesktopWindow(), desktop_dc); |
301 } | 308 } |
302 } | 309 } |
303 | 310 |
304 #endif // defined(OS_WIN) | 311 #endif // defined(OS_WIN) |
305 | 312 |
313 #if defined(OS_CHROMEOS) | |
314 // Pattern to match USB modaliases from BlueZ. | |
315 const char kUsbModaliasPattern[] = | |
316 "usb:p[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]" | |
Ilya Sherman
2013/04/20 04:54:02
nit: Might help with readability to add a line bre
| |
317 "v[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]" | |
318 "d[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]"; | |
319 | |
320 SystemProfileProto::Bluetooth::PairedDevice::Type AsBluetoothDeviceType( | |
321 enum device::BluetoothDevice::DeviceType device_type) { | |
322 switch (device_type) { | |
323 case device::BluetoothDevice::DEVICE_UNKNOWN: | |
324 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_UNKNOWN; | |
325 case device::BluetoothDevice::DEVICE_COMPUTER: | |
326 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_COMPUTER; | |
327 case device::BluetoothDevice::DEVICE_PHONE: | |
328 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_PHONE; | |
329 case device::BluetoothDevice::DEVICE_MODEM: | |
330 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_MODEM; | |
331 case device::BluetoothDevice::DEVICE_AUDIO: | |
332 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_AUDIO; | |
333 case device::BluetoothDevice::DEVICE_CAR_AUDIO: | |
334 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_CAR_AUDIO; | |
335 case device::BluetoothDevice::DEVICE_VIDEO: | |
336 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_VIDEO; | |
337 case device::BluetoothDevice::DEVICE_PERIPHERAL: | |
338 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_PERIPHERAL; | |
339 case device::BluetoothDevice::DEVICE_JOYSTICK: | |
340 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_JOYSTICK; | |
341 case device::BluetoothDevice::DEVICE_GAMEPAD: | |
342 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_GAMEPAD; | |
343 case device::BluetoothDevice::DEVICE_KEYBOARD: | |
344 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_KEYBOARD; | |
345 case device::BluetoothDevice::DEVICE_MOUSE: | |
346 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_MOUSE; | |
347 case device::BluetoothDevice::DEVICE_TABLET: | |
348 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_TABLET; | |
349 case device::BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO: | |
350 return | |
351 SystemProfileProto::Bluetooth::PairedDevice::DEVICE_KEYBOARD_MOUSE_COMBO; | |
Ilya Sherman
2013/04/20 04:54:02
nit: This indentation is off. Perhaps add a "usin
keybuk
2013/04/22 19:30:51
You can't "using" a class member like that in C++
Ilya Sherman
2013/04/23 00:09:43
How about a typedef, then?
| |
352 default: | |
Ilya Sherman
2013/04/20 04:54:02
nit: Please omit the default case, so that the com
keybuk
2013/04/22 19:30:51
Done.
| |
353 NOTREACHED(); | |
354 return SystemProfileProto::Bluetooth::PairedDevice::DEVICE_UNKNOWN; | |
355 } | |
356 } | |
357 #endif // defined(OS_CHROMEOS) | |
358 | |
306 } // namespace | 359 } // namespace |
307 | 360 |
308 GoogleUpdateMetrics::GoogleUpdateMetrics() : is_system_install(false) {} | 361 GoogleUpdateMetrics::GoogleUpdateMetrics() : is_system_install(false) {} |
309 | 362 |
310 GoogleUpdateMetrics::~GoogleUpdateMetrics() {} | 363 GoogleUpdateMetrics::~GoogleUpdateMetrics() {} |
311 | 364 |
312 static base::LazyInstance<std::string>::Leaky | 365 static base::LazyInstance<std::string>::Leaky |
313 g_version_extension = LAZY_INSTANCE_INITIALIZER; | 366 g_version_extension = LAZY_INSTANCE_INITIALIZER; |
314 | 367 |
315 MetricsLog::MetricsLog(const std::string& client_id, int session_id) | 368 MetricsLog::MetricsLog(const std::string& client_id, int session_id) |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
870 WritePluginList(plugin_list, write_as_xml); | 923 WritePluginList(plugin_list, write_as_xml); |
871 | 924 |
872 std::vector<ActiveGroupId> field_trial_ids; | 925 std::vector<ActiveGroupId> field_trial_ids; |
873 GetFieldTrialIds(&field_trial_ids); | 926 GetFieldTrialIds(&field_trial_ids); |
874 WriteFieldTrials(field_trial_ids, system_profile); | 927 WriteFieldTrials(field_trial_ids, system_profile); |
875 | 928 |
876 #if defined(OS_CHROMEOS) | 929 #if defined(OS_CHROMEOS) |
877 PerfDataProto perf_data_proto; | 930 PerfDataProto perf_data_proto; |
878 if (perf_provider_.GetPerfData(&perf_data_proto)) | 931 if (perf_provider_.GetPerfData(&perf_data_proto)) |
879 uma_proto()->add_perf_data()->Swap(&perf_data_proto); | 932 uma_proto()->add_perf_data()->Swap(&perf_data_proto); |
933 | |
934 device::BluetoothAdapterFactory::GetAdapter( | |
935 base::Bind(&MetricsLog::WriteBluetoothProto, | |
936 base::Unretained(this))); | |
Ilya Sherman
2013/04/20 04:54:02
Why is base::Unretained() safe? That is, what gua
keybuk
2013/04/22 19:30:51
Done.
| |
880 #endif | 937 #endif |
881 } | 938 } |
882 | 939 |
883 void MetricsLog::RecordProfilerData( | 940 void MetricsLog::RecordProfilerData( |
884 const tracked_objects::ProcessDataSnapshot& process_data, | 941 const tracked_objects::ProcessDataSnapshot& process_data, |
885 int process_type) { | 942 int process_type) { |
886 DCHECK(!locked()); | 943 DCHECK(!locked()); |
887 | 944 |
888 if (tracked_objects::GetTimeSourceType() != | 945 if (tracked_objects::GetTimeSourceType() != |
889 tracked_objects::TIME_SOURCE_TYPE_WALL_TIME) { | 946 tracked_objects::TIME_SOURCE_TYPE_WALL_TIME) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1080 ProductDataToProto(google_update_metrics.google_update_data, | 1137 ProductDataToProto(google_update_metrics.google_update_data, |
1081 google_update->mutable_google_update_status()); | 1138 google_update->mutable_google_update_status()); |
1082 } | 1139 } |
1083 | 1140 |
1084 if (!google_update_metrics.product_data.version.empty()) { | 1141 if (!google_update_metrics.product_data.version.empty()) { |
1085 ProductDataToProto(google_update_metrics.product_data, | 1142 ProductDataToProto(google_update_metrics.product_data, |
1086 google_update->mutable_client_status()); | 1143 google_update->mutable_client_status()); |
1087 } | 1144 } |
1088 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) | 1145 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) |
1089 } | 1146 } |
1147 | |
1148 void MetricsLog::WriteBluetoothProto( | |
1149 scoped_refptr<device::BluetoothAdapter> adapter) { | |
1150 #if defined(OS_CHROMEOS) | |
1151 SystemProfileProto::Bluetooth* bluetooth = | |
1152 uma_proto()->mutable_system_profile()->mutable_bluetooth(); | |
1153 | |
1154 bluetooth->set_is_present(adapter->IsPresent()); | |
1155 bluetooth->set_is_enabled(adapter->IsPowered()); | |
1156 | |
1157 device::BluetoothAdapter::DeviceList devices = adapter->GetDevices(); | |
1158 for (device::BluetoothAdapter::DeviceList::iterator iter = | |
1159 devices.begin(); iter != devices.end(); ++iter) { | |
Ilya Sherman
2013/04/20 04:54:02
nit: Indent this line four more spaces, since it's
keybuk
2013/04/22 19:30:51
Done.
| |
1160 SystemProfileProto::Bluetooth::PairedDevice* paired_device = | |
1161 bluetooth->add_paired_device(); | |
1162 | |
1163 chromeos::BluetoothDeviceExperimentalChromeOS* device = | |
1164 static_cast<chromeos::BluetoothDeviceExperimentalChromeOS*>(*iter); | |
Ilya Sherman
2013/04/20 04:54:02
How do you know that this cast is safe? If it's a
keybuk
2013/04/22 19:30:51
Done.
| |
1165 | |
1166 paired_device->set_bluetooth_class(device->GetBluetoothClass()); | |
1167 paired_device->set_type(AsBluetoothDeviceType(device->GetDeviceType())); | |
1168 | |
1169 std::string modalias = device->GetModalias(); | |
1170 if (MatchPattern(modalias, kUsbModaliasPattern)) { | |
Ilya Sherman
2013/04/20 04:54:02
Hmm, is this meant to be a regex pattern match? I
keybuk
2013/04/22 19:30:51
Done.
| |
1171 // usb:vXXXXpXXXXdXXXX | |
1172 uint64 vendor_id = 0, product_id = 0, bcd_device = 0; | |
1173 base::HexStringToUInt64(modalias.substr(5, 4), &vendor_id); | |
1174 base::HexStringToUInt64(modalias.substr(10, 4), &product_id); | |
1175 base::HexStringToUInt64(modalias.substr(15, 4), &bcd_device); | |
1176 | |
1177 paired_device->set_vendor_id(vendor_id); | |
1178 paired_device->set_product_id(product_id); | |
1179 paired_device->set_bcd_device(bcd_device); | |
1180 } | |
1181 } | |
1182 #endif // defined(OS_CHROMEOS) | |
1183 } | |
OLD | NEW |