| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // empty when unimplemented. | 296 // empty when unimplemented. |
| 297 static void GetConnectedNetworks(NetworkList* network_list); | 297 static void GetConnectedNetworks(NetworkList* network_list); |
| 298 | 298 |
| 299 // Returns the type of connection |network| uses. Note that this may vary | 299 // 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| | 300 // slightly over time (e.g. CONNECTION_2G to CONNECTION_3G). If |network| |
| 301 // is no longer connected, it will return CONNECTION_UNKNOWN. | 301 // is no longer connected, it will return CONNECTION_UNKNOWN. |
| 302 // Only implemented for Android (Lollipop and newer), returns | 302 // Only implemented for Android (Lollipop and newer), returns |
| 303 // CONNECTION_UNKNOWN when unimplemented. | 303 // CONNECTION_UNKNOWN when unimplemented. |
| 304 static ConnectionType GetNetworkConnectionType(NetworkHandle network); | 304 static ConnectionType GetNetworkConnectionType(NetworkHandle network); |
| 305 | 305 |
| 306 // Returns the device's current default network connection. This is the | 306 // Determines the device's current default network connection. This is the |
| 307 // network used for newly created socket communication for sockets that are | 307 // network used for newly created socket communication for sockets that are |
| 308 // not explicitly bound to a particular network (e.g. via | 308 // not explicitly bound to a particular network (e.g. via |
| 309 // DatagramClientSocket.BindToNetwork). Returns |kInvalidNetworkHandle| if | 309 // DatagramClientSocket.BindToNetwork). Sets |*network| to the default network |
| 310 // there is no default connected network. | 310 // or |kInvalidNetworkHandle| if there is no default connected network. |
| 311 // Only implemented for Android (Lollipop and newer), returns | 311 // Only implemented for Android (Lollipop and newer). |
| 312 // |kInvalidNetworkHandle| when unimplemented. | 312 // Returns a net error code. |
| 313 static NetworkHandle GetDefaultNetwork(); | 313 static int GetDefaultNetwork(NetworkHandle* network); |
| 314 | 314 |
| 315 // Retrieve the last read DnsConfig. This could be expensive if the system has | 315 // Retrieve the last read DnsConfig. This could be expensive if the system has |
| 316 // a large HOSTS file. | 316 // a large HOSTS file. |
| 317 static void GetDnsConfig(DnsConfig* config); | 317 static void GetDnsConfig(DnsConfig* config); |
| 318 | 318 |
| 319 #if defined(OS_LINUX) | 319 #if defined(OS_LINUX) |
| 320 // Returns the AddressTrackerLinux if present. | 320 // Returns the AddressTrackerLinux if present. |
| 321 static const internal::AddressTrackerLinux* GetAddressTracker(); | 321 static const internal::AddressTrackerLinux* GetAddressTracker(); |
| 322 #endif | 322 #endif |
| 323 | 323 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 // See the description of the corresponding functions named without "Current". | 477 // See the description of the corresponding functions named without "Current". |
| 478 // Implementations must be thread-safe. Implementations must also be | 478 // Implementations must be thread-safe. Implementations must also be |
| 479 // cheap as they are called often. | 479 // cheap as they are called often. |
| 480 virtual ConnectionType GetCurrentConnectionType() const = 0; | 480 virtual ConnectionType GetCurrentConnectionType() const = 0; |
| 481 virtual void GetCurrentMaxBandwidthAndConnectionType( | 481 virtual void GetCurrentMaxBandwidthAndConnectionType( |
| 482 double* max_bandwidth_mbps, | 482 double* max_bandwidth_mbps, |
| 483 ConnectionType* connection_type) const; | 483 ConnectionType* connection_type) const; |
| 484 virtual void GetCurrentConnectedNetworks(NetworkList* network_list) const; | 484 virtual void GetCurrentConnectedNetworks(NetworkList* network_list) const; |
| 485 virtual ConnectionType GetCurrentNetworkConnectionType( | 485 virtual ConnectionType GetCurrentNetworkConnectionType( |
| 486 NetworkHandle network) const; | 486 NetworkHandle network) const; |
| 487 virtual NetworkHandle GetCurrentDefaultNetwork() const; | 487 virtual int GetCurrentDefaultNetwork(NetworkHandle* network) const; |
| 488 | 488 |
| 489 // Broadcasts a notification to all registered observers. Note that this | 489 // Broadcasts a notification to all registered observers. Note that this |
| 490 // happens asynchronously, even for observers on the current thread, even in | 490 // happens asynchronously, even for observers on the current thread, even in |
| 491 // tests. | 491 // tests. |
| 492 static void NotifyObserversOfIPAddressChange(); | 492 static void NotifyObserversOfIPAddressChange(); |
| 493 static void NotifyObserversOfConnectionTypeChange(); | 493 static void NotifyObserversOfConnectionTypeChange(); |
| 494 static void NotifyObserversOfDNSChange(); | 494 static void NotifyObserversOfDNSChange(); |
| 495 static void NotifyObserversOfInitialDNSConfigRead(); | 495 static void NotifyObserversOfInitialDNSConfigRead(); |
| 496 static void NotifyObserversOfNetworkChange(ConnectionType type); | 496 static void NotifyObserversOfNetworkChange(ConnectionType type); |
| 497 static void NotifyObserversOfMaxBandwidthChange(double max_bandwidth_mbps, | 497 static void NotifyObserversOfMaxBandwidthChange(double max_bandwidth_mbps, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 | 548 |
| 549 // Set true to disable non-test notifications (to prevent flakes in tests). | 549 // Set true to disable non-test notifications (to prevent flakes in tests). |
| 550 static bool test_notifications_only_; | 550 static bool test_notifications_only_; |
| 551 | 551 |
| 552 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); | 552 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
| 553 }; | 553 }; |
| 554 | 554 |
| 555 } // namespace net | 555 } // namespace net |
| 556 | 556 |
| 557 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 557 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
| OLD | NEW |