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

Side by Side Diff: chrome/browser/metrics/metrics_network_observer.h

Issue 12082090: [net] Add WifiPhyMode to SystemProfile (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: responded to isherman's review 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_METRICS_METRICS_NETWORK_OBSERVER_H_
6 #define CHROME_BROWSER_METRICS_METRICS_NETWORK_OBSERVER_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/common/metrics/proto/system_profile.pb.h"
12 #include "net/base/net_util.h"
13 #include "net/base/network_change_notifier.h"
14
15 using metrics::SystemProfileProto;
16
17 // Registers as observer with net::NetworkChangeNotifier and keeps track of
18 // the network environment.
19 class MetricsNetworkObserver
20 : public net::NetworkChangeNotifier::ConnectionTypeObserver {
21 public:
22 MetricsNetworkObserver();
23 virtual ~MetricsNetworkObserver();
24
25 void Reset();
26
27 // ConnectionTypeObserver:
28 virtual void OnConnectionTypeChanged(
29 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
30
31 bool connection_type_is_ambiguous() const {
32 return connection_type_is_ambiguous_;
33 }
34
35 SystemProfileProto::Network::ConnectionType connection_type() const {
36 switch (connection_type_) {
37 case net::NetworkChangeNotifier::CONNECTION_NONE:
38 case net::NetworkChangeNotifier::CONNECTION_UNKNOWN:
39 return SystemProfileProto::Network::CONNECTION_UNKNOWN;
40 case net::NetworkChangeNotifier::CONNECTION_ETHERNET:
41 return SystemProfileProto::Network::CONNECTION_ETHERNET;
42 case net::NetworkChangeNotifier::CONNECTION_WIFI:
43 return SystemProfileProto::Network::CONNECTION_WIFI;
44 case net::NetworkChangeNotifier::CONNECTION_2G:
45 return SystemProfileProto::Network::CONNECTION_2G;
46 case net::NetworkChangeNotifier::CONNECTION_3G:
47 return SystemProfileProto::Network::CONNECTION_3G;
48 case net::NetworkChangeNotifier::CONNECTION_4G:
49 return SystemProfileProto::Network::CONNECTION_4G;
50 }
51 NOTREACHED();
52 return SystemProfileProto::Network::CONNECTION_UNKNOWN;
53 }
54
55 bool wifi_phy_mode_is_ambiguous() const {
56 return wifi_phy_mode_is_ambiguous_;
57 }
58
59 SystemProfileProto::Network::WifiPhyMode wifi_phy_mode() const {
60 switch (wifi_phy_mode_) {
61 case net::WIFI_PHY_MODE_NONE:
62 return SystemProfileProto::Network::WIFI_PHY_MODE_NONE;
63 case net::WIFI_PHY_MODE_ANCIENT:
64 return SystemProfileProto::Network::WIFI_PHY_MODE_ANCIENT;
65 case net::WIFI_PHY_MODE_A:
66 return SystemProfileProto::Network::WIFI_PHY_MODE_A;
67 case net::WIFI_PHY_MODE_B:
68 return SystemProfileProto::Network::WIFI_PHY_MODE_B;
69 case net::WIFI_PHY_MODE_G:
70 return SystemProfileProto::Network::WIFI_PHY_MODE_G;
71 case net::WIFI_PHY_MODE_N:
72 return SystemProfileProto::Network::WIFI_PHY_MODE_N;
73 case net::WIFI_PHY_MODE_UNKNOWN:
74 return SystemProfileProto::Network::WIFI_PHY_MODE_UNKNOWN;
75 }
76 NOTREACHED();
77 return SystemProfileProto::Network::WIFI_PHY_MODE_UNKNOWN;
78 }
79
80 private:
81 class WifiPhyModeJob;
82
83 void OnWifiModeChanged(net::WifiPhyMode* mode);
84
85 base::WeakPtrFactory<MetricsNetworkObserver> weak_ptr_factory_;
86
87 bool connection_type_is_ambiguous_;
88 net::NetworkChangeNotifier::ConnectionType connection_type_;
89
90 bool wifi_phy_mode_is_ambiguous_;
91 net::WifiPhyMode wifi_phy_mode_;
92
93 DISALLOW_COPY_AND_ASSIGN(MetricsNetworkObserver);
94 };
95
96 #endif // CHROME_BROWSER_METRICS_METRICS_NETWORK_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698