Chromium Code Reviews| Index: net/base/network_change_notifier.h |
| diff --git a/net/base/network_change_notifier.h b/net/base/network_change_notifier.h |
| index abced4859a29857b493bf52012a0041ad6c9828b..8206e3911776efe4a36ff65360db09b2b4b77667 100644 |
| --- a/net/base/network_change_notifier.h |
| +++ b/net/base/network_change_notifier.h |
| @@ -186,14 +186,12 @@ class NET_EXPORT NetworkChangeNotifier { |
| class NET_EXPORT MaxBandwidthObserver { |
| public: |
| - // Will be called when a change occurs to the network's maximum bandwidth as |
| - // defined in http://w3c.github.io/netinfo/. Generally this will only be |
| - // called on bandwidth changing network connection/disconnection events. |
| - // Some platforms may call it more frequently, such as when WiFi signal |
| - // strength changes. |
| - // TODO(jkarlin): This is currently only implemented for Android. Implement |
| - // on every platform. |
| - virtual void OnMaxBandwidthChanged(double max_bandwidth_mbps) = 0; |
| + // Called when a change occurs to the network's maximum bandwidth as |
| + // defined in http://w3c.github.io/netinfo/. Also called on type change, |
| + // even if the maximum bandwidth doesn't change. See the documentation of |
| + // GetMaxBanwidth for what to expect for the values of |max_bandwidth_mbps|. |
|
pauljensen
2015/09/15 18:17:40
GetMaxBandwidth->GetMaxBandwidthAndConnectionType
jkarlin
2015/09/16 12:12:22
Done.
|
| + virtual void OnMaxBandwidthChanged(ConnectionType type, |
| + double max_bandwidth_mbps) = 0; |
| protected: |
| MaxBandwidthObserver() {} |
| @@ -234,13 +232,16 @@ class NET_EXPORT NetworkChangeNotifier { |
| // the internet, the connection type is CONNECTION_WIFI. |
| static ConnectionType GetConnectionType(); |
| - // Returns a theoretical upper limit on download bandwidth, potentially based |
| - // on underlying connection type, signal strength, or some other signal. The |
| - // default mapping of connection type to maximum bandwidth is provided in the |
| - // NetInfo spec: http://w3c.github.io/netinfo/. Host-specific application |
| - // permissions may be required, please see host-specific declaration for more |
| - // information. |
| - static double GetMaxBandwidth(); |
| + // Sets |max_bandwidth_mbps| to a theoretical upper limit on download |
| + // bandwidth, potentially based on underlying connection type, signal |
| + // strength, or some other signal. Specifically, it returns +Infinity if there |
| + // is a connection and 0.0 otherwise. The circumstances in which a more |
|
pauljensen
2015/09/15 18:17:40
Um I think it does more than "Specifically, it ret
jkarlin
2015/09/16 12:12:22
Done.
|
| + // specific value is given are: Android cellular types, Android wifi types, |
|
pauljensen
2015/09/15 18:17:40
can we reword the "types" here to something like "
pauljensen
2015/09/15 18:17:40
wifi->WiFi
jkarlin
2015/09/16 12:12:22
Done.
jkarlin
2015/09/16 12:12:22
Done.
|
| + // and ChromeOS cellular types. See the NetInfo spec for the mapping of |
| + // specific subtypes to bandwidth values: http://w3c.github.io/netinfo/. |
| + // |connection_type| is set to the current ConnectionType. |
|
pauljensen
2015/09/15 18:17:40
ConnectionType->active default network's connectio
jkarlin
2015/09/16 12:12:22
Done.
|
| + static void GetMaxBandwidthAndConnectionType(double* max_bandwidth_mbps, |
| + ConnectionType* connection_type); |
| // Retrieve the last read DnsConfig. This could be expensive if the system has |
| // a large HOSTS file. |
| @@ -309,6 +310,8 @@ class NET_EXPORT NetworkChangeNotifier { |
| ConnectionType type); |
| static void NotifyObserversOfNetworkChangeForTests(ConnectionType type); |
| static void NotifyObserversOfInitialDNSConfigReadForTests(); |
| + static void NotifyObserversOfMaxBandwidthChangeForTests(ConnectionType type, |
| + double max_bandwidth); |
| // Enable or disable notifications from the host. After setting to true, be |
| // sure to pump the RunLoop until idle to finish any preexisting |
| @@ -392,7 +395,9 @@ class NET_EXPORT NetworkChangeNotifier { |
| // See the description of NetworkChangeNotifier::GetMaxBandwidth(). |
| // Implementations must be thread-safe. Implementations must also be |
| // cheap as it is called often. |
| - virtual double GetCurrentMaxBandwidth() const; |
| + virtual void GetCurrentMaxBandwidthAndConnectionType( |
| + double* max_bandwidth_mbps, |
| + ConnectionType* connection_type) const; |
| // Returns a theoretical upper limit on download bandwidth given a connection |
| // subtype. The mapping of connection type to maximum bandwidth is provided in |
| @@ -407,7 +412,8 @@ class NET_EXPORT NetworkChangeNotifier { |
| static void NotifyObserversOfDNSChange(); |
| static void NotifyObserversOfInitialDNSConfigRead(); |
| static void NotifyObserversOfNetworkChange(ConnectionType type); |
| - static void NotifyObserversOfMaxBandwidthChange(double max_bandwidth_mbps); |
| + static void NotifyObserversOfMaxBandwidthChange(ConnectionType type, |
| + double max_bandwidth_mbps); |
| // Stores |config| in NetworkState and notifies OnDNSChanged observers. |
| static void SetDnsConfig(const DnsConfig& config); |
| @@ -429,7 +435,8 @@ class NET_EXPORT NetworkChangeNotifier { |
| void NotifyObserversOfDNSChangeImpl(); |
| void NotifyObserversOfInitialDNSConfigReadImpl(); |
| void NotifyObserversOfNetworkChangeImpl(ConnectionType type); |
| - void NotifyObserversOfMaxBandwidthChangeImpl(double max_bandwidth_mbps); |
| + void NotifyObserversOfMaxBandwidthChangeImpl(ConnectionType type, |
| + double max_bandwidth_mbps); |
| const scoped_refptr<base::ObserverListThreadSafe<IPAddressObserver>> |
| ip_address_observer_list_; |