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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
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
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
148 /*
149 void ChromeOSMetricsProvider::OnInitTaskGotHardwareClass(
150 const std::string& hardware_class,
151 const base::Callback& callback) {
152 hardware_class_ = hardware_class;
153 callback.Run();
154 }
155 */
156
135 void ChromeOSMetricsProvider::ProvideSystemProfileMetrics( 157 void ChromeOSMetricsProvider::ProvideSystemProfileMetrics(
136 metrics::SystemProfileProto* system_profile_proto) { 158 metrics::SystemProfileProto* system_profile_proto) {
137 std::vector<PerfDataProto> perf_data; 159 std::vector<PerfDataProto> perf_data;
138 if (perf_provider_.GetPerfData(&perf_data)) { 160 if (perf_provider_.GetPerfData(&perf_data)) {
139 for (std::vector<PerfDataProto>::iterator iter = perf_data.begin(); 161 for (std::vector<PerfDataProto>::iterator iter = perf_data.begin();
140 iter != perf_data.end(); 162 iter != perf_data.end();
141 ++iter) { 163 ++iter) {
142 uma_proto_->add_perf_data()->Swap(&(*iter)); 164 uma_proto_->add_perf_data()->Swap(&(*iter));
143 } 165 }
144 } 166 }
145 167
146 WriteBluetoothProto(system_profile_proto); 168 WriteBluetoothProto(system_profile_proto);
147 UpdateMultiProfileUserCount(system_profile_proto); 169 UpdateMultiProfileUserCount(system_profile_proto);
148 170
149 metrics::SystemProfileProto::Hardware* hardware = 171 metrics::SystemProfileProto::Hardware* hardware =
150 system_profile_proto->mutable_hardware(); 172 system_profile_proto->mutable_hardware();
173 hardware->set_hardware_class(hardware_class_);
151 gfx::Display::TouchSupport has_touch = ui::GetInternalDisplayTouchSupport(); 174 gfx::Display::TouchSupport has_touch = ui::GetInternalDisplayTouchSupport();
152 if (has_touch == gfx::Display::TOUCH_SUPPORT_AVAILABLE) 175 if (has_touch == gfx::Display::TOUCH_SUPPORT_AVAILABLE)
153 hardware->set_internal_display_supports_touch(true); 176 hardware->set_internal_display_supports_touch(true);
154 else if (has_touch == gfx::Display::TOUCH_SUPPORT_UNAVAILABLE) 177 else if (has_touch == gfx::Display::TOUCH_SUPPORT_UNAVAILABLE)
155 hardware->set_internal_display_supports_touch(false); 178 hardware->set_internal_display_supports_touch(false);
156 WriteExternalTouchscreensProto(hardware); 179 WriteExternalTouchscreensProto(hardware);
157 } 180 }
158 181
159 void ChromeOSMetricsProvider::ProvideStabilityMetrics( 182 void ChromeOSMetricsProvider::ProvideStabilityMetrics(
160 metrics::SystemProfileProto* system_profile_proto) { 183 metrics::SystemProfileProto* system_profile_proto) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 277 }
255 278
256 system_profile_proto->set_multi_profile_user_count(user_count); 279 system_profile_proto->set_multi_profile_user_count(user_count);
257 } 280 }
258 } 281 }
259 282
260 void ChromeOSMetricsProvider::SetBluetoothAdapter( 283 void ChromeOSMetricsProvider::SetBluetoothAdapter(
261 scoped_refptr<device::BluetoothAdapter> adapter) { 284 scoped_refptr<device::BluetoothAdapter> adapter) {
262 adapter_ = adapter; 285 adapter_ = adapter;
263 } 286 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698