Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 24 matching lines...) Expand all Loading... | |
| 35 // This is a superset of the connection types in the NetInfo v3 specification: | 35 // This is a superset of the connection types in the NetInfo v3 specification: |
| 36 // http://w3c.github.io/netinfo/. | 36 // http://w3c.github.io/netinfo/. |
| 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 // 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_BLUETOOTH = 7, | 46 CONNECTION_BLUETOOTH = 7, |
| 47 CONNECTION_LAST = CONNECTION_BLUETOOTH | 47 CONNECTION_LAST = CONNECTION_BLUETOOTH |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class NET_EXPORT IPAddressObserver { | 50 class NET_EXPORT IPAddressObserver { |
| 51 public: | 51 public: |
| 52 // Will be called when the IP address of the primary interface changes. | 52 // Will be called when the IP address of the primary interface changes. |
| 53 // This includes when the primary interface itself changes. | 53 // This includes when the primary interface itself changes. |
| 54 virtual void OnIPAddressChanged() = 0; | 54 virtual void OnIPAddressChanged() = 0; |
| 55 | 55 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 // online state. | 283 // online state. |
| 284 base::TimeDelta ip_address_online_delay_; | 284 base::TimeDelta ip_address_online_delay_; |
| 285 // Controls delay after OnConnectionTypeChanged when transitioning from an | 285 // Controls delay after OnConnectionTypeChanged when transitioning from an |
| 286 // offline state. | 286 // offline state. |
| 287 base::TimeDelta connection_type_offline_delay_; | 287 base::TimeDelta connection_type_offline_delay_; |
| 288 // Controls delay after OnConnectionTypeChanged when transitioning from an | 288 // Controls delay after OnConnectionTypeChanged when transitioning from an |
| 289 // online state. | 289 // online state. |
| 290 base::TimeDelta connection_type_online_delay_; | 290 base::TimeDelta connection_type_online_delay_; |
| 291 }; | 291 }; |
| 292 | 292 |
| 293 explicit NetworkChangeNotifier( | 293 explicit NetworkChangeNotifier(const NetworkChangeCalculatorParams& params = |
| 294 const NetworkChangeCalculatorParams& params = | 294 NetworkChangeCalculatorParams()); |
|
mef
2014/10/10 20:38:17
not sure about motivation of this alignment.
| |
| 295 NetworkChangeCalculatorParams()); | |
| 296 | 295 |
| 297 #if defined(OS_LINUX) | 296 #if defined(OS_LINUX) |
| 298 // Returns the AddressTrackerLinux if present. | 297 // Returns the AddressTrackerLinux if present. |
| 299 // TODO(szym): Retrieve AddressMap from NetworkState. http://crbug.com/144212 | 298 // TODO(szym): Retrieve AddressMap from NetworkState. http://crbug.com/144212 |
| 300 virtual const internal::AddressTrackerLinux* | 299 virtual const internal::AddressTrackerLinux* GetAddressTrackerInternal() |
| 301 GetAddressTrackerInternal() const; | 300 const; |
| 302 #endif | 301 #endif |
| 303 | 302 |
| 304 // See the description of NetworkChangeNotifier::GetMaxBandwidth(). | 303 // See the description of NetworkChangeNotifier::GetMaxBandwidth(). |
| 305 // Implementations must be thread-safe. Implementations must also be | 304 // Implementations must be thread-safe. Implementations must also be |
| 306 // cheap as it is called often. | 305 // cheap as it is called often. |
| 307 virtual double GetCurrentMaxBandwidth() const; | 306 virtual double GetCurrentMaxBandwidth() const; |
| 308 | 307 |
| 309 // Broadcasts a notification to all registered observers. Note that this | 308 // Broadcasts a notification to all registered observers. Note that this |
| 310 // happens asynchronously, even for observers on the current thread, even in | 309 // happens asynchronously, even for observers on the current thread, even in |
| 311 // tests. | 310 // tests. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 | 350 |
| 352 // Set true to disable non-test notifications (to prevent flakes in tests). | 351 // Set true to disable non-test notifications (to prevent flakes in tests). |
| 353 bool test_notifications_only_; | 352 bool test_notifications_only_; |
| 354 | 353 |
| 355 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); | 354 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
| 356 }; | 355 }; |
| 357 | 356 |
| 358 } // namespace net | 357 } // namespace net |
| 359 | 358 |
| 360 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 359 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
| OLD | NEW |