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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 17 matching lines...) Expand all
28 // NetworkChangeNotifier monitors the system for network changes, and notifies 28 // NetworkChangeNotifier monitors the system for network changes, and notifies
29 // registered observers of those events. Observers may register on any thread, 29 // registered observers of those events. Observers may register on any thread,
30 // and will be called back on the thread from which they registered. 30 // and will be called back on the thread from which they registered.
31 // NetworkChangeNotifiers are threadsafe, though they must be created and 31 // NetworkChangeNotifiers are threadsafe, though they must be created and
32 // destroyed on the same thread. 32 // destroyed on the same thread.
33 class NET_EXPORT NetworkChangeNotifier { 33 class NET_EXPORT NetworkChangeNotifier {
34 public: 34 public:
35 // Using the terminology of the Network Information API: 35 // Using the terminology of the Network Information API:
36 // http://www.w3.org/TR/netinfo-api. 36 // http://www.w3.org/TR/netinfo-api.
37 enum ConnectionType { 37 enum ConnectionType {
38 CONNECTION_UNKNOWN = 0, // A connection exists, but its type is unknown. 38 CONNECTION_UNKNOWN = 0, // A connection exists, but its type is unknown.
39 CONNECTION_ETHERNET = 1, 39 CONNECTION_ETHERNET = 1,
40 CONNECTION_WIFI = 2, 40 CONNECTION_WIFI = 2,
41 CONNECTION_2G = 3, 41 CONNECTION_2G = 3,
42 CONNECTION_3G = 4, 42 CONNECTION_3G = 4,
43 CONNECTION_4G = 5, 43 CONNECTION_4G = 5,
44 CONNECTION_NONE = 6 // No connection. 44 CONNECTION_NONE = 6 // No connection.
45 }; 45 };
46 46
47 class NET_EXPORT IPAddressObserver { 47 class NET_EXPORT IPAddressObserver {
48 public: 48 public:
49 // Will be called when the IP address of the primary interface changes. 49 // Will be called when the IP address of the primary interface changes.
50 // This includes when the primary interface itself changes. 50 // This includes when the primary interface itself changes.
51 virtual void OnIPAddressChanged() = 0; 51 virtual void OnIPAddressChanged() = 0;
52 52
53 protected: 53 protected:
54 IPAddressObserver() {} 54 IPAddressObserver() {}
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // online state. 265 // online state.
266 base::TimeDelta ip_address_online_delay_; 266 base::TimeDelta ip_address_online_delay_;
267 // Controls delay after OnConnectionTypeChanged when transitioning from an 267 // Controls delay after OnConnectionTypeChanged when transitioning from an
268 // offline state. 268 // offline state.
269 base::TimeDelta connection_type_offline_delay_; 269 base::TimeDelta connection_type_offline_delay_;
270 // Controls delay after OnConnectionTypeChanged when transitioning from an 270 // Controls delay after OnConnectionTypeChanged when transitioning from an
271 // online state. 271 // online state.
272 base::TimeDelta connection_type_online_delay_; 272 base::TimeDelta connection_type_online_delay_;
273 }; 273 };
274 274
275 explicit NetworkChangeNotifier( 275 explicit NetworkChangeNotifier(const NetworkChangeCalculatorParams& params =
276 const NetworkChangeCalculatorParams& params = 276 NetworkChangeCalculatorParams());
277 NetworkChangeCalculatorParams());
278 277
279 #if defined(OS_LINUX) 278 #if defined(OS_LINUX)
280 // Returns the AddressTrackerLinux if present. 279 // Returns the AddressTrackerLinux if present.
281 // TODO(szym): Retrieve AddressMap from NetworkState. http://crbug.com/144212 280 // TODO(szym): Retrieve AddressMap from NetworkState. http://crbug.com/144212
282 virtual const internal::AddressTrackerLinux* 281 virtual const internal::AddressTrackerLinux* GetAddressTrackerInternal()
283 GetAddressTrackerInternal() const; 282 const;
284 #endif 283 #endif
285 284
286 // Broadcasts a notification to all registered observers. Note that this 285 // Broadcasts a notification to all registered observers. Note that this
287 // happens asynchronously, even for observers on the current thread, even in 286 // happens asynchronously, even for observers on the current thread, even in
288 // tests. 287 // tests.
289 static void NotifyObserversOfIPAddressChange(); 288 static void NotifyObserversOfIPAddressChange();
290 static void NotifyObserversOfConnectionTypeChange(); 289 static void NotifyObserversOfConnectionTypeChange();
291 static void NotifyObserversOfDNSChange(); 290 static void NotifyObserversOfDNSChange();
292 static void NotifyObserversOfNetworkChange(ConnectionType type); 291 static void NotifyObserversOfNetworkChange(ConnectionType type);
293 292
(...skipping 26 matching lines...) Expand all
320 319
321 // Computes NetworkChange signal from IPAddress and ConnectionType signals. 320 // Computes NetworkChange signal from IPAddress and ConnectionType signals.
322 scoped_ptr<NetworkChangeCalculator> network_change_calculator_; 321 scoped_ptr<NetworkChangeCalculator> network_change_calculator_;
323 322
324 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); 323 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier);
325 }; 324 };
326 325
327 } // namespace net 326 } // namespace net
328 327
329 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ 328 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698