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

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, 6 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 28 matching lines...) Expand all
39 // Also used as a default value. 39 // Also used as a default value.
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_LAST = CONNECTION_NONE 46 CONNECTION_LAST = CONNECTION_NONE
47 }; 47 };
48 48
49 // Information of the currently connected wifi AP.
50 struct NET_EXPORT WifiApInfo {
51 WifiApInfo();
52 ~WifiApInfo();
stevenjb 2014/06/12 20:54:40 empty constructors (and destructors for no-virtual
zqiu1 2014/07/07 23:37:33 Done.
53
54 std::string bssid;
55 std::string security;
56 std::string model_number;
57 std::string model_name;
58 std::string device_name;
59 std::string manufacturer;
60 std::string oui_list;
61 };
62
49 class NET_EXPORT IPAddressObserver { 63 class NET_EXPORT IPAddressObserver {
50 public: 64 public:
51 // Will be called when the IP address of the primary interface changes. 65 // Will be called when the IP address of the primary interface changes.
52 // This includes when the primary interface itself changes. 66 // This includes when the primary interface itself changes.
53 virtual void OnIPAddressChanged() = 0; 67 virtual void OnIPAddressChanged() = 0;
54 68
55 protected: 69 protected:
56 IPAddressObserver() {} 70 IPAddressObserver() {}
57 virtual ~IPAddressObserver() {} 71 virtual ~IPAddressObserver() {}
58 72
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 DISALLOW_COPY_AND_ASSIGN(NetworkChangeObserver); 141 DISALLOW_COPY_AND_ASSIGN(NetworkChangeObserver);
128 }; 142 };
129 143
130 virtual ~NetworkChangeNotifier(); 144 virtual ~NetworkChangeNotifier();
131 145
132 // See the description of NetworkChangeNotifier::GetConnectionType(). 146 // See the description of NetworkChangeNotifier::GetConnectionType().
133 // Implementations must be thread-safe. Implementations must also be 147 // Implementations must be thread-safe. Implementations must also be
134 // cheap as this could be called (repeatedly) from the network thread. 148 // cheap as this could be called (repeatedly) from the network thread.
135 virtual ConnectionType GetCurrentConnectionType() const = 0; 149 virtual ConnectionType GetCurrentConnectionType() const = 0;
136 150
151 // Fill in the wifi AP info if device is currently connected to a wifi AP,
152 // Return true if device is connected to a wifi AP, false otherwise.
153 virtual bool GetCurrentWifiApInfo(WifiApInfo &info) { return false; }
stevenjb 2014/06/12 20:54:40 virtual methods should never be inlined (only exec
zqiu1 2014/07/07 23:37:33 Done.
154
137 // Replaces the default class factory instance of NetworkChangeNotifier class. 155 // Replaces the default class factory instance of NetworkChangeNotifier class.
138 // The method will take over the ownership of |factory| object. 156 // The method will take over the ownership of |factory| object.
139 static void SetFactory(NetworkChangeNotifierFactory* factory); 157 static void SetFactory(NetworkChangeNotifierFactory* factory);
140 158
141 // Creates the process-wide, platform-specific NetworkChangeNotifier. The 159 // Creates the process-wide, platform-specific NetworkChangeNotifier. The
142 // caller owns the returned pointer. You may call this on any thread. You 160 // caller owns the returned pointer. You may call this on any thread. You
143 // may also avoid creating this entirely (in which case nothing will be 161 // may also avoid creating this entirely (in which case nothing will be
144 // monitored), but if you do create it, you must do so before any other 162 // monitored), but if you do create it, you must do so before any other
145 // threads try to access the API below, and it must outlive all other threads 163 // threads try to access the API below, and it must outlive all other threads
146 // which might try to use it. 164 // which might try to use it.
147 static NetworkChangeNotifier* Create(); 165 static NetworkChangeNotifier* Create();
148 166
149 // Returns the connection type. 167 // Returns the connection type.
150 // A return value of |CONNECTION_NONE| is a pretty strong indicator that the 168 // A return value of |CONNECTION_NONE| is a pretty strong indicator that the
151 // user won't be able to connect to remote sites. However, another return 169 // user won't be able to connect to remote sites. However, another return
152 // value doesn't imply that the user will be able to connect to remote sites; 170 // value doesn't imply that the user will be able to connect to remote sites;
153 // even if some link is up, it is uncertain whether a particular connection 171 // even if some link is up, it is uncertain whether a particular connection
154 // attempt to a particular remote site will be successful. 172 // attempt to a particular remote site will be successful.
155 // The returned value only describes the connection currently used by the 173 // The returned value only describes the connection currently used by the
156 // device, and does not take into account other machines on the network. For 174 // device, and does not take into account other machines on the network. For
157 // example, if the device is connected using Wifi to a 3G gateway to access 175 // example, if the device is connected using Wifi to a 3G gateway to access
158 // the internet, the connection type is CONNECTION_WIFI. 176 // the internet, the connection type is CONNECTION_WIFI.
159 static ConnectionType GetConnectionType(); 177 static ConnectionType GetConnectionType();
160 178
179 // Retreive the wifi AP info.
180 static bool GetWifiApInfo(WifiApInfo &info);
181
161 // Retrieve the last read DnsConfig. This could be expensive if the system has 182 // Retrieve the last read DnsConfig. This could be expensive if the system has
162 // a large HOSTS file. 183 // a large HOSTS file.
163 static void GetDnsConfig(DnsConfig* config); 184 static void GetDnsConfig(DnsConfig* config);
164 185
165 #if defined(OS_LINUX) 186 #if defined(OS_LINUX)
166 // Returns the AddressTrackerLinux if present. 187 // Returns the AddressTrackerLinux if present.
167 static const internal::AddressTrackerLinux* GetAddressTracker(); 188 static const internal::AddressTrackerLinux* GetAddressTracker();
168 #endif 189 #endif
169 190
170 // Convenience method to determine if the user is offline. 191 // Convenience method to determine if the user is offline.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 346
326 // Computes NetworkChange signal from IPAddress and ConnectionType signals. 347 // Computes NetworkChange signal from IPAddress and ConnectionType signals.
327 scoped_ptr<NetworkChangeCalculator> network_change_calculator_; 348 scoped_ptr<NetworkChangeCalculator> network_change_calculator_;
328 349
329 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); 350 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier);
330 }; 351 };
331 352
332 } // namespace net 353 } // namespace net
333 354
334 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 355 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698