| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/task_scheduler/post_task.h" |
| 15 #include "base/task_scheduler/task_traits.h" |
| 16 #include "base/threading/thread_restrictions.h" |
| 14 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 18 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 16 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 19 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 17 #include "chrome/common/chrome_features.h" | 20 #include "chrome/common/chrome_features.h" |
| 18 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 19 #include "chromeos/system/statistics_provider.h" | 22 #include "chromeos/system/statistics_provider.h" |
| 20 #include "components/metrics/leak_detector/leak_detector.h" | 23 #include "components/metrics/leak_detector/leak_detector.h" |
| 21 #include "components/metrics/metrics_service.h" | 24 #include "components/metrics/metrics_service.h" |
| 22 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" | 25 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" |
| 23 #include "components/prefs/pref_registry_simple.h" | 26 #include "components/prefs/pref_registry_simple.h" |
| 24 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
| 25 #include "components/user_manager/user_manager.h" | 28 #include "components/user_manager/user_manager.h" |
| 26 #include "content/public/browser/browser_thread.h" | |
| 27 #include "device/bluetooth/bluetooth_adapter.h" | 29 #include "device/bluetooth/bluetooth_adapter.h" |
| 28 #include "device/bluetooth/bluetooth_adapter_factory.h" | 30 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 29 #include "device/bluetooth/bluetooth_device.h" | 31 #include "device/bluetooth/bluetooth_device.h" |
| 30 #include "ui/display/display.h" | 32 #include "ui/display/display.h" |
| 31 #include "ui/events/event_utils.h" | 33 #include "ui/events/event_utils.h" |
| 32 | 34 |
| 33 #if defined(USE_X11) | 35 #if defined(USE_X11) |
| 34 #include "ui/events/devices/x11/touch_factory_x11.h" | 36 #include "ui/events/devices/x11/touch_factory_x11.h" |
| 35 #endif // defined(USE_X11) | 37 #endif // defined(USE_X11) |
| 36 | 38 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 registered_user_count_at_log_initialization_ = false; | 162 registered_user_count_at_log_initialization_ = false; |
| 161 if (user_manager::UserManager::IsInitialized()) { | 163 if (user_manager::UserManager::IsInitialized()) { |
| 162 registered_user_count_at_log_initialization_ = true; | 164 registered_user_count_at_log_initialization_ = true; |
| 163 user_count_at_log_initialization_ = | 165 user_count_at_log_initialization_ = |
| 164 user_manager::UserManager::Get()->GetLoggedInUsers().size(); | 166 user_manager::UserManager::Get()->GetLoggedInUsers().size(); |
| 165 } | 167 } |
| 166 } | 168 } |
| 167 | 169 |
| 168 void ChromeOSMetricsProvider::InitTaskGetHardwareClass( | 170 void ChromeOSMetricsProvider::InitTaskGetHardwareClass( |
| 169 const base::Closure& callback) { | 171 const base::Closure& callback) { |
| 170 // Run the (potentially expensive) task on the FILE thread to avoid blocking | 172 // Run the (potentially expensive) task in the background to avoid blocking |
| 171 // the UI thread. | 173 // the UI thread. |
| 172 content::BrowserThread::PostTaskAndReply( | 174 base::PostTaskWithTraitsAndReply( |
| 173 content::BrowserThread::FILE, | |
| 174 FROM_HERE, | 175 FROM_HERE, |
| 175 base::Bind(&ChromeOSMetricsProvider::InitTaskGetHardwareClassOnFileThread, | 176 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
| 176 weak_ptr_factory_.GetWeakPtr()), | 177 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}, |
| 178 base::BindOnce( |
| 179 &ChromeOSMetricsProvider::InitTaskGetHardwareClassOnBackgroundThread, |
| 180 weak_ptr_factory_.GetWeakPtr()), |
| 177 callback); | 181 callback); |
| 178 } | 182 } |
| 179 | 183 |
| 180 void ChromeOSMetricsProvider::InitTaskGetHardwareClassOnFileThread() { | 184 void ChromeOSMetricsProvider::InitTaskGetHardwareClassOnBackgroundThread() { |
| 181 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 185 base::ThreadRestrictions::AssertWaitAllowed(); |
| 182 chromeos::system::StatisticsProvider::GetInstance()->GetMachineStatistic( | 186 chromeos::system::StatisticsProvider::GetInstance()->GetMachineStatistic( |
| 183 "hardware_class", &hardware_class_); | 187 "hardware_class", &hardware_class_); |
| 184 } | 188 } |
| 185 | 189 |
| 186 void ChromeOSMetricsProvider::InitTaskGetBluetoothAdapter( | 190 void ChromeOSMetricsProvider::InitTaskGetBluetoothAdapter( |
| 187 const base::Closure& callback) { | 191 const base::Closure& callback) { |
| 188 device::BluetoothAdapterFactory::GetAdapter( | 192 device::BluetoothAdapterFactory::GetAdapter( |
| 189 base::Bind(&ChromeOSMetricsProvider::SetBluetoothAdapter, | 193 base::Bind(&ChromeOSMetricsProvider::SetBluetoothAdapter, |
| 190 weak_ptr_factory_.GetWeakPtr(), callback)); | 194 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 191 } | 195 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 void ChromeOSMetricsProvider::RecordEnrollmentStatus() { | 338 void ChromeOSMetricsProvider::RecordEnrollmentStatus() { |
| 335 UMA_HISTOGRAM_ENUMERATION( | 339 UMA_HISTOGRAM_ENUMERATION( |
| 336 "UMA.EnrollmentStatus", GetEnrollmentStatus(), ENROLLMENT_STATUS_MAX); | 340 "UMA.EnrollmentStatus", GetEnrollmentStatus(), ENROLLMENT_STATUS_MAX); |
| 337 } | 341 } |
| 338 | 342 |
| 339 void ChromeOSMetricsProvider::RecordArcState() { | 343 void ChromeOSMetricsProvider::RecordArcState() { |
| 340 arc::ArcSessionManager* arc_session_manager = arc::ArcSessionManager::Get(); | 344 arc::ArcSessionManager* arc_session_manager = arc::ArcSessionManager::Get(); |
| 341 if (arc_session_manager) | 345 if (arc_session_manager) |
| 342 arc_session_manager->RecordArcState(); | 346 arc_session_manager->RecordArcState(); |
| 343 } | 347 } |
| OLD | NEW |