| 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/chromeos_metrics_provider.h" | 5 #include "chrome/browser/metrics/chromeos_metrics_provider.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/chromeos/login/users/user_manager.h" | 13 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 14 #include "chrome/browser/metrics/metrics_service.h" | 14 #include "chrome/browser/metrics/metrics_service.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" | 16 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" |
| 17 #include "device/bluetooth/bluetooth_adapter.h" | 17 #include "device/bluetooth/bluetooth_adapter.h" |
| 18 #include "device/bluetooth/bluetooth_adapter_factory.h" | 18 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 19 #include "device/bluetooth/bluetooth_device.h" | 19 #include "device/bluetooth/bluetooth_device.h" |
| 20 #include "ui/events/event_utils.h" | 20 #include "ui/events/event_utils.h" |
| 21 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
| 22 | 22 |
| 23 #if defined(USE_X11) | 23 #if defined(USE_X11) |
| 24 #include "ui/events/x/touch_factory_x11.h" | 24 #include "ui/events/x/touch_factory_x11.h" |
| 25 #endif // defined(USE_X11) | 25 #endif // defined(USE_X11) |
| 26 | 26 |
| 27 using metrics::ChromeUserMetricsExtension; | 27 using metrics::ChromeUserMetricsExtension; |
| 28 using metrics::PerfDataProto; | 28 using metrics::SampledProfile; |
| 29 using metrics::SystemProfileProto; | 29 using metrics::SystemProfileProto; |
| 30 typedef SystemProfileProto::Hardware::Bluetooth::PairedDevice PairedDevice; | 30 typedef SystemProfileProto::Hardware::Bluetooth::PairedDevice PairedDevice; |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 PairedDevice::Type AsBluetoothDeviceType( | 34 PairedDevice::Type AsBluetoothDeviceType( |
| 35 device::BluetoothDevice::DeviceType device_type) { | 35 device::BluetoothDevice::DeviceType device_type) { |
| 36 switch (device_type) { | 36 switch (device_type) { |
| 37 case device::BluetoothDevice::DEVICE_UNKNOWN: | 37 case device::BluetoothDevice::DEVICE_UNKNOWN: |
| 38 return PairedDevice::DEVICE_UNKNOWN; | 38 return PairedDevice::DEVICE_UNKNOWN; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 count = pref->GetInteger(prefs::kStabilitySystemUncleanShutdownCount); | 167 count = pref->GetInteger(prefs::kStabilitySystemUncleanShutdownCount); |
| 168 if (count) { | 168 if (count) { |
| 169 stability_proto->set_unclean_system_shutdown_count(count); | 169 stability_proto->set_unclean_system_shutdown_count(count); |
| 170 pref->SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 0); | 170 pref->SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 0); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 void ChromeOSMetricsProvider::ProvideGeneralMetrics( | 174 void ChromeOSMetricsProvider::ProvideGeneralMetrics( |
| 175 metrics::ChromeUserMetricsExtension* uma_proto) { | 175 metrics::ChromeUserMetricsExtension* uma_proto) { |
| 176 std::vector<PerfDataProto> perf_data; | 176 std::vector<SampledProfile> sampled_profiles; |
| 177 if (perf_provider_.GetPerfData(&perf_data)) { | 177 if (perf_provider_.GetSampledProfiles(&sampled_profiles)) { |
| 178 for (std::vector<PerfDataProto>::iterator iter = perf_data.begin(); | 178 for (std::vector<SampledProfile>::iterator iter = sampled_profiles.begin(); |
| 179 iter != perf_data.end(); | 179 iter != sampled_profiles.end(); |
| 180 ++iter) { | 180 ++iter) { |
| 181 uma_proto->add_perf_data()->Swap(&(*iter)); | 181 uma_proto->add_sampled_profile()->Swap(&(*iter)); |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 void ChromeOSMetricsProvider::WriteBluetoothProto( | 186 void ChromeOSMetricsProvider::WriteBluetoothProto( |
| 187 metrics::SystemProfileProto* system_profile_proto) { | 187 metrics::SystemProfileProto* system_profile_proto) { |
| 188 metrics::SystemProfileProto::Hardware* hardware = | 188 metrics::SystemProfileProto::Hardware* hardware = |
| 189 system_profile_proto->mutable_hardware(); | 189 system_profile_proto->mutable_hardware(); |
| 190 | 190 |
| 191 // BluetoothAdapterFactory::GetAdapter is synchronous on Chrome OS; if that | 191 // BluetoothAdapterFactory::GetAdapter is synchronous on Chrome OS; if that |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 257 } |
| 258 | 258 |
| 259 system_profile_proto->set_multi_profile_user_count(user_count); | 259 system_profile_proto->set_multi_profile_user_count(user_count); |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 | 262 |
| 263 void ChromeOSMetricsProvider::SetBluetoothAdapter( | 263 void ChromeOSMetricsProvider::SetBluetoothAdapter( |
| 264 scoped_refptr<device::BluetoothAdapter> adapter) { | 264 scoped_refptr<device::BluetoothAdapter> adapter) { |
| 265 adapter_ = adapter; | 265 adapter_ = adapter; |
| 266 } | 266 } |
| OLD | NEW |