Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1305)

Unified Diff: net/android/java/src/org/chromium/net/NetworkChangeNotifier.java

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/BUILD.gn ('k') | net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4db6d478dcc0cdfb7569a41ae790705b75c3e20f 100644
--- a/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
+++ b/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
@@ -73,7 +73,7 @@ public class NetworkChangeNotifier {
}
@CalledByNative
- public double getCurrentMaxBandwidth() {
+ public double getCurrentMaxBandwidthInMbps() {
return mCurrentMaxBandwidth;
}
@@ -147,14 +147,19 @@ 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());
+ final NetworkChangeNotifierAutoDetect.NetworkState networkState =
+ mAutoDetector.getCurrentNetworkState();
+ updateCurrentConnectionType(mAutoDetector.getCurrentConnectionType(networkState));
+ updateCurrentMaxBandwidth(mAutoDetector.getCurrentMaxBandwidthInMbps(networkState));
}
} else {
destroyAutoDetector();
@@ -177,9 +182,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 +193,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 +212,15 @@ 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 +245,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.
« no previous file with comments | « net/BUILD.gn ('k') | net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698