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 API based on NetworkHandles. | |
pauljensen
2015/11/30 20:23:48
API->APIs
| |
295 // Public methods that use NetworkHandles are GetNetworkConnectionType(), | |
296 // GetNetworkConnectionType(), and GetDefaultNetwork(). | |
pauljensen
2015/11/30 20:23:48
please also mention NetworkObserver
Jana
2015/11/30 22:31:06
Done.
| |
297 static bool AreNetworkHandlesSupported(); | |
298 | |
294 // Sets |network_list| to a list of all networks that are currently connected. | 299 // Sets |network_list| to a list of all networks that are currently connected. |
295 // Only implemented for Android (Lollipop and newer), leaves |network_list| | 300 // Only implemented for Android (Lollipop and newer), leaves |network_list| |
296 // empty when unimplemented. | 301 // empty when unimplemented. Requires NetworkHandles support. |
pauljensen
2015/11/30 20:23:48
support->support, see AreNetworkHandlesSupported()
Jana
2015/11/30 22:31:06
Done.
| |
297 static void GetConnectedNetworks(NetworkList* network_list); | 302 static void GetConnectedNetworks(NetworkList* network_list); |
298 | 303 |
299 // Returns the type of connection |network| uses. Note that this may vary | 304 // 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| | 305 // slightly over time (e.g. CONNECTION_2G to CONNECTION_3G). If |network| |
301 // is no longer connected, it will return CONNECTION_UNKNOWN. | 306 // is no longer connected, it will return CONNECTION_UNKNOWN. |
302 // Only implemented for Android (Lollipop and newer), returns | 307 // Only implemented for Android (Lollipop and newer), returns |
303 // CONNECTION_UNKNOWN when unimplemented. | 308 // CONNECTION_UNKNOWN when unimplemented. Requires NetworkHandles support. |
pauljensen
2015/11/30 20:23:48
ditto
Jana
2015/11/30 22:31:06
Done.
| |
304 static ConnectionType GetNetworkConnectionType(NetworkHandle network); | 309 static ConnectionType GetNetworkConnectionType(NetworkHandle network); |
305 | 310 |
306 // Returns the device's current default network connection. This is the | 311 // Returns the device's current default network connection. This is the |
307 // network used for newly created socket communication for sockets that are | 312 // network used for newly created socket communication for sockets that are |
308 // not explicitly bound to a particular network (e.g. via | 313 // not explicitly bound to a particular network (e.g. via |
309 // DatagramClientSocket.BindToNetwork). Returns |kInvalidNetworkHandle| if | 314 // DatagramClientSocket.BindToNetwork). Returns |kInvalidNetworkHandle| if |
310 // there is no default connected network. | 315 // there is no default connected network. |
311 // Only implemented for Android (Lollipop and newer), returns | 316 // Only implemented for Android (Lollipop and newer), returns |
312 // |kInvalidNetworkHandle| when unimplemented. | 317 // |kInvalidNetworkHandle| when unimplemented. |
318 // Requires NetworkHandles support. | |
pauljensen
2015/11/30 20:23:48
ditto
Jana
2015/11/30 22:31:06
Done.
| |
313 static NetworkHandle GetDefaultNetwork(); | 319 static NetworkHandle GetDefaultNetwork(); |
314 | 320 |
315 // Retrieve the last read DnsConfig. This could be expensive if the system has | 321 // Retrieve the last read DnsConfig. This could be expensive if the system has |
316 // a large HOSTS file. | 322 // a large HOSTS file. |
317 static void GetDnsConfig(DnsConfig* config); | 323 static void GetDnsConfig(DnsConfig* config); |
318 | 324 |
319 #if defined(OS_LINUX) | 325 #if defined(OS_LINUX) |
320 // Returns the AddressTrackerLinux if present. | 326 // Returns the AddressTrackerLinux if present. |
321 static const internal::AddressTrackerLinux* GetAddressTracker(); | 327 static const internal::AddressTrackerLinux* GetAddressTracker(); |
322 #endif | 328 #endif |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 #endif | 480 #endif |
475 | 481 |
476 // These are the actual implementations of the static queryable APIs. | 482 // These are the actual implementations of the static queryable APIs. |
477 // See the description of the corresponding functions named without "Current". | 483 // See the description of the corresponding functions named without "Current". |
478 // Implementations must be thread-safe. Implementations must also be | 484 // Implementations must be thread-safe. Implementations must also be |
479 // cheap as they are called often. | 485 // cheap as they are called often. |
480 virtual ConnectionType GetCurrentConnectionType() const = 0; | 486 virtual ConnectionType GetCurrentConnectionType() const = 0; |
481 virtual void GetCurrentMaxBandwidthAndConnectionType( | 487 virtual void GetCurrentMaxBandwidthAndConnectionType( |
482 double* max_bandwidth_mbps, | 488 double* max_bandwidth_mbps, |
483 ConnectionType* connection_type) const; | 489 ConnectionType* connection_type) const; |
490 virtual bool AreNetworkHandlesCurrentlySupported() const; | |
484 virtual void GetCurrentConnectedNetworks(NetworkList* network_list) const; | 491 virtual void GetCurrentConnectedNetworks(NetworkList* network_list) const; |
485 virtual ConnectionType GetCurrentNetworkConnectionType( | 492 virtual ConnectionType GetCurrentNetworkConnectionType( |
486 NetworkHandle network) const; | 493 NetworkHandle network) const; |
487 virtual NetworkHandle GetCurrentDefaultNetwork() const; | 494 virtual NetworkHandle GetCurrentDefaultNetwork() const; |
488 | 495 |
489 // Broadcasts a notification to all registered observers. Note that this | 496 // Broadcasts a notification to all registered observers. Note that this |
490 // happens asynchronously, even for observers on the current thread, even in | 497 // happens asynchronously, even for observers on the current thread, even in |
491 // tests. | 498 // tests. |
492 static void NotifyObserversOfIPAddressChange(); | 499 static void NotifyObserversOfIPAddressChange(); |
493 static void NotifyObserversOfConnectionTypeChange(); | 500 static void NotifyObserversOfConnectionTypeChange(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 | 555 |
549 // Set true to disable non-test notifications (to prevent flakes in tests). | 556 // Set true to disable non-test notifications (to prevent flakes in tests). |
550 static bool test_notifications_only_; | 557 static bool test_notifications_only_; |
551 | 558 |
552 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); | 559 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
553 }; | 560 }; |
554 | 561 |
555 } // namespace net | 562 } // namespace net |
556 | 563 |
557 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 564 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
OLD | NEW |