| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 PrefService* pref = g_browser_process->local_state(); | 89 PrefService* pref = g_browser_process->local_state(); |
| 88 DCHECK(pref); | 90 DCHECK(pref); |
| 89 int value = pref->GetInteger(path); | 91 int value = pref->GetInteger(path); |
| 90 pref->SetInteger(path, value + 1); | 92 pref->SetInteger(path, value + 1); |
| 91 } | 93 } |
| 92 | 94 |
| 93 } // namespace | 95 } // namespace |
| 94 | 96 |
| 95 ChromeOSMetricsProvider::ChromeOSMetricsProvider() | 97 ChromeOSMetricsProvider::ChromeOSMetricsProvider() |
| 96 : registered_user_count_at_log_initialization_(false), | 98 : registered_user_count_at_log_initialization_(false), |
| 97 user_count_at_log_initialization_(0) { | 99 user_count_at_log_initialization_(0), |
| 100 weak_ptr_factory_(this) { |
| 98 } | 101 } |
| 99 | 102 |
| 100 ChromeOSMetricsProvider::~ChromeOSMetricsProvider() { | 103 ChromeOSMetricsProvider::~ChromeOSMetricsProvider() { |
| 101 } | 104 } |
| 102 | 105 |
| 103 // static | 106 // static |
| 104 void ChromeOSMetricsProvider::RegisterPrefs(PrefRegistrySimple* registry) { | 107 void ChromeOSMetricsProvider::RegisterPrefs(PrefRegistrySimple* registry) { |
| 105 registry->RegisterIntegerPref(prefs::kStabilityOtherUserCrashCount, 0); | 108 registry->RegisterIntegerPref(prefs::kStabilityOtherUserCrashCount, 0); |
| 106 registry->RegisterIntegerPref(prefs::kStabilityKernelCrashCount, 0); | 109 registry->RegisterIntegerPref(prefs::kStabilityKernelCrashCount, 0); |
| 107 registry->RegisterIntegerPref(prefs::kStabilitySystemUncleanShutdownCount, 0); | 110 registry->RegisterIntegerPref(prefs::kStabilitySystemUncleanShutdownCount, 0); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 125 | 128 |
| 126 void ChromeOSMetricsProvider::OnDidCreateMetricsLog() { | 129 void ChromeOSMetricsProvider::OnDidCreateMetricsLog() { |
| 127 registered_user_count_at_log_initialization_ = false; | 130 registered_user_count_at_log_initialization_ = false; |
| 128 if (chromeos::UserManager::IsInitialized()) { | 131 if (chromeos::UserManager::IsInitialized()) { |
| 129 registered_user_count_at_log_initialization_ = true; | 132 registered_user_count_at_log_initialization_ = true; |
| 130 user_count_at_log_initialization_ = | 133 user_count_at_log_initialization_ = |
| 131 chromeos::UserManager::Get()->GetLoggedInUsers().size(); | 134 chromeos::UserManager::Get()->GetLoggedInUsers().size(); |
| 132 } | 135 } |
| 133 } | 136 } |
| 134 | 137 |
| 138 void ChromeOSMetricsProvider::InitTaskGetHardwareClass( |
| 139 const base::Closure& callback) { |
| 140 // Run the (potentially expensive) task on the FILE thread to avoid blocking |
| 141 // the UI thread. |
| 142 content::BrowserThread::PostTaskAndReply( |
| 143 content::BrowserThread::FILE, |
| 144 FROM_HERE, |
| 145 base::Bind(&ChromeOSMetricsProvider::InitTaskGetHardwareClassOnFileThread, |
| 146 weak_ptr_factory_.GetWeakPtr()), |
| 147 callback); |
| 148 } |
| 149 |
| 150 void ChromeOSMetricsProvider::InitTaskGetHardwareClassOnFileThread() { |
| 151 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 152 chromeos::system::StatisticsProvider::GetInstance()->GetMachineStatistic( |
| 153 "hardware_class", &hardware_class_); |
| 154 } |
| 155 |
| 135 void ChromeOSMetricsProvider::ProvideSystemProfileMetrics( | 156 void ChromeOSMetricsProvider::ProvideSystemProfileMetrics( |
| 136 metrics::SystemProfileProto* system_profile_proto) { | 157 metrics::SystemProfileProto* system_profile_proto) { |
| 137 WriteBluetoothProto(system_profile_proto); | 158 WriteBluetoothProto(system_profile_proto); |
| 138 UpdateMultiProfileUserCount(system_profile_proto); | 159 UpdateMultiProfileUserCount(system_profile_proto); |
| 139 | 160 |
| 140 metrics::SystemProfileProto::Hardware* hardware = | 161 metrics::SystemProfileProto::Hardware* hardware = |
| 141 system_profile_proto->mutable_hardware(); | 162 system_profile_proto->mutable_hardware(); |
| 163 hardware->set_hardware_class(hardware_class_); |
| 142 gfx::Display::TouchSupport has_touch = ui::GetInternalDisplayTouchSupport(); | 164 gfx::Display::TouchSupport has_touch = ui::GetInternalDisplayTouchSupport(); |
| 143 if (has_touch == gfx::Display::TOUCH_SUPPORT_AVAILABLE) | 165 if (has_touch == gfx::Display::TOUCH_SUPPORT_AVAILABLE) |
| 144 hardware->set_internal_display_supports_touch(true); | 166 hardware->set_internal_display_supports_touch(true); |
| 145 else if (has_touch == gfx::Display::TOUCH_SUPPORT_UNAVAILABLE) | 167 else if (has_touch == gfx::Display::TOUCH_SUPPORT_UNAVAILABLE) |
| 146 hardware->set_internal_display_supports_touch(false); | 168 hardware->set_internal_display_supports_touch(false); |
| 147 WriteExternalTouchscreensProto(hardware); | 169 WriteExternalTouchscreensProto(hardware); |
| 148 } | 170 } |
| 149 | 171 |
| 150 void ChromeOSMetricsProvider::ProvideStabilityMetrics( | 172 void ChromeOSMetricsProvider::ProvideStabilityMetrics( |
| 151 metrics::SystemProfileProto* system_profile_proto) { | 173 metrics::SystemProfileProto* system_profile_proto) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 279 } |
| 258 | 280 |
| 259 system_profile_proto->set_multi_profile_user_count(user_count); | 281 system_profile_proto->set_multi_profile_user_count(user_count); |
| 260 } | 282 } |
| 261 } | 283 } |
| 262 | 284 |
| 263 void ChromeOSMetricsProvider::SetBluetoothAdapter( | 285 void ChromeOSMetricsProvider::SetBluetoothAdapter( |
| 264 scoped_refptr<device::BluetoothAdapter> adapter) { | 286 scoped_refptr<device::BluetoothAdapter> adapter) { |
| 265 adapter_ = adapter; | 287 adapter_ = adapter; |
| 266 } | 288 } |
| OLD | NEW |