OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_chromeos.h" | 5 #include "chrome/browser/metrics/metrics_log_chromeos.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/chromeos/login/user_manager.h" | 11 #include "chrome/browser/chromeos/login/user_manager.h" |
12 #include "chrome/common/metrics/proto/chrome_user_metrics_extension.pb.h" | 12 #include "chrome/common/metrics/proto/chrome_user_metrics_extension.pb.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "device/bluetooth/bluetooth_adapter.h" | 14 #include "device/bluetooth/bluetooth_adapter.h" |
15 #include "device/bluetooth/bluetooth_adapter_factory.h" | 15 #include "device/bluetooth/bluetooth_adapter_factory.h" |
16 #include "device/bluetooth/bluetooth_device.h" | 16 #include "device/bluetooth/bluetooth_device.h" |
| 17 #include "ui/events/event_utils.h" |
| 18 #include "ui/events/x/touch_factory_x11.h" |
| 19 #include "ui/gfx/screen.h" |
17 | 20 |
18 using metrics::ChromeUserMetricsExtension; | 21 using metrics::ChromeUserMetricsExtension; |
19 using metrics::PerfDataProto; | 22 using metrics::PerfDataProto; |
20 using metrics::SystemProfileProto; | 23 using metrics::SystemProfileProto; |
21 typedef SystemProfileProto::Hardware::Bluetooth::PairedDevice PairedDevice; | 24 typedef SystemProfileProto::Hardware::Bluetooth::PairedDevice PairedDevice; |
22 | 25 |
| 26 namespace { |
| 27 |
23 PairedDevice::Type AsBluetoothDeviceType( | 28 PairedDevice::Type AsBluetoothDeviceType( |
24 device::BluetoothDevice::DeviceType device_type) { | 29 device::BluetoothDevice::DeviceType device_type) { |
25 switch (device_type) { | 30 switch (device_type) { |
26 case device::BluetoothDevice::DEVICE_UNKNOWN: | 31 case device::BluetoothDevice::DEVICE_UNKNOWN: |
27 return PairedDevice::DEVICE_UNKNOWN; | 32 return PairedDevice::DEVICE_UNKNOWN; |
28 case device::BluetoothDevice::DEVICE_COMPUTER: | 33 case device::BluetoothDevice::DEVICE_COMPUTER: |
29 return PairedDevice::DEVICE_COMPUTER; | 34 return PairedDevice::DEVICE_COMPUTER; |
30 case device::BluetoothDevice::DEVICE_PHONE: | 35 case device::BluetoothDevice::DEVICE_PHONE: |
31 return PairedDevice::DEVICE_PHONE; | 36 return PairedDevice::DEVICE_PHONE; |
32 case device::BluetoothDevice::DEVICE_MODEM: | 37 case device::BluetoothDevice::DEVICE_MODEM: |
(...skipping 17 matching lines...) Expand all Loading... |
50 case device::BluetoothDevice::DEVICE_TABLET: | 55 case device::BluetoothDevice::DEVICE_TABLET: |
51 return PairedDevice::DEVICE_TABLET; | 56 return PairedDevice::DEVICE_TABLET; |
52 case device::BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO: | 57 case device::BluetoothDevice::DEVICE_KEYBOARD_MOUSE_COMBO: |
53 return PairedDevice::DEVICE_KEYBOARD_MOUSE_COMBO; | 58 return PairedDevice::DEVICE_KEYBOARD_MOUSE_COMBO; |
54 } | 59 } |
55 | 60 |
56 NOTREACHED(); | 61 NOTREACHED(); |
57 return PairedDevice::DEVICE_UNKNOWN; | 62 return PairedDevice::DEVICE_UNKNOWN; |
58 } | 63 } |
59 | 64 |
| 65 void WriteExternalTouchscreensProto(SystemProfileProto::Hardware* hardware) { |
| 66 std::set<std::pair<int, int> > touchscreen_ids = |
| 67 ui::TouchFactory::GetInstance()->GetTouchscreenIds(); |
| 68 for (std::set<std::pair<int, int> >::iterator it = touchscreen_ids.begin(); |
| 69 it != touchscreen_ids.end(); |
| 70 ++it) { |
| 71 SystemProfileProto::Hardware::TouchScreen* touchscreen = |
| 72 hardware->add_external_touchscreen(); |
| 73 touchscreen->set_vendor_id(it->first); |
| 74 touchscreen->set_product_id(it->second); |
| 75 } |
| 76 } |
| 77 |
| 78 } // namespace |
| 79 |
60 MetricsLogChromeOS::~MetricsLogChromeOS() { | 80 MetricsLogChromeOS::~MetricsLogChromeOS() { |
61 } | 81 } |
62 | 82 |
63 MetricsLogChromeOS::MetricsLogChromeOS(ChromeUserMetricsExtension* uma_proto) | 83 MetricsLogChromeOS::MetricsLogChromeOS(ChromeUserMetricsExtension* uma_proto) |
64 : uma_proto_(uma_proto) { | 84 : uma_proto_(uma_proto) { |
65 UpdateMultiProfileUserCount(); | 85 UpdateMultiProfileUserCount(); |
66 } | 86 } |
67 | 87 |
68 void MetricsLogChromeOS::LogChromeOSMetrics() { | 88 void MetricsLogChromeOS::LogChromeOSMetrics() { |
69 PerfDataProto perf_data_proto; | 89 PerfDataProto perf_data_proto; |
70 if (perf_provider_.GetPerfData(&perf_data_proto)) | 90 if (perf_provider_.GetPerfData(&perf_data_proto)) |
71 uma_proto_->add_perf_data()->Swap(&perf_data_proto); | 91 uma_proto_->add_perf_data()->Swap(&perf_data_proto); |
72 | 92 |
73 WriteBluetoothProto(); | 93 WriteBluetoothProto(); |
74 UpdateMultiProfileUserCount(); | 94 UpdateMultiProfileUserCount(); |
| 95 |
| 96 SystemProfileProto::Hardware* hardware = |
| 97 uma_proto_->mutable_system_profile()->mutable_hardware(); |
| 98 gfx::Display::TouchSupport has_touch = ui::GetInternalDisplayTouchSupport(); |
| 99 if (has_touch == gfx::Display::TOUCH_SUPPORT_AVAILABLE) |
| 100 hardware->set_internal_display_supports_touch(true); |
| 101 else if (has_touch == gfx::Display::TOUCH_SUPPORT_UNAVAILABLE) |
| 102 hardware->set_internal_display_supports_touch(false); |
| 103 WriteExternalTouchscreensProto(hardware); |
75 } | 104 } |
76 | 105 |
77 void MetricsLogChromeOS::WriteRealtimeStabilityAttributes(PrefService* pref) { | 106 void MetricsLogChromeOS::WriteRealtimeStabilityAttributes(PrefService* pref) { |
78 SystemProfileProto::Stability* stability = | 107 SystemProfileProto::Stability* stability = |
79 uma_proto_->mutable_system_profile()->mutable_stability(); | 108 uma_proto_->mutable_system_profile()->mutable_stability(); |
80 | 109 |
81 int count = pref->GetInteger(prefs::kStabilityOtherUserCrashCount); | 110 int count = pref->GetInteger(prefs::kStabilityOtherUserCrashCount); |
82 if (count) { | 111 if (count) { |
83 stability->set_other_user_crash_count(count); | 112 stability->set_other_user_crash_count(count); |
84 pref->SetInteger(prefs::kStabilityOtherUserCrashCount, 0); | 113 pref->SetInteger(prefs::kStabilityOtherUserCrashCount, 0); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 188 } |
160 | 189 |
161 system_profile->set_multi_profile_user_count(user_count); | 190 system_profile->set_multi_profile_user_count(user_count); |
162 } | 191 } |
163 } | 192 } |
164 | 193 |
165 void MetricsLogChromeOS::SetBluetoothAdapter( | 194 void MetricsLogChromeOS::SetBluetoothAdapter( |
166 scoped_refptr<device::BluetoothAdapter> adapter) { | 195 scoped_refptr<device::BluetoothAdapter> adapter) { |
167 adapter_ = adapter; | 196 adapter_ = adapter; |
168 } | 197 } |
OLD | NEW |