| Index: net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
|
| diff --git a/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java b/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
|
| index 928af78e55e7a201e7fedc8b752fefee40a6b4a8..34c7c5a2fd53c8f07f5c30bbc5c1da1adb1845b5 100644
|
| --- a/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
|
| +++ b/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
|
| @@ -147,14 +147,17 @@ public class NetworkChangeNotifier {
|
| new NetworkChangeNotifierAutoDetect.Observer() {
|
| @Override
|
| public void onConnectionTypeChanged(int newConnectionType) {
|
| - updateCurrentMaxBandwidth(mAutoDetector.getCurrentMaxBandwidthInMbps());
|
| updateCurrentConnectionType(newConnectionType);
|
| }
|
| + @Override
|
| + public void onMaxBandwidthChanged(double maxBandwidthMbps) {
|
| + updateCurrentMaxBandwidth(maxBandwidthMbps);
|
| + }
|
| },
|
| mContext,
|
| alwaysWatchForChanges);
|
| - updateCurrentMaxBandwidth(mAutoDetector.getCurrentMaxBandwidthInMbps());
|
| updateCurrentConnectionType(mAutoDetector.getCurrentConnectionType());
|
| + updateCurrentMaxBandwidth(mAutoDetector.getCurrentMaxBandwidthInMbps());
|
| }
|
| } else {
|
| destroyAutoDetector();
|
| @@ -177,9 +180,9 @@ public class NetworkChangeNotifier {
|
| boolean connectionCurrentlyExists =
|
| mCurrentConnectionType != ConnectionType.CONNECTION_NONE;
|
| if (connectionCurrentlyExists != forceOnline) {
|
| - updateCurrentMaxBandwidth(forceOnline ? Double.POSITIVE_INFINITY : 0.0);
|
| updateCurrentConnectionType(forceOnline ? ConnectionType.CONNECTION_UNKNOWN
|
| : ConnectionType.CONNECTION_NONE);
|
| + updateCurrentMaxBandwidth(forceOnline ? Double.POSITIVE_INFINITY : 0.0);
|
| }
|
| }
|
|
|
| @@ -188,8 +191,10 @@ public class NetworkChangeNotifier {
|
| notifyObserversOfConnectionTypeChange(newConnectionType);
|
| }
|
|
|
| - private void updateCurrentMaxBandwidth(double maxBandwidth) {
|
| - mCurrentMaxBandwidth = maxBandwidth;
|
| + private void updateCurrentMaxBandwidth(double maxBandwidthMbps) {
|
| + if (maxBandwidthMbps == mCurrentMaxBandwidth) return;
|
| + mCurrentMaxBandwidth = maxBandwidthMbps;
|
| + notifyObserversOfMaxBandwidthChange(maxBandwidthMbps);
|
| }
|
|
|
| /**
|
| @@ -205,6 +210,16 @@ public class NetworkChangeNotifier {
|
| }
|
|
|
| /**
|
| + * Alerts all observers of a bandwidth change.
|
| + */
|
| + void notifyObserversOfMaxBandwidthChange(double maxBandwidthMbps) {
|
| + for (Long nativeChangeNotifier : mNativeChangeNotifiers) {
|
| + nativeNotifyMaxBandwidthChanged(nativeChangeNotifier, maxBandwidthMbps);
|
| + }
|
| + }
|
| +
|
| +
|
| + /**
|
| * Adds an observer for any connection type changes.
|
| */
|
| public static void addConnectionTypeObserver(ConnectionTypeObserver observer) {
|
| @@ -229,6 +244,9 @@ public class NetworkChangeNotifier {
|
| @NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
|
| private native void nativeNotifyConnectionTypeChanged(long nativePtr, int newConnectionType);
|
|
|
| + @NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
|
| + private native void nativeNotifyMaxBandwidthChanged(long nativePtr, double maxBandwidthMbps);
|
| +
|
| private static native double nativeGetMaxBandwidthForConnectionSubtype(int subtype);
|
|
|
| // For testing only.
|
|
|