Index: components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java |
diff --git a/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java b/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java |
index ab530b6e8610abbe4bb352dab3d46521bf11f42b..9ce8893dd06e1bae8a41b986d3acba9618d9151c 100644 |
--- a/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java |
+++ b/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java |
@@ -80,6 +80,8 @@ class CronetUrlRequestContext extends CronetEngine { |
CronetLibraryLoader.ensureInitialized(builder.getContext(), builder); |
nativeSetMinLogLevel(getLoggingLevel()); |
synchronized (mLock) { |
+ mNetworkQualityEstimatorEnabled = builder.networkQualityEstimatorEnabled(); |
+ mNetworkQualityExecutor = builder.networkQualityEstimatorExecutor(); |
mUrlRequestContextAdapter = nativeCreateRequestContextAdapter( |
createNativeUrlRequestContextConfig(builder.getContext(), builder)); |
if (mUrlRequestContextAdapter == 0) { |
@@ -117,7 +119,7 @@ class CronetUrlRequestContext extends CronetEngine { |
builder.dataReductionProxyPrimaryProxy(), builder.dataReductionProxyFallbackProxy(), |
builder.dataReductionProxySecureProxyCheckUrl(), builder.cacheDisabled(), |
builder.httpCacheMode(), builder.httpCacheMaxSize(), builder.experimentalOptions(), |
- builder.mockCertVerifier()); |
+ builder.mockCertVerifier(), builder.networkQualityEstimatorEnabled()); |
for (Builder.QuicHint quicHint : builder.quicHints()) { |
nativeAddQuicHint(urlRequestContextConfig, quicHint.mHost, quicHint.mPort, |
quicHint.mAlternatePort); |
@@ -222,15 +224,9 @@ class CronetUrlRequestContext extends CronetEngine { |
return nativeGetHistogramDeltas(); |
} |
+ // TODO(tbansal): http://crbug.com/618034 Remove this API. |
@Override |
public void enableNetworkQualityEstimator(Executor executor) { |
- enableNetworkQualityEstimatorForTesting(false, false, executor); |
- } |
- |
- @VisibleForTesting |
- @Override |
- void enableNetworkQualityEstimatorForTesting( |
- boolean useLocalHostRequests, boolean useSmallerResponses, Executor executor) { |
if (mNetworkQualityEstimatorEnabled) { |
throw new IllegalStateException("Network quality estimator already enabled"); |
} |
@@ -241,7 +237,20 @@ class CronetUrlRequestContext extends CronetEngine { |
mNetworkQualityExecutor = executor; |
synchronized (mLock) { |
checkHaveAdapter(); |
- nativeEnableNetworkQualityEstimator( |
+ nativeEnableNetworkQualityEstimator(mUrlRequestContextAdapter); |
+ } |
+ } |
+ |
+ @VisibleForTesting |
+ @Override |
+ void configureNetworkQualityEstimatorForTesting( |
+ boolean useLocalHostRequests, boolean useSmallerResponses) { |
+ if (!mNetworkQualityEstimatorEnabled) { |
bengr
2016/06/07 20:53:16
I was wondering if you even need this variable. E.
tbansal1
2016/06/07 21:37:17
Done.
|
+ throw new IllegalStateException("Network quality estimator must be enabled"); |
+ } |
+ synchronized (mLock) { |
+ checkHaveAdapter(); |
+ nativeConfigureNetworkQualityEstimatorForTesting( |
mUrlRequestContextAdapter, useLocalHostRequests, useSmallerResponses); |
} |
} |
@@ -478,7 +487,8 @@ class CronetUrlRequestContext extends CronetEngine { |
boolean sdchEnabled, String dataReductionProxyKey, |
String dataReductionProxyPrimaryProxy, String dataReductionProxyFallbackProxy, |
String dataReductionProxySecureProxyCheckUrl, boolean disableCache, int httpCacheMode, |
- long httpCacheMaxSize, String experimentalOptions, long mockCertVerifier); |
+ long httpCacheMaxSize, String experimentalOptions, long mockCertVerifier, |
+ boolean enableNetworkQualityEstimator); |
private static native void nativeAddQuicHint( |
long urlRequestContextConfig, String host, int port, int alternatePort); |
@@ -506,10 +516,13 @@ class CronetUrlRequestContext extends CronetEngine { |
private native void nativeInitRequestContextOnMainThread(long nativePtr); |
@NativeClassQualifiedName("CronetURLRequestContextAdapter") |
- private native void nativeEnableNetworkQualityEstimator( |
+ private native void nativeConfigureNetworkQualityEstimatorForTesting( |
long nativePtr, boolean useLocalHostRequests, boolean useSmallerResponses); |
@NativeClassQualifiedName("CronetURLRequestContextAdapter") |
+ private native void nativeEnableNetworkQualityEstimator(long nativePtr); |
+ |
+ @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
private native void nativeProvideRTTObservations(long nativePtr, boolean should); |
@NativeClassQualifiedName("CronetURLRequestContextAdapter") |