Chromium Code Reviews| 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 50123990b3b052d498fd8b109b1aa77e794cfa7f..b2f79ab09c1d053b2c586fc8439eedf14b797217 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,30 @@ 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::PostTask( |
| + content::BrowserThread::FILE, |
| + FROM_HERE, |
| + base::Bind(&ChromeOSMetricsProvider::InitTaskGetHardwareClassOnFileThread, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + base::MessageLoop::current()->message_loop_proxy(), |
| + callback)); |
|
Alexei Svitkine (slow)
2014/05/28 15:50:10
Can you avoid passing the two params by using Post
blundell
2014/05/28 18:39:35
Done.
|
| +} |
| + |
| +void ChromeOSMetricsProvider::InitTaskGetHardwareClassOnFileThread( |
| + base::MessageLoopProxy* target_loop, |
| + const base::Closure& callback) { |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| + |
| + chromeos::system::StatisticsProvider::GetInstance()->GetMachineStatistic( |
| + "hardware_class", &hardware_class_); |
| + |
| + target_loop->PostTask(FROM_HERE, callback); |
| +} |
| + |
| void ChromeOSMetricsProvider::ProvideSystemProfileMetrics( |
| metrics::SystemProfileProto* system_profile_proto) { |
| std::vector<PerfDataProto> perf_data; |
| @@ -148,6 +175,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); |