| 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 "chromeos/system/statistics_provider.h" |
| 16 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" | 17 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" |
| 18 #include "content/public/browser/browser_thread.h" |
| 17 #include "device/bluetooth/bluetooth_adapter.h" | 19 #include "device/bluetooth/bluetooth_adapter.h" |
| 18 #include "device/bluetooth/bluetooth_adapter_factory.h" | 20 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 19 #include "device/bluetooth/bluetooth_device.h" | 21 #include "device/bluetooth/bluetooth_device.h" |
| 20 #include "ui/events/event_utils.h" | 22 #include "ui/events/event_utils.h" |
| 21 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
| 22 | 24 |
| 23 #if defined(USE_X11) | 25 #if defined(USE_X11) |
| 24 #include "ui/events/x/touch_factory_x11.h" | 26 #include "ui/events/x/touch_factory_x11.h" |
| 25 #endif // defined(USE_X11) | 27 #endif // defined(USE_X11) |
| 26 | 28 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 127 |
| 126 void ChromeOSMetricsProvider::OnDidCreateMetricsLog() { | 128 void ChromeOSMetricsProvider::OnDidCreateMetricsLog() { |
| 127 registered_user_count_at_log_initialization_ = false; | 129 registered_user_count_at_log_initialization_ = false; |
| 128 if (chromeos::UserManager::IsInitialized()) { | 130 if (chromeos::UserManager::IsInitialized()) { |
| 129 registered_user_count_at_log_initialization_ = true; | 131 registered_user_count_at_log_initialization_ = true; |
| 130 user_count_at_log_initialization_ = | 132 user_count_at_log_initialization_ = |
| 131 chromeos::UserManager::Get()->GetLoggedInUsers().size(); | 133 chromeos::UserManager::Get()->GetLoggedInUsers().size(); |
| 132 } | 134 } |
| 133 } | 135 } |
| 134 | 136 |
| 137 void ChromeOSMetricsProvider::InitTaskGetHardwareClass( |
| 138 base::MessageLoopProxy* target_loop, |
| 139 const base::Closure& callback) { |
| 140 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 141 |
| 142 chromeos::system::StatisticsProvider::GetInstance()->GetMachineStatistic( |
| 143 "hardware_class", &hardware_class_); |
| 144 |
| 145 target_loop->PostTask(FROM_HERE, callback); |
| 146 } |
| 147 |
| 135 void ChromeOSMetricsProvider::ProvideSystemProfileMetrics( | 148 void ChromeOSMetricsProvider::ProvideSystemProfileMetrics( |
| 136 metrics::SystemProfileProto* system_profile_proto) { | 149 metrics::SystemProfileProto* system_profile_proto) { |
| 137 std::vector<PerfDataProto> perf_data; | 150 std::vector<PerfDataProto> perf_data; |
| 138 if (perf_provider_.GetPerfData(&perf_data)) { | 151 if (perf_provider_.GetPerfData(&perf_data)) { |
| 139 for (std::vector<PerfDataProto>::iterator iter = perf_data.begin(); | 152 for (std::vector<PerfDataProto>::iterator iter = perf_data.begin(); |
| 140 iter != perf_data.end(); | 153 iter != perf_data.end(); |
| 141 ++iter) { | 154 ++iter) { |
| 142 uma_proto_->add_perf_data()->Swap(&(*iter)); | 155 uma_proto_->add_perf_data()->Swap(&(*iter)); |
| 143 } | 156 } |
| 144 } | 157 } |
| 145 | 158 |
| 146 WriteBluetoothProto(system_profile_proto); | 159 WriteBluetoothProto(system_profile_proto); |
| 147 UpdateMultiProfileUserCount(system_profile_proto); | 160 UpdateMultiProfileUserCount(system_profile_proto); |
| 148 | 161 |
| 149 metrics::SystemProfileProto::Hardware* hardware = | 162 metrics::SystemProfileProto::Hardware* hardware = |
| 150 system_profile_proto->mutable_hardware(); | 163 system_profile_proto->mutable_hardware(); |
| 164 hardware->set_hardware_class(hardware_class_); |
| 151 gfx::Display::TouchSupport has_touch = ui::GetInternalDisplayTouchSupport(); | 165 gfx::Display::TouchSupport has_touch = ui::GetInternalDisplayTouchSupport(); |
| 152 if (has_touch == gfx::Display::TOUCH_SUPPORT_AVAILABLE) | 166 if (has_touch == gfx::Display::TOUCH_SUPPORT_AVAILABLE) |
| 153 hardware->set_internal_display_supports_touch(true); | 167 hardware->set_internal_display_supports_touch(true); |
| 154 else if (has_touch == gfx::Display::TOUCH_SUPPORT_UNAVAILABLE) | 168 else if (has_touch == gfx::Display::TOUCH_SUPPORT_UNAVAILABLE) |
| 155 hardware->set_internal_display_supports_touch(false); | 169 hardware->set_internal_display_supports_touch(false); |
| 156 WriteExternalTouchscreensProto(hardware); | 170 WriteExternalTouchscreensProto(hardware); |
| 157 } | 171 } |
| 158 | 172 |
| 159 void ChromeOSMetricsProvider::ProvideStabilityMetrics( | 173 void ChromeOSMetricsProvider::ProvideStabilityMetrics( |
| 160 metrics::SystemProfileProto* system_profile_proto) { | 174 metrics::SystemProfileProto* system_profile_proto) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 268 } |
| 255 | 269 |
| 256 system_profile_proto->set_multi_profile_user_count(user_count); | 270 system_profile_proto->set_multi_profile_user_count(user_count); |
| 257 } | 271 } |
| 258 } | 272 } |
| 259 | 273 |
| 260 void ChromeOSMetricsProvider::SetBluetoothAdapter( | 274 void ChromeOSMetricsProvider::SetBluetoothAdapter( |
| 261 scoped_refptr<device::BluetoothAdapter> adapter) { | 275 scoped_refptr<device::BluetoothAdapter> adapter) { |
| 262 adapter_ = adapter; | 276 adapter_ = adapter; |
| 263 } | 277 } |
| OLD | NEW |