Chromium Code Reviews| Index: components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java |
| diff --git a/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java b/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java |
| index 47d4345be6badb8147a47238315ce1610aed2871..7678f8b7cdab541cdff33515d2152a9f6375facd 100644 |
| --- a/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java |
| +++ b/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java |
| @@ -20,6 +20,7 @@ import org.chromium.base.annotations.NativeClassQualifiedName; |
| import org.chromium.base.annotations.UsedByReflection; |
| import org.chromium.net.BidirectionalStream; |
| import org.chromium.net.CronetEngine; |
| +import org.chromium.net.EffectiveConnectionType; |
| import org.chromium.net.NetworkQualityRttListener; |
| import org.chromium.net.NetworkQualityThroughputListener; |
| import org.chromium.net.RequestFinishedInfo; |
| @@ -77,6 +78,14 @@ public class CronetUrlRequestContext extends CronetEngine { |
| */ |
| private final Object mFinishedListenerLock = new Object(); |
| + /** |
| + * Current effective connection type as computed by the network quality |
| + * estimator. |
| + */ |
| + @GuardedBy("mNetworkQualityLock") |
| + private int mEffectiveConnectionType = |
|
xunjieli
2016/08/09 13:22:44
I think this should be:
@EffectiveConnectionType
|
| + EffectiveConnectionType.EFFECTIVE_CONNECTION_TYPE_UNKNOWN; |
| + |
| @GuardedBy("mNetworkQualityLock") |
| private final ObserverList<NetworkQualityRttListener> mRttListenerList = |
| new ObserverList<NetworkQualityRttListener>(); |
| @@ -260,6 +269,17 @@ public class CronetUrlRequestContext extends CronetEngine { |
| return nativeGetHistogramDeltas(); |
| } |
| + @Override |
| + public int getEffectiveConnectionType() { |
| + if (!mNetworkQualityEstimatorEnabled) { |
| + throw new IllegalStateException("Network quality estimator must be enabled"); |
| + } |
| + synchronized (mNetworkQualityLock) { |
| + checkHaveAdapter(); |
| + return mEffectiveConnectionType; |
| + } |
| + } |
| + |
| @VisibleForTesting |
| @Override |
| public void configureNetworkQualityEstimatorForTesting( |
| @@ -437,6 +457,16 @@ public class CronetUrlRequestContext extends CronetEngine { |
| @SuppressWarnings("unused") |
| @CalledByNative |
| + private void onEffectiveConnectionTypeChanged(int effectiveConnectionType) { |
| + synchronized (mNetworkQualityLock) { |
| + // Convert the enum returned by the network quality estimator to an enum of type |
| + // EffectiveConnectionType. |
| + mEffectiveConnectionType = effectiveConnectionType; |
| + } |
| + } |
| + |
| + @SuppressWarnings("unused") |
| + @CalledByNative |
| private void onRttObservation(final int rttMs, final long whenMs, final int source) { |
| synchronized (mNetworkQualityLock) { |
| for (final NetworkQualityRttListener listener : mRttListenerList) { |