Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: chrome/browser/metrics/chromeos_metrics_provider.cc

Issue 301633006: Move ChromeOS hardware class init out of MetricsService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/metrics/chromeos_metrics_provider.cc
diff --git a/chrome/browser/metrics/chromeos_metrics_provider.cc b/chrome/browser/metrics/chromeos_metrics_provider.cc
index 0a4fd15a112a9de661e4fd0a807937f3a0749538..5ecec291ca0ac38824b6a898fedd8c709f00ad5a 100644
--- a/chrome/browser/metrics/chromeos_metrics_provider.cc
+++ b/chrome/browser/metrics/chromeos_metrics_provider.cc
@@ -13,7 +13,9 @@
#include "chrome/browser/chromeos/login/users/user_manager.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/common/pref_names.h"
+#include "chromeos/system/statistics_provider.h"
#include "components/metrics/proto/chrome_user_metrics_extension.pb.h"
+#include "content/public/browser/browser_thread.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/bluetooth_device.h"
@@ -94,7 +96,8 @@ void IncrementPrefValue(const char* path) {
ChromeOSMetricsProvider::ChromeOSMetricsProvider()
: registered_user_count_at_log_initialization_(false),
- user_count_at_log_initialization_(0) {
+ user_count_at_log_initialization_(0),
+ weak_ptr_factory_(this) {
}
ChromeOSMetricsProvider::~ChromeOSMetricsProvider() {
@@ -132,6 +135,24 @@ void ChromeOSMetricsProvider::OnDidCreateMetricsLog() {
}
}
+void ChromeOSMetricsProvider::InitTaskGetHardwareClass(
+ const base::Closure& callback) {
+ // Run the (potentially expensive) task on the FILE thread to avoid blocking
+ // the UI thread.
+ content::BrowserThread::PostTaskAndReply(
+ content::BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&ChromeOSMetricsProvider::InitTaskGetHardwareClassOnFileThread,
+ weak_ptr_factory_.GetWeakPtr()),
+ callback);
+}
+
+void ChromeOSMetricsProvider::InitTaskGetHardwareClassOnFileThread() {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
+ chromeos::system::StatisticsProvider::GetInstance()->GetMachineStatistic(
+ "hardware_class", &hardware_class_);
+}
+
void ChromeOSMetricsProvider::ProvideSystemProfileMetrics(
metrics::SystemProfileProto* system_profile_proto) {
WriteBluetoothProto(system_profile_proto);
@@ -139,6 +160,7 @@ void ChromeOSMetricsProvider::ProvideSystemProfileMetrics(
metrics::SystemProfileProto::Hardware* hardware =
system_profile_proto->mutable_hardware();
+ hardware->set_hardware_class(hardware_class_);
gfx::Display::TouchSupport has_touch = ui::GetInternalDisplayTouchSupport();
if (has_touch == gfx::Display::TOUCH_SUPPORT_AVAILABLE)
hardware->set_internal_display_supports_touch(true);
« no previous file with comments | « chrome/browser/metrics/chromeos_metrics_provider.h ('k') | chrome/browser/metrics/chromeos_metrics_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698