OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/metrics_log.h" | 5 #include "chrome/browser/metrics/metrics_log.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "chrome/common/metrics/proto/profiler_event.pb.h" | 38 #include "chrome/common/metrics/proto/profiler_event.pb.h" |
39 #include "chrome/common/metrics/proto/system_profile.pb.h" | 39 #include "chrome/common/metrics/proto/system_profile.pb.h" |
40 #include "chrome/common/metrics/variations/variations_util.h" | 40 #include "chrome/common/metrics/variations/variations_util.h" |
41 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
42 #include "chrome/installer/util/google_update_settings.h" | 42 #include "chrome/installer/util/google_update_settings.h" |
43 #include "content/public/browser/content_browser_client.h" | 43 #include "content/public/browser/content_browser_client.h" |
44 #include "content/public/browser/gpu_data_manager.h" | 44 #include "content/public/browser/gpu_data_manager.h" |
45 #include "content/public/common/content_client.h" | 45 #include "content/public/common/content_client.h" |
46 #include "content/public/common/gpu_info.h" | 46 #include "content/public/common/gpu_info.h" |
47 #include "googleurl/src/gurl.h" | 47 #include "googleurl/src/gurl.h" |
48 #include "net/base/network_change_notifier.h" | |
49 #include "ui/gfx/screen.h" | 48 #include "ui/gfx/screen.h" |
50 #include "webkit/plugins/webplugininfo.h" | 49 #include "webkit/plugins/webplugininfo.h" |
51 | 50 |
52 #if defined(OS_ANDROID) | 51 #if defined(OS_ANDROID) |
53 #include "base/android/build_info.h" | 52 #include "base/android/build_info.h" |
54 #endif | 53 #endif |
55 | 54 |
56 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) | 55 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) |
57 | 56 |
58 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 hardware->set_max_dpi_y(si.max_dpi_y); | 300 hardware->set_max_dpi_y(si.max_dpi_y); |
302 } | 301 } |
303 ReleaseDC(GetDesktopWindow(), desktop_dc); | 302 ReleaseDC(GetDesktopWindow(), desktop_dc); |
304 } | 303 } |
305 } | 304 } |
306 | 305 |
307 #endif // defined(OS_WIN) | 306 #endif // defined(OS_WIN) |
308 | 307 |
309 } // namespace | 308 } // namespace |
310 | 309 |
311 class MetricsLog::NetworkObserver | |
312 : public net::NetworkChangeNotifier::ConnectionTypeObserver { | |
313 public: | |
314 NetworkObserver() : connection_type_is_ambiguous_(false) { | |
315 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | |
316 Reset(); | |
317 } | |
318 virtual ~NetworkObserver() { | |
319 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | |
320 } | |
321 | |
322 void Reset() { | |
323 connection_type_is_ambiguous_ = false; | |
324 connection_type_ = net::NetworkChangeNotifier::GetConnectionType(); | |
325 } | |
326 | |
327 // ConnectionTypeObserver: | |
328 virtual void OnConnectionTypeChanged( | |
329 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE { | |
330 if (type == net::NetworkChangeNotifier::CONNECTION_NONE) | |
331 return; | |
332 if (type != connection_type_ && | |
333 connection_type_ != net::NetworkChangeNotifier::CONNECTION_NONE) { | |
334 connection_type_is_ambiguous_ = true; | |
335 } | |
336 connection_type_ = type; | |
337 } | |
338 | |
339 bool connection_type_is_ambiguous() const { | |
340 return connection_type_is_ambiguous_; | |
341 } | |
342 | |
343 SystemProfileProto::Network::ConnectionType connection_type() const { | |
344 switch (connection_type_) { | |
345 case net::NetworkChangeNotifier::CONNECTION_NONE: | |
346 case net::NetworkChangeNotifier::CONNECTION_UNKNOWN: | |
347 return SystemProfileProto::Network::CONNECTION_UNKNOWN; | |
348 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: | |
349 return SystemProfileProto::Network::CONNECTION_ETHERNET; | |
350 case net::NetworkChangeNotifier::CONNECTION_WIFI: | |
351 return SystemProfileProto::Network::CONNECTION_WIFI; | |
352 case net::NetworkChangeNotifier::CONNECTION_2G: | |
353 return SystemProfileProto::Network::CONNECTION_2G; | |
354 case net::NetworkChangeNotifier::CONNECTION_3G: | |
355 return SystemProfileProto::Network::CONNECTION_3G; | |
356 case net::NetworkChangeNotifier::CONNECTION_4G: | |
357 return SystemProfileProto::Network::CONNECTION_4G; | |
358 } | |
359 NOTREACHED(); | |
360 return SystemProfileProto::Network::CONNECTION_UNKNOWN; | |
361 } | |
362 | |
363 private: | |
364 bool connection_type_is_ambiguous_; | |
365 net::NetworkChangeNotifier::ConnectionType connection_type_; | |
366 | |
367 DISALLOW_COPY_AND_ASSIGN(NetworkObserver); | |
368 }; | |
369 | |
370 GoogleUpdateMetrics::GoogleUpdateMetrics() : is_system_install(false) {} | 310 GoogleUpdateMetrics::GoogleUpdateMetrics() : is_system_install(false) {} |
371 | 311 |
372 GoogleUpdateMetrics::~GoogleUpdateMetrics() {} | 312 GoogleUpdateMetrics::~GoogleUpdateMetrics() {} |
373 | 313 |
374 static base::LazyInstance<std::string>::Leaky | 314 static base::LazyInstance<std::string>::Leaky |
375 g_version_extension = LAZY_INSTANCE_INITIALIZER; | 315 g_version_extension = LAZY_INSTANCE_INITIALIZER; |
376 | 316 |
377 MetricsLog::MetricsLog(const std::string& client_id, int session_id) | 317 MetricsLog::MetricsLog(const std::string& client_id, int session_id) |
378 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()), | 318 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()) {} |
379 network_observer_(new NetworkObserver()) {} | |
380 | 319 |
381 MetricsLog::~MetricsLog() {} | 320 MetricsLog::~MetricsLog() {} |
382 | 321 |
383 // static | 322 // static |
384 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { | 323 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { |
385 registry->RegisterListPref(prefs::kStabilityPluginStats); | 324 registry->RegisterListPref(prefs::kStabilityPluginStats); |
386 } | 325 } |
387 | 326 |
388 // static | 327 // static |
389 int64 MetricsLog::GetIncrementalUptime(PrefService* pref) { | 328 int64 MetricsLog::GetIncrementalUptime(PrefService* pref) { |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 | 808 |
870 SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware(); | 809 SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware(); |
871 hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture()); | 810 hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture()); |
872 hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB()); | 811 hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB()); |
873 #if defined(OS_WIN) | 812 #if defined(OS_WIN) |
874 hardware->set_dll_base(reinterpret_cast<uint64>(&__ImageBase)); | 813 hardware->set_dll_base(reinterpret_cast<uint64>(&__ImageBase)); |
875 #endif | 814 #endif |
876 | 815 |
877 SystemProfileProto::Network* network = system_profile->mutable_network(); | 816 SystemProfileProto::Network* network = system_profile->mutable_network(); |
878 network->set_connection_type_is_ambiguous( | 817 network->set_connection_type_is_ambiguous( |
879 network_observer_->connection_type_is_ambiguous()); | 818 network_observer_.connection_type_is_ambiguous()); |
880 network->set_connection_type(network_observer_->connection_type()); | 819 network->set_connection_type(network_observer_.connection_type()); |
881 network_observer_->Reset(); | 820 network->set_wifi_phy_layer_protocol_is_ambiguous( |
| 821 network_observer_.wifi_phy_layer_protocol_is_ambiguous()); |
| 822 network->set_wifi_phy_layer_protocol( |
| 823 network_observer_.wifi_phy_layer_protocol()); |
| 824 network_observer_.Reset(); |
882 | 825 |
883 SystemProfileProto::OS* os = system_profile->mutable_os(); | 826 SystemProfileProto::OS* os = system_profile->mutable_os(); |
884 std::string os_name = base::SysInfo::OperatingSystemName(); | 827 std::string os_name = base::SysInfo::OperatingSystemName(); |
885 #if defined(OS_WIN) | 828 #if defined(OS_WIN) |
886 // TODO(mad): This only checks whether the main process is a Metro process at | 829 // TODO(mad): This only checks whether the main process is a Metro process at |
887 // upload time; not whether the collected metrics were all gathered from | 830 // upload time; not whether the collected metrics were all gathered from |
888 // Metro. This is ok as an approximation for now, since users will rarely be | 831 // Metro. This is ok as an approximation for now, since users will rarely be |
889 // switching from Metro to Desktop mode; but we should re-evaluate whether we | 832 // switching from Metro to Desktop mode; but we should re-evaluate whether we |
890 // can distinguish metrics more cleanly in the future: http://crbug.com/140568 | 833 // can distinguish metrics more cleanly in the future: http://crbug.com/140568 |
891 if (base::win::IsMetroProcess()) | 834 if (base::win::IsMetroProcess()) |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 ProductDataToProto(google_update_metrics.google_update_data, | 1087 ProductDataToProto(google_update_metrics.google_update_data, |
1145 google_update->mutable_google_update_status()); | 1088 google_update->mutable_google_update_status()); |
1146 } | 1089 } |
1147 | 1090 |
1148 if (!google_update_metrics.product_data.version.empty()) { | 1091 if (!google_update_metrics.product_data.version.empty()) { |
1149 ProductDataToProto(google_update_metrics.product_data, | 1092 ProductDataToProto(google_update_metrics.product_data, |
1150 google_update->mutable_client_status()); | 1093 google_update->mutable_client_status()); |
1151 } | 1094 } |
1152 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) | 1095 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) |
1153 } | 1096 } |
OLD | NEW |