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

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: 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 AP.
62 struct NET_EXPORT WifiApInfo {
63 WifiSecurityMode security;
64 std::string bssid;
65 std::string model_number;
66 std::string model_name;
67 std::string device_name;
68 std::string oui_list;
69 };
70
50 class NET_EXPORT IPAddressObserver { 71 class NET_EXPORT IPAddressObserver {
51 public: 72 public:
52 // Will be called when the IP address of the primary interface changes. 73 // Will be called when the IP address of the primary interface changes.
53 // This includes when the primary interface itself changes. 74 // This includes when the primary interface itself changes.
54 virtual void OnIPAddressChanged() = 0; 75 virtual void OnIPAddressChanged() = 0;
55 76
56 protected: 77 protected:
57 IPAddressObserver() {} 78 IPAddressObserver() {}
58 virtual ~IPAddressObserver() {} 79 virtual ~IPAddressObserver() {}
59 80
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 DISALLOW_COPY_AND_ASSIGN(NetworkChangeObserver); 149 DISALLOW_COPY_AND_ASSIGN(NetworkChangeObserver);
129 }; 150 };
130 151
131 virtual ~NetworkChangeNotifier(); 152 virtual ~NetworkChangeNotifier();
132 153
133 // See the description of NetworkChangeNotifier::GetConnectionType(). 154 // See the description of NetworkChangeNotifier::GetConnectionType().
134 // Implementations must be thread-safe. Implementations must also be 155 // Implementations must be thread-safe. Implementations must also be
135 // cheap as this could be called (repeatedly) from the network thread. 156 // cheap as this could be called (repeatedly) from the network thread.
136 virtual ConnectionType GetCurrentConnectionType() const = 0; 157 virtual ConnectionType GetCurrentConnectionType() const = 0;
137 158
159 // Fill in the wifi AP info if device is currently connected to a wifi AP,
160 // Return true if device is connected to a wifi AP, false otherwise.
161 virtual bool GetCurrentWifiApInfo(WifiApInfo &info);
stevenjb 2014/07/08 00:24:53 *info
zqiu1 2014/07/08 20:47:53 Done.
162
138 // Replaces the default class factory instance of NetworkChangeNotifier class. 163 // Replaces the default class factory instance of NetworkChangeNotifier class.
139 // The method will take over the ownership of |factory| object. 164 // The method will take over the ownership of |factory| object.
140 static void SetFactory(NetworkChangeNotifierFactory* factory); 165 static void SetFactory(NetworkChangeNotifierFactory* factory);
141 166
142 // Creates the process-wide, platform-specific NetworkChangeNotifier. The 167 // Creates the process-wide, platform-specific NetworkChangeNotifier. The
143 // caller owns the returned pointer. You may call this on any thread. You 168 // 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 169 // 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 170 // 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 171 // threads try to access the API below, and it must outlive all other threads
147 // which might try to use it. 172 // which might try to use it.
148 static NetworkChangeNotifier* Create(); 173 static NetworkChangeNotifier* Create();
149 174
150 // Returns the connection type. 175 // Returns the connection type.
151 // A return value of |CONNECTION_NONE| is a pretty strong indicator that the 176 // 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 177 // 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; 178 // 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 179 // even if some link is up, it is uncertain whether a particular connection
155 // attempt to a particular remote site will be successful. 180 // attempt to a particular remote site will be successful.
156 // The returned value only describes the connection currently used by the 181 // 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 182 // 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 183 // example, if the device is connected using Wifi to a 3G gateway to access
159 // the internet, the connection type is CONNECTION_WIFI. 184 // the internet, the connection type is CONNECTION_WIFI.
160 static ConnectionType GetConnectionType(); 185 static ConnectionType GetConnectionType();
161 186
187 // Retreive the wifi AP info.
188 static bool GetWifiApInfo(WifiApInfo &info);
stevenjb 2014/07/08 00:24:53 *info
zqiu1 2014/07/08 20:47:53 Done.
189
162 // Retrieve the last read DnsConfig. This could be expensive if the system has 190 // Retrieve the last read DnsConfig. This could be expensive if the system has
163 // a large HOSTS file. 191 // a large HOSTS file.
164 static void GetDnsConfig(DnsConfig* config); 192 static void GetDnsConfig(DnsConfig* config);
165 193
166 #if defined(OS_LINUX) 194 #if defined(OS_LINUX)
167 // Returns the AddressTrackerLinux if present. 195 // Returns the AddressTrackerLinux if present.
168 static const internal::AddressTrackerLinux* GetAddressTracker(); 196 static const internal::AddressTrackerLinux* GetAddressTracker();
169 #endif 197 #endif
170 198
171 // Convenience method to determine if the user is offline. 199 // Convenience method to determine if the user is offline.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 367
340 // Set true to disable non-test notifications (to prevent flakes in tests). 368 // Set true to disable non-test notifications (to prevent flakes in tests).
341 bool test_notifications_only_; 369 bool test_notifications_only_;
342 370
343 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); 371 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier);
344 }; 372 };
345 373
346 } // namespace net 374 } // namespace net
347 375
348 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 376 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698