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" | |
50 #include "device/bluetooth/bluetooth_device.h" | |
47 #include "googleurl/src/gurl.h" | 51 #include "googleurl/src/gurl.h" |
48 #include "ui/gfx/screen.h" | 52 #include "ui/gfx/screen.h" |
49 #include "webkit/plugins/webplugininfo.h" | 53 #include "webkit/plugins/webplugininfo.h" |
50 | 54 |
51 #if defined(OS_ANDROID) | 55 #if defined(OS_ANDROID) |
52 #include "base/android/build_info.h" | 56 #include "base/android/build_info.h" |
53 #endif | 57 #endif |
54 | 58 |
55 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) | 59 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) |
56 | 60 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
296 reinterpret_cast<LPARAM>(&si))) { | 300 reinterpret_cast<LPARAM>(&si))) { |
297 hardware->set_max_dpi_x(si.max_dpi_x); | 301 hardware->set_max_dpi_x(si.max_dpi_x); |
298 hardware->set_max_dpi_y(si.max_dpi_y); | 302 hardware->set_max_dpi_y(si.max_dpi_y); |
299 } | 303 } |
300 ReleaseDC(GetDesktopWindow(), desktop_dc); | 304 ReleaseDC(GetDesktopWindow(), desktop_dc); |
301 } | 305 } |
302 } | 306 } |
303 | 307 |
304 #endif // defined(OS_WIN) | 308 #endif // defined(OS_WIN) |
305 | 309 |
310 #if defined(OS_CHROMEOS) | |
311 SystemProfileProto::Hardware::Bluetooth::PairedDevice::Type | |
312 AsBluetoothDeviceType( | |
313 enum device::BluetoothDevice::DeviceType device_type) { | |
314 switch (device_type) { | |
315 case device::BluetoothDevice::DEVICE_UNKNOWN: | |
316 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
317 DEVICE_UNKNOWN; | |
318 case device::BluetoothDevice::DEVICE_COMPUTER: | |
319 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
320 DEVICE_COMPUTER; | |
321 case device::BluetoothDevice::DEVICE_PHONE: | |
322 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
323 DEVICE_PHONE; | |
324 case device::BluetoothDevice::DEVICE_MODEM: | |
325 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
326 DEVICE_MODEM; | |
327 case device::BluetoothDevice::DEVICE_AUDIO: | |
328 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
329 DEVICE_AUDIO; | |
330 case device::BluetoothDevice::DEVICE_CAR_AUDIO: | |
331 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
332 DEVICE_CAR_AUDIO; | |
333 case device::BluetoothDevice::DEVICE_VIDEO: | |
334 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
335 DEVICE_VIDEO; | |
336 case device::BluetoothDevice::DEVICE_PERIPHERAL: | |
337 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
338 DEVICE_PERIPHERAL; | |
339 case device::BluetoothDevice::DEVICE_JOYSTICK: | |
340 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
341 DEVICE_JOYSTICK; | |
342 case device::BluetoothDevice::DEVICE_GAMEPAD: | |
343 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
344 DEVICE_GAMEPAD; | |
345 case device::BluetoothDevice::DEVICE_KEYBOARD: | |
346 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
347 DEVICE_KEYBOARD; | |
348 case device::BluetoothDevice::DEVICE_MOUSE: | |
349 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
350 DEVICE_MOUSE; | |
351 case device::BluetoothDevice::DEVICE_TABLET: | |
352 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
353 DEVICE_TABLET; | |
354 case device::BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO: | |
355 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
356 DEVICE_KEYBOARD_MOUSE_COMBO; | |
357 } | |
358 | |
359 NOTREACHED(); | |
360 return SystemProfileProto::Hardware::Bluetooth::PairedDevice:: | |
361 DEVICE_UNKNOWN; | |
362 } | |
363 #endif // defined(OS_CHROMEOS) | |
364 | |
306 } // namespace | 365 } // namespace |
307 | 366 |
308 GoogleUpdateMetrics::GoogleUpdateMetrics() : is_system_install(false) {} | 367 GoogleUpdateMetrics::GoogleUpdateMetrics() : is_system_install(false) {} |
309 | 368 |
310 GoogleUpdateMetrics::~GoogleUpdateMetrics() {} | 369 GoogleUpdateMetrics::~GoogleUpdateMetrics() {} |
311 | 370 |
312 static base::LazyInstance<std::string>::Leaky | 371 static base::LazyInstance<std::string>::Leaky |
313 g_version_extension = LAZY_INSTANCE_INITIALIZER; | 372 g_version_extension = LAZY_INSTANCE_INITIALIZER; |
314 | 373 |
315 MetricsLog::MetricsLog(const std::string& client_id, int session_id) | 374 MetricsLog::MetricsLog(const std::string& client_id, int session_id) |
316 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {} | 375 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()), |
376 weak_ptr_factory_(this) {} | |
317 | 377 |
318 MetricsLog::~MetricsLog() {} | 378 MetricsLog::~MetricsLog() {} |
319 | 379 |
320 // static | 380 // static |
321 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { | 381 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { |
322 registry->RegisterListPref(prefs::kStabilityPluginStats); | 382 registry->RegisterListPref(prefs::kStabilityPluginStats); |
323 } | 383 } |
324 | 384 |
325 // static | 385 // static |
326 int64 MetricsLog::GetIncrementalUptime(PrefService* pref) { | 386 int64 MetricsLog::GetIncrementalUptime(PrefService* pref) { |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
870 WritePluginList(plugin_list, write_as_xml); | 930 WritePluginList(plugin_list, write_as_xml); |
871 | 931 |
872 std::vector<ActiveGroupId> field_trial_ids; | 932 std::vector<ActiveGroupId> field_trial_ids; |
873 GetFieldTrialIds(&field_trial_ids); | 933 GetFieldTrialIds(&field_trial_ids); |
874 WriteFieldTrials(field_trial_ids, system_profile); | 934 WriteFieldTrials(field_trial_ids, system_profile); |
875 | 935 |
876 #if defined(OS_CHROMEOS) | 936 #if defined(OS_CHROMEOS) |
877 PerfDataProto perf_data_proto; | 937 PerfDataProto perf_data_proto; |
878 if (perf_provider_.GetPerfData(&perf_data_proto)) | 938 if (perf_provider_.GetPerfData(&perf_data_proto)) |
879 uma_proto()->add_perf_data()->Swap(&perf_data_proto); | 939 uma_proto()->add_perf_data()->Swap(&perf_data_proto); |
940 | |
941 device::BluetoothAdapterFactory::GetAdapter( | |
942 base::Bind(&MetricsLog::WriteBluetoothProto, | |
943 weak_ptr_factory_.GetWeakPtr(), | |
944 hardware)); | |
Ilya Sherman
2013/04/23 00:09:43
Sorry, I should have caught this in the previous r
keybuk
2013/04/23 00:41:42
On Chrome OS it's guaranteed to be 100% synchronou
| |
880 #endif | 945 #endif |
881 } | 946 } |
882 | 947 |
883 void MetricsLog::RecordProfilerData( | 948 void MetricsLog::RecordProfilerData( |
884 const tracked_objects::ProcessDataSnapshot& process_data, | 949 const tracked_objects::ProcessDataSnapshot& process_data, |
885 int process_type) { | 950 int process_type) { |
886 DCHECK(!locked()); | 951 DCHECK(!locked()); |
887 | 952 |
888 if (tracked_objects::GetTimeSourceType() != | 953 if (tracked_objects::GetTimeSourceType() != |
889 tracked_objects::TIME_SOURCE_TYPE_WALL_TIME) { | 954 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, | 1145 ProductDataToProto(google_update_metrics.google_update_data, |
1081 google_update->mutable_google_update_status()); | 1146 google_update->mutable_google_update_status()); |
1082 } | 1147 } |
1083 | 1148 |
1084 if (!google_update_metrics.product_data.version.empty()) { | 1149 if (!google_update_metrics.product_data.version.empty()) { |
1085 ProductDataToProto(google_update_metrics.product_data, | 1150 ProductDataToProto(google_update_metrics.product_data, |
1086 google_update->mutable_client_status()); | 1151 google_update->mutable_client_status()); |
1087 } | 1152 } |
1088 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) | 1153 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) |
1089 } | 1154 } |
1155 | |
1156 void MetricsLog::WriteBluetoothProto( | |
1157 SystemProfileProto::Hardware* hardware, | |
1158 scoped_refptr<device::BluetoothAdapter> adapter) { | |
1159 #if defined(OS_CHROMEOS) | |
1160 SystemProfileProto::Hardware::Bluetooth* bluetooth = | |
1161 hardware->mutable_bluetooth(); | |
1162 | |
1163 bluetooth->set_is_present(adapter->IsPresent()); | |
1164 bluetooth->set_is_enabled(adapter->IsPowered()); | |
1165 | |
1166 device::BluetoothAdapter::DeviceList devices = adapter->GetDevices(); | |
1167 for (device::BluetoothAdapter::DeviceList::iterator iter = | |
1168 devices.begin(); iter != devices.end(); ++iter) { | |
1169 SystemProfileProto::Hardware::Bluetooth::PairedDevice* paired_device = | |
1170 bluetooth->add_paired_device(); | |
1171 | |
1172 device::BluetoothDevice* device = *iter; | |
1173 paired_device->set_bluetooth_class(device->GetBluetoothClass()); | |
1174 paired_device->set_type(AsBluetoothDeviceType(device->GetDeviceType())); | |
1175 | |
1176 // address is xx:xx:xx:xx:xx:xx, extract the first three components and | |
1177 // pack into a uint32 | |
1178 std::string address = device->GetAddress(); | |
1179 if (address.length() > 9 && | |
1180 address[2] == ':' && address[5] == ':' && address[8] == ':') { | |
1181 uint32 vendor_prefix = 0; | |
1182 | |
1183 uint64 component = 0; | |
1184 base::HexStringToUInt64(address.substr(0, 2), &component); | |
1185 vendor_prefix |= component << 16; | |
1186 | |
1187 component = 0; | |
1188 base::HexStringToUInt64(address.substr(3, 2), &component); | |
1189 vendor_prefix |= component << 8; | |
1190 | |
1191 component = 0; | |
1192 base::HexStringToUInt64(address.substr(6, 2), &component); | |
1193 vendor_prefix |= component; | |
Ilya Sherman
2013/04/23 00:09:43
Rather than calling HexStringToUInt64 three times,
keybuk
2013/04/23 00:41:42
Done.
| |
1194 | |
1195 paired_device->set_vendor_prefix(vendor_prefix); | |
1196 } | |
1197 | |
1198 paired_device->set_vendor_id(device->GetVendorID()); | |
1199 paired_device->set_product_id(device->GetProductID()); | |
1200 paired_device->set_device_id(device->GetDeviceID()); | |
1201 } | |
1202 #endif // defined(OS_CHROMEOS) | |
1203 } | |
OLD | NEW |