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..97a2354ef39212a6ae981930a1734a9945fc9a4f 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|. |
+ virtual void OnMaxBandwidthChanged(ConnectionType type, |
+ double max_bandwidth_mbps) = 0; |
protected: |
MaxBandwidthObserver() {} |
@@ -235,12 +233,16 @@ class NET_EXPORT NetworkChangeNotifier { |
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(); |
+ // 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 specific value is given are: |
+ // Android cellular types, Android wifi types, and ChromeOS cellular types. |
+ // See the NetInfo spec for the mapping of specific subtypes to bandwidth |
+ // values: http://w3c.github.io/netinfo/. |
+ // If |connection_type| is not nullptr then it is set to the |
+ // current ConnectionType. |
+ static double GetMaxBandwidthAndConnectionType( |
+ ConnectionType* connection_type); |
pauljensen
2015/09/11 18:59:02
Are you going to change this API to take pointers
jkarlin
2015/09/11 19:04:26
Ah, I took our convo. to mean that you were fine w
pauljensen
2015/09/11 19:18:59
Oh, no, I was trying to say I wanted it to be:
voi
jkarlin
2015/09/11 20:07:24
Done.
|
// Retrieve the last read DnsConfig. This could be expensive if the system has |
// a large HOSTS file. |
@@ -309,6 +311,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 +396,8 @@ 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 double GetCurrentMaxBandwidthAndConnectionType( |
+ ConnectionType* connection_type) const; |
pauljensen
2015/09/11 18:59:02
ditto
jkarlin
2015/09/11 20:07:23
Done.
|
// 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_; |