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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 // threads try to access the API below, and it must outlive all other threads | 263 // threads try to access the API below, and it must outlive all other threads |
264 // which might try to use it. | 264 // which might try to use it. |
265 static NetworkChangeNotifier* Create(); | 265 static NetworkChangeNotifier* Create(); |
266 | 266 |
267 // Returns the connection type. | 267 // Returns the connection type. |
268 // A return value of |CONNECTION_NONE| is a pretty strong indicator that the | 268 // A return value of |CONNECTION_NONE| is a pretty strong indicator that the |
269 // user won't be able to connect to remote sites. However, another return | 269 // user won't be able to connect to remote sites. However, another return |
270 // value doesn't imply that the user will be able to connect to remote sites; | 270 // value doesn't imply that the user will be able to connect to remote sites; |
271 // even if some link is up, it is uncertain whether a particular connection | 271 // even if some link is up, it is uncertain whether a particular connection |
272 // attempt to a particular remote site will be successful. | 272 // attempt to a particular remote site will be successful. |
273 // The returned value only describes the connection currently used by the | 273 // The returned value only describes the first-hop connection, for example if |
274 // device, and does not take into account other machines on the network. For | 274 // the device is connected via WiFi to a 4G hotspot, the returned value will |
275 // example, if the device is connected using Wifi to a 3G gateway to access | 275 // be CONNECTION_WIFI, not CONNECTION_4G. |
276 // the internet, the connection type is CONNECTION_WIFI. | |
277 static ConnectionType GetConnectionType(); | 276 static ConnectionType GetConnectionType(); |
278 | 277 |
| 278 // Returns the device's current default active network connection's subtype. |
| 279 // The returned value only describes the first-hop connection, for example if |
| 280 // the device is connected via WiFi to a 4G hotspot, the returned value will |
| 281 // reflect WiFi, not 4G. This method may return SUBTYPE_UNKNOWN even if the |
| 282 // connection type is known. |
| 283 static ConnectionSubtype GetConnectionSubtype(); |
| 284 |
279 // Sets |max_bandwidth_mbps| to a theoretical upper limit on download | 285 // Sets |max_bandwidth_mbps| to a theoretical upper limit on download |
280 // bandwidth, potentially based on underlying connection type, signal | 286 // bandwidth, potentially based on underlying connection type, signal |
281 // strength, or some other signal. If the network subtype is unknown then | 287 // strength, or some other signal. If the network subtype is unknown then |
282 // |max_bandwidth_mbps| is set to +Infinity and if there is no network | 288 // |max_bandwidth_mbps| is set to +Infinity and if there is no network |
283 // connection then it is set to 0.0. The circumstances in which a more | 289 // connection then it is set to 0.0. The circumstances in which a more |
284 // specific value is given are: when an Android device is connected to a | 290 // specific value is given are: when an Android device is connected to a |
285 // cellular or WiFi network, and when a ChromeOS device is connected to a | 291 // cellular or WiFi network, and when a ChromeOS device is connected to a |
286 // cellular network. See the NetInfo spec for the mapping of | 292 // cellular network. See the NetInfo spec for the mapping of |
287 // specific subtypes to bandwidth values: http://w3c.github.io/netinfo/. | 293 // specific subtypes to bandwidth values: http://w3c.github.io/netinfo/. |
288 // |connection_type| is set to the current active default network's connection | 294 // |connection_type| is set to the current active default network's connection |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 // TODO(szym): Retrieve AddressMap from NetworkState. http://crbug.com/144212 | 497 // TODO(szym): Retrieve AddressMap from NetworkState. http://crbug.com/144212 |
492 virtual const internal::AddressTrackerLinux* | 498 virtual const internal::AddressTrackerLinux* |
493 GetAddressTrackerInternal() const; | 499 GetAddressTrackerInternal() const; |
494 #endif | 500 #endif |
495 | 501 |
496 // These are the actual implementations of the static queryable APIs. | 502 // These are the actual implementations of the static queryable APIs. |
497 // See the description of the corresponding functions named without "Current". | 503 // See the description of the corresponding functions named without "Current". |
498 // Implementations must be thread-safe. Implementations must also be | 504 // Implementations must be thread-safe. Implementations must also be |
499 // cheap as they are called often. | 505 // cheap as they are called often. |
500 virtual ConnectionType GetCurrentConnectionType() const = 0; | 506 virtual ConnectionType GetCurrentConnectionType() const = 0; |
| 507 virtual ConnectionSubtype GetCurrentConnectionSubtype() const; |
501 virtual void GetCurrentMaxBandwidthAndConnectionType( | 508 virtual void GetCurrentMaxBandwidthAndConnectionType( |
502 double* max_bandwidth_mbps, | 509 double* max_bandwidth_mbps, |
503 ConnectionType* connection_type) const; | 510 ConnectionType* connection_type) const; |
504 virtual bool AreNetworkHandlesCurrentlySupported() const; | 511 virtual bool AreNetworkHandlesCurrentlySupported() const; |
505 virtual void GetCurrentConnectedNetworks(NetworkList* network_list) const; | 512 virtual void GetCurrentConnectedNetworks(NetworkList* network_list) const; |
506 virtual ConnectionType GetCurrentNetworkConnectionType( | 513 virtual ConnectionType GetCurrentNetworkConnectionType( |
507 NetworkHandle network) const; | 514 NetworkHandle network) const; |
508 virtual NetworkHandle GetCurrentDefaultNetwork() const; | 515 virtual NetworkHandle GetCurrentDefaultNetwork() const; |
509 | 516 |
510 // Hook that allows derived implementations to log histograms at the time a | 517 // Hook that allows derived implementations to log histograms at the time a |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 580 |
574 // Set true to disable non-test notifications (to prevent flakes in tests). | 581 // Set true to disable non-test notifications (to prevent flakes in tests). |
575 static bool test_notifications_only_; | 582 static bool test_notifications_only_; |
576 | 583 |
577 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); | 584 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
578 }; | 585 }; |
579 | 586 |
580 } // namespace net | 587 } // namespace net |
581 | 588 |
582 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ | 589 #endif // NET_BASE_NETWORK_CHANGE_NOTIFIER_H_ |
OLD | NEW |