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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 // type. | 284 // type. |
285 static void GetMaxBandwidthAndConnectionType(double* max_bandwidth_mbps, | 285 static void GetMaxBandwidthAndConnectionType(double* max_bandwidth_mbps, |
286 ConnectionType* connection_type); | 286 ConnectionType* connection_type); |
287 | 287 |
288 // Returns a theoretical upper limit (in Mbps) on download bandwidth given a | 288 // Returns a theoretical upper limit (in Mbps) on download bandwidth given a |
289 // connection subtype. The mapping of connection type to maximum bandwidth is | 289 // connection subtype. The mapping of connection type to maximum bandwidth is |
290 // provided in the NetInfo spec: http://w3c.github.io/netinfo/. | 290 // provided in the NetInfo spec: http://w3c.github.io/netinfo/. |
291 // TODO(jkarlin): Rename to GetMaxBandwidthMbpsForConnectionSubtype. | 291 // TODO(jkarlin): Rename to GetMaxBandwidthMbpsForConnectionSubtype. |
292 static double GetMaxBandwidthForConnectionSubtype(ConnectionSubtype subtype); | 292 static double GetMaxBandwidthForConnectionSubtype(ConnectionSubtype subtype); |
293 | 293 |
294 // Returns true if the platform supports use of APIs based on NetworkHandles. | |
295 // Public methods that use NetworkHandles are GetNetworkConnectionType(), | |
296 // GetNetworkConnectionType(), GetDefaultNetwork(), AddNetworkObserver(), | |
297 // RemoveNetworkObserver, and all public NetworkObserver methods. | |
pauljensen
2015/12/01 12:34:44
RemoveNetworkObserver->RemoveNetworkObserver()
| |
298 static bool AreNetworkHandlesSupported(); | |
299 | |
294 // Sets |network_list| to a list of all networks that are currently connected. | 300 // Sets |network_list| to a list of all networks that are currently connected. |
295 // Only implemented for Android (Lollipop and newer), leaves |network_list| | 301 // Only implemented for Android (Lollipop and newer), leaves |network_list| |
296 // empty when unimplemented. | 302 // empty when unimplemented. Requires NetworkHandles support, see |
303 // AreNetworkHandlesSupported(). | |
297 static void GetConnectedNetworks(NetworkList* network_list); | 304 static void GetConnectedNetworks(NetworkList* network_list); |
298 | 305 |
299 // Returns the type of connection |network| uses. Note that this may vary | 306 // Returns the type of connection |network| uses. Note that this may vary |
300 // slightly over time (e.g. CONNECTION_2G to CONNECTION_3G). If |network| | 307 // slightly over time (e.g. CONNECTION_2G to CONNECTION_3G). If |network| |
301 // is no longer connected, it will return CONNECTION_UNKNOWN. | 308 // is no longer connected, it will return CONNECTION_UNKNOWN. |
302 // Only implemented for Android (Lollipop and newer), returns | 309 // Only implemented for Android (Lollipop and newer), returns |
303 // CONNECTION_UNKNOWN when unimplemented. | 310 // CONNECTION_UNKNOWN when unimplemented. Requires NetworkHandles support, |
311 // see AreNetworkHandlesSupported(). | |
304 static ConnectionType GetNetworkConnectionType(NetworkHandle network); | 312 static ConnectionType GetNetworkConnectionType(NetworkHandle network); |
305 | 313 |
306 // Returns the device's current default network connection. This is the | 314 // Returns the device's current default network connection. This is the |
307 // network used for newly created socket communication for sockets that are | 315 // network used for newly created socket communication for sockets that are |
308 // not explicitly bound to a particular network (e.g. via | 316 // not explicitly bound to a particular network (e.g. via |
309 // DatagramClientSocket.BindToNetwork). Returns |kInvalidNetworkHandle| if | 317 // DatagramClientSocket.BindToNetwork). Returns |kInvalidNetworkHandle| if |
310 // there is no default connected network. | 318 // there is no default connected network. |
311 // Only implemented for Android (Lollipop and newer), returns | 319 // Only implemented for Android (Lollipop and newer), returns |
312 // |kInvalidNetworkHandle| when unimplemented. | 320 // |kInvalidNetworkHandle| when unimplemented. |
321 // Requires NetworkHandles support, see AreNetworkHandlesSupported(). | |
313 static NetworkHandle GetDefaultNetwork(); | 322 static NetworkHandle GetDefaultNetwork(); |
314 | 323 |
315 // Retrieve the last read DnsConfig. This could be expensive if the system has | 324 // Retrieve the last read DnsConfig. This could be expensive if the system has |
316 // a large HOSTS file. | 325 // a large HOSTS file. |
317 static void GetDnsConfig(DnsConfig* config); | 326 static void GetDnsConfig(DnsConfig* config); |
318 | 327 |
319 #if defined(OS_LINUX) | 328 #if defined(OS_LINUX) |
320 // Returns the AddressTrackerLinux if present. | 329 // Returns the AddressTrackerLinux if present. |
321 static const internal::AddressTrackerLinux* GetAddressTracker(); | 330 static const internal::AddressTrackerLinux* GetAddressTracker(); |
322 #endif | 331 #endif |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 #endif | 483 #endif |
475 | 484 |
476 // These are the actual implementations of the static queryable APIs. | 485 // These are the actual implementations of the static queryable APIs. |
477 // See the description of the corresponding functions named without "Current". | 486 // See the description of the corresponding functions named without "Current". |
478 // Implementations must be thread-safe. Implementations must also be | 487 // Implementations must be thread-safe. Implementations must also be |
479 // cheap as they are called often. | 488 // cheap as they are called often. |
480 virtual ConnectionType GetCurrentConnectionType() const = 0; | 489 virtual ConnectionType GetCurrentConnectionType() const = 0; |
481 virtual void GetCurrentMaxBandwidthAndConnectionType( | 490 virtual void GetCurrentMaxBandwidthAndConnectionType( |
482 double* max_bandwidth_mbps, | 491 double* max_bandwidth_mbps, |
483 ConnectionType* connection_type) const; | 492 ConnectionType* connection_type) const; |
493 virtual bool AreNetworkHandlesCurrentlySupported() const; | |
484 virtual void GetCurrentConnectedNetworks(NetworkList* network_list) const; | 494 virtual void GetCurrentConnectedNetworks(NetworkList* network_list) const; |
485 virtual ConnectionType GetCurrentNetworkConnectionType( | 495 virtual ConnectionType GetCurrentNetworkConnectionType( |
486 NetworkHandle network) const; | 496 NetworkHandle network) const; |
487 virtual NetworkHandle GetCurrentDefaultNetwork() const; | 497 virtual NetworkHandle GetCurrentDefaultNetwork() const; |
488 | 498 |
489 // Broadcasts a notification to all registered observers. Note that this | 499 // Broadcasts a notification to all registered observers. Note that this |
490 // happens asynchronously, even for observers on the current thread, even in | 500 // happens asynchronously, even for observers on the current thread, even in |
491 // tests. | 501 // tests. |
492 static void NotifyObserversOfIPAddressChange(); | 502 static void NotifyObserversOfIPAddressChange(); |
493 static void NotifyObserversOfConnectionTypeChange(); | 503 static void NotifyObserversOfConnectionTypeChange(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 | 558 |
549 // Set true to disable non-test notifications (to prevent flakes in tests). | 559 // Set true to disable non-test notifications (to prevent flakes in tests). |
550 static bool test_notifications_only_; | 560 static bool test_notifications_only_; |
551 | 561 |
552 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); | 562 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
553 }; | 563 }; |
554 | 564 |
555 } // namespace net | 565 } // namespace net |
556 | 566 |
557 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 567 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
OLD | NEW |