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