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

Side by Side Diff: net/base/network_change_notifier.h

Issue 328793002: Add wifi AP info to system profile metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add default constructor/destructor to WifiAccessPointInfo struct to fix compilation error on certai… Created 6 years, 5 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 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/observer_list_threadsafe.h" 9 #include "base/observer_list_threadsafe.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 29 matching lines...) Expand all
40 CONNECTION_ETHERNET = 1, 40 CONNECTION_ETHERNET = 1,
41 CONNECTION_WIFI = 2, 41 CONNECTION_WIFI = 2,
42 CONNECTION_2G = 3, 42 CONNECTION_2G = 3,
43 CONNECTION_3G = 4, 43 CONNECTION_3G = 4,
44 CONNECTION_4G = 5, 44 CONNECTION_4G = 5,
45 CONNECTION_NONE = 6, // No connection. 45 CONNECTION_NONE = 6, // No connection.
46 CONNECTION_BLUETOOTH = 7, 46 CONNECTION_BLUETOOTH = 7,
47 CONNECTION_LAST = CONNECTION_BLUETOOTH 47 CONNECTION_LAST = CONNECTION_BLUETOOTH
48 }; 48 };
49 49
50 // Wifi access point security mode definitions.
51 enum WifiSecurityMode {
52 WIFI_SECURITY_UNKNOWN = 0,
53 WIFI_SECURITY_WPA = 1,
54 WIFI_SECURITY_WEP = 2,
55 WIFI_SECURITY_RSN = 3,
56 WIFI_SECURITY_802_1X = 4,
57 WIFI_SECURITY_PSK = 5,
58 WIFI_SECURITY_NONE
59 };
60
61 // Information of the currently connected wifi access point.
62 struct NET_EXPORT WifiAccessPointInfo {
63 WifiAccessPointInfo();
stevenjb 2014/07/15 18:16:14 nit: struct constructor can be inlined
zqiu1 2014/07/15 19:34:02 There are structs with constructor/destructor that
64 ~WifiAccessPointInfo();
stevenjb 2014/07/15 18:16:14 No need for empty destructor in struct
zqiu1 2014/07/15 19:34:02 I think this is still needed, encountered compilat
stevenjb 2014/07/15 19:45:08 Ah, right, I forgot about that. OK.
65 WifiSecurityMode security;
66 std::string bssid;
67 std::string model_number;
68 std::string model_name;
69 std::string device_name;
70 std::string oui_list;
71 };
72
50 class NET_EXPORT IPAddressObserver { 73 class NET_EXPORT IPAddressObserver {
51 public: 74 public:
52 // Will be called when the IP address of the primary interface changes. 75 // Will be called when the IP address of the primary interface changes.
53 // This includes when the primary interface itself changes. 76 // This includes when the primary interface itself changes.
54 virtual void OnIPAddressChanged() = 0; 77 virtual void OnIPAddressChanged() = 0;
55 78
56 protected: 79 protected:
57 IPAddressObserver() {} 80 IPAddressObserver() {}
58 virtual ~IPAddressObserver() {} 81 virtual ~IPAddressObserver() {}
59 82
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 DISALLOW_COPY_AND_ASSIGN(NetworkChangeObserver); 151 DISALLOW_COPY_AND_ASSIGN(NetworkChangeObserver);
129 }; 152 };
130 153
131 virtual ~NetworkChangeNotifier(); 154 virtual ~NetworkChangeNotifier();
132 155
133 // See the description of NetworkChangeNotifier::GetConnectionType(). 156 // See the description of NetworkChangeNotifier::GetConnectionType().
134 // Implementations must be thread-safe. Implementations must also be 157 // Implementations must be thread-safe. Implementations must also be
135 // cheap as this could be called (repeatedly) from the network thread. 158 // cheap as this could be called (repeatedly) from the network thread.
136 virtual ConnectionType GetCurrentConnectionType() const = 0; 159 virtual ConnectionType GetCurrentConnectionType() const = 0;
137 160
161 // Fill in the wifi access point info if device is currently connected to a
162 // wifi access point. Return true if device is connected to a wifi access
163 // point, false otherwise.
164 virtual bool GetCurrentWifiAccessPointInfo(WifiAccessPointInfo* info);
165
138 // Replaces the default class factory instance of NetworkChangeNotifier class. 166 // Replaces the default class factory instance of NetworkChangeNotifier class.
139 // The method will take over the ownership of |factory| object. 167 // The method will take over the ownership of |factory| object.
140 static void SetFactory(NetworkChangeNotifierFactory* factory); 168 static void SetFactory(NetworkChangeNotifierFactory* factory);
141 169
142 // Creates the process-wide, platform-specific NetworkChangeNotifier. The 170 // Creates the process-wide, platform-specific NetworkChangeNotifier. The
143 // caller owns the returned pointer. You may call this on any thread. You 171 // caller owns the returned pointer. You may call this on any thread. You
144 // may also avoid creating this entirely (in which case nothing will be 172 // may also avoid creating this entirely (in which case nothing will be
145 // monitored), but if you do create it, you must do so before any other 173 // monitored), but if you do create it, you must do so before any other
146 // threads try to access the API below, and it must outlive all other threads 174 // threads try to access the API below, and it must outlive all other threads
147 // which might try to use it. 175 // which might try to use it.
148 static NetworkChangeNotifier* Create(); 176 static NetworkChangeNotifier* Create();
149 177
150 // Returns the connection type. 178 // Returns the connection type.
151 // A return value of |CONNECTION_NONE| is a pretty strong indicator that the 179 // A return value of |CONNECTION_NONE| is a pretty strong indicator that the
152 // user won't be able to connect to remote sites. However, another return 180 // user won't be able to connect to remote sites. However, another return
153 // value doesn't imply that the user will be able to connect to remote sites; 181 // value doesn't imply that the user will be able to connect to remote sites;
154 // even if some link is up, it is uncertain whether a particular connection 182 // even if some link is up, it is uncertain whether a particular connection
155 // attempt to a particular remote site will be successful. 183 // attempt to a particular remote site will be successful.
156 // The returned value only describes the connection currently used by the 184 // The returned value only describes the connection currently used by the
157 // device, and does not take into account other machines on the network. For 185 // device, and does not take into account other machines on the network. For
158 // example, if the device is connected using Wifi to a 3G gateway to access 186 // example, if the device is connected using Wifi to a 3G gateway to access
159 // the internet, the connection type is CONNECTION_WIFI. 187 // the internet, the connection type is CONNECTION_WIFI.
160 static ConnectionType GetConnectionType(); 188 static ConnectionType GetConnectionType();
161 189
190 // Retreive the wifi access point info.
191 static bool GetWifiAccessPointInfo(WifiAccessPointInfo* info);
192
162 // Retrieve the last read DnsConfig. This could be expensive if the system has 193 // Retrieve the last read DnsConfig. This could be expensive if the system has
163 // a large HOSTS file. 194 // a large HOSTS file.
164 static void GetDnsConfig(DnsConfig* config); 195 static void GetDnsConfig(DnsConfig* config);
165 196
166 #if defined(OS_LINUX) 197 #if defined(OS_LINUX)
167 // Returns the AddressTrackerLinux if present. 198 // Returns the AddressTrackerLinux if present.
168 static const internal::AddressTrackerLinux* GetAddressTracker(); 199 static const internal::AddressTrackerLinux* GetAddressTracker();
169 #endif 200 #endif
170 201
171 // Convenience method to determine if the user is offline. 202 // Convenience method to determine if the user is offline.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 370
340 // Set true to disable non-test notifications (to prevent flakes in tests). 371 // Set true to disable non-test notifications (to prevent flakes in tests).
341 bool test_notifications_only_; 372 bool test_notifications_only_;
342 373
343 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); 374 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier);
344 }; 375 };
345 376
346 } // namespace net 377 } // namespace net
347 378
348 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 379 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698