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

Side by Side Diff: chrome/browser/metrics/metrics_log.cc

Issue 12082090: [net] Add WifiPhyMode to SystemProfile (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: ensure to probe the current WifiPhyMode on Reset Created 7 years, 10 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 (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 12 matching lines...) Expand all
23 #include "base/time.h" 23 #include "base/time.h"
24 #include "base/tracked_objects.h" 24 #include "base/tracked_objects.h"
25 #include "base/utf_string_conversions.h" 25 #include "base/utf_string_conversions.h"
26 #include "chrome/browser/autocomplete/autocomplete_input.h" 26 #include "chrome/browser/autocomplete/autocomplete_input.h"
27 #include "chrome/browser/autocomplete/autocomplete_log.h" 27 #include "chrome/browser/autocomplete/autocomplete_log.h"
28 #include "chrome/browser/autocomplete/autocomplete_match.h" 28 #include "chrome/browser/autocomplete/autocomplete_match.h"
29 #include "chrome/browser/autocomplete/autocomplete_provider.h" 29 #include "chrome/browser/autocomplete/autocomplete_provider.h"
30 #include "chrome/browser/autocomplete/autocomplete_result.h" 30 #include "chrome/browser/autocomplete/autocomplete_result.h"
31 #include "chrome/browser/browser_process.h" 31 #include "chrome/browser/browser_process.h"
32 #include "chrome/browser/google/google_util.h" 32 #include "chrome/browser/google/google_util.h"
33 #include "chrome/browser/metrics/metrics_network_observer.h"
33 #include "chrome/browser/plugins/plugin_prefs.h" 34 #include "chrome/browser/plugins/plugin_prefs.h"
34 #include "chrome/browser/profiles/profile_manager.h" 35 #include "chrome/browser/profiles/profile_manager.h"
35 #include "chrome/common/chrome_version_info.h" 36 #include "chrome/common/chrome_version_info.h"
36 #include "chrome/common/logging_chrome.h" 37 #include "chrome/common/logging_chrome.h"
37 #include "chrome/common/metrics/proto/omnibox_event.pb.h" 38 #include "chrome/common/metrics/proto/omnibox_event.pb.h"
38 #include "chrome/common/metrics/proto/profiler_event.pb.h" 39 #include "chrome/common/metrics/proto/profiler_event.pb.h"
39 #include "chrome/common/metrics/proto/system_profile.pb.h" 40 #include "chrome/common/metrics/proto/system_profile.pb.h"
40 #include "chrome/common/metrics/variations/variations_util.h" 41 #include "chrome/common/metrics/variations/variations_util.h"
41 #include "chrome/common/pref_names.h" 42 #include "chrome/common/pref_names.h"
42 #include "chrome/installer/util/google_update_settings.h" 43 #include "chrome/installer/util/google_update_settings.h"
43 #include "content/public/browser/content_browser_client.h" 44 #include "content/public/browser/content_browser_client.h"
44 #include "content/public/browser/gpu_data_manager.h" 45 #include "content/public/browser/gpu_data_manager.h"
45 #include "content/public/common/content_client.h" 46 #include "content/public/common/content_client.h"
46 #include "content/public/common/gpu_info.h" 47 #include "content/public/common/gpu_info.h"
47 #include "googleurl/src/gurl.h" 48 #include "googleurl/src/gurl.h"
48 #include "net/base/network_change_notifier.h"
49 #include "ui/gfx/screen.h" 49 #include "ui/gfx/screen.h"
50 #include "webkit/plugins/webplugininfo.h" 50 #include "webkit/plugins/webplugininfo.h"
51 51
52 #if defined(OS_ANDROID) 52 #if defined(OS_ANDROID)
53 #include "base/android/build_info.h" 53 #include "base/android/build_info.h"
54 #endif 54 #endif
55 55
56 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) 56 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name)
57 57
58 #if defined(OS_WIN) 58 #if defined(OS_WIN)
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 hardware->set_max_dpi_y(si.max_dpi_y); 301 hardware->set_max_dpi_y(si.max_dpi_y);
302 } 302 }
303 ReleaseDC(GetDesktopWindow(), desktop_dc); 303 ReleaseDC(GetDesktopWindow(), desktop_dc);
304 } 304 }
305 } 305 }
306 306
307 #endif // defined(OS_WIN) 307 #endif // defined(OS_WIN)
308 308
309 } // namespace 309 } // namespace
310 310
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) {} 311 GoogleUpdateMetrics::GoogleUpdateMetrics() : is_system_install(false) {}
371 312
372 GoogleUpdateMetrics::~GoogleUpdateMetrics() {} 313 GoogleUpdateMetrics::~GoogleUpdateMetrics() {}
373 314
374 static base::LazyInstance<std::string>::Leaky 315 static base::LazyInstance<std::string>::Leaky
375 g_version_extension = LAZY_INSTANCE_INITIALIZER; 316 g_version_extension = LAZY_INSTANCE_INITIALIZER;
376 317
377 MetricsLog::MetricsLog(const std::string& client_id, int session_id) 318 MetricsLog::MetricsLog(const std::string& client_id, int session_id)
378 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()), 319 : MetricsLogBase(client_id, session_id, MetricsLog::GetVersionString()),
379 network_observer_(new NetworkObserver()) {} 320 network_observer_(new MetricsNetworkObserver()) {}
380 321
381 MetricsLog::~MetricsLog() {} 322 MetricsLog::~MetricsLog() {}
382 323
383 // static 324 // static
384 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) { 325 void MetricsLog::RegisterPrefs(PrefRegistrySimple* registry) {
385 registry->RegisterListPref(prefs::kStabilityPluginStats); 326 registry->RegisterListPref(prefs::kStabilityPluginStats);
386 } 327 }
387 328
388 // static 329 // static
389 int64 MetricsLog::GetIncrementalUptime(PrefService* pref) { 330 int64 MetricsLog::GetIncrementalUptime(PrefService* pref) {
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture()); 812 hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture());
872 hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB()); 813 hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB());
873 #if defined(OS_WIN) 814 #if defined(OS_WIN)
874 hardware->set_dll_base(reinterpret_cast<uint64>(&__ImageBase)); 815 hardware->set_dll_base(reinterpret_cast<uint64>(&__ImageBase));
875 #endif 816 #endif
876 817
877 SystemProfileProto::Network* network = system_profile->mutable_network(); 818 SystemProfileProto::Network* network = system_profile->mutable_network();
878 network->set_connection_type_is_ambiguous( 819 network->set_connection_type_is_ambiguous(
879 network_observer_->connection_type_is_ambiguous()); 820 network_observer_->connection_type_is_ambiguous());
880 network->set_connection_type(network_observer_->connection_type()); 821 network->set_connection_type(network_observer_->connection_type());
822 network->set_wifi_phy_mode_is_ambiguous(
823 network_observer_->wifi_phy_mode_is_ambiguous());
824 network->set_wifi_phy_mode(network_observer_->wifi_phy_mode());
881 network_observer_->Reset(); 825 network_observer_->Reset();
882 826
883 SystemProfileProto::OS* os = system_profile->mutable_os(); 827 SystemProfileProto::OS* os = system_profile->mutable_os();
884 std::string os_name = base::SysInfo::OperatingSystemName(); 828 std::string os_name = base::SysInfo::OperatingSystemName();
885 #if defined(OS_WIN) 829 #if defined(OS_WIN)
886 // TODO(mad): This only checks whether the main process is a Metro process at 830 // 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 831 // 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 832 // 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 833 // 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 834 // can distinguish metrics more cleanly in the future: http://crbug.com/140568
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 ProductDataToProto(google_update_metrics.google_update_data, 1088 ProductDataToProto(google_update_metrics.google_update_data,
1145 google_update->mutable_google_update_status()); 1089 google_update->mutable_google_update_status());
1146 } 1090 }
1147 1091
1148 if (!google_update_metrics.product_data.version.empty()) { 1092 if (!google_update_metrics.product_data.version.empty()) {
1149 ProductDataToProto(google_update_metrics.product_data, 1093 ProductDataToProto(google_update_metrics.product_data,
1150 google_update->mutable_client_status()); 1094 google_update->mutable_client_status());
1151 } 1095 }
1152 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN) 1096 #endif // defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)
1153 } 1097 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698