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

Unified Diff: components/cronet/android/api/src/org/chromium/net/CronetEngine.java

Issue 2045703003: Enable NQE when Cronet Engine is built (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed mef comments Created 4 years, 6 months 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
Index: components/cronet/android/api/src/org/chromium/net/CronetEngine.java
diff --git a/components/cronet/android/api/src/org/chromium/net/CronetEngine.java b/components/cronet/android/api/src/org/chromium/net/CronetEngine.java
index 2b82f2a8ad2fc9d2ef83cb454e3e5fcc852b602f..bd2f22401d9ab8dbdfe910ae5d20fab1eb00a4ef 100644
--- a/components/cronet/android/api/src/org/chromium/net/CronetEngine.java
+++ b/components/cronet/android/api/src/org/chromium/net/CronetEngine.java
@@ -120,6 +120,7 @@ public abstract class CronetEngine {
private long mHttpCacheMaxSize;
private String mExperimentalOptions;
private long mMockCertVerifier;
+ private boolean mNetworkQualityEstimatorEnabled;
/**
* Default config enables SPDY, disables QUIC, SDCH and HTTP cache.
@@ -133,6 +134,7 @@ public abstract class CronetEngine {
enableHTTP2(true);
enableSDCH(false);
enableHttpCache(HTTP_CACHE_DISABLED, 0);
+ enableNetworkQualityEstimator(false);
}
/**
@@ -604,6 +606,34 @@ public abstract class CronetEngine {
}
/**
+ * Enables the network quality estimator, which collects and reports
+ * measurements of round trip time (RTT) and downstream throughput at
+ * various layers of the network stack. After enabling the estimator,
+ * listeners of RTT and throughput can be added with
+ * {@link #addRttListener} and {@link #addThroughputListener} and
+ * removed with {@link #removeRttListener} and
+ * {@link #removeThroughputListener}. The estimator uses memory and CPU
+ * only when enabled.
+ * @param value {@code true} to enable network quality estimator,
+ * {@code false} to disable.
+ * @hide as it's a prototype.
+ * @return the builder to facilitate chaining.
+ */
+ public Builder enableNetworkQualityEstimator(boolean value) {
+ mNetworkQualityEstimatorEnabled = value;
+ return this;
+ }
+
+ /**
+ * @return true if the network quality estimator has been enabled for
+ * this builder.
+ * @hide as it's a prototype.
+ */
+ boolean networkQualityEstimatorEnabled() {
+ return mNetworkQualityEstimatorEnabled;
+ }
+
+ /**
* Returns {@link Context} for builder.
*
* @return {@link Context} for builder.
@@ -803,6 +833,18 @@ public abstract class CronetEngine {
public abstract byte[] getGlobalMetricsDeltas();
/**
+ * Sets the executor which will be used to notify RequestFinished
+ * listeners, and to notify network quality RTT listeners
+ * that do not provide an executor.
+ * TODO(tbansal): http://crbug.com/618034 Remove this API. In short term,
+ * once all Cronet embedders supply a valid executor with
+ * NetworkQualityRTTListener, update the above comment to reflect that
+ * {@link executor} is only used to notify RequestFinishedListeners.
+ * @hide as it's a prototype.
+ */
+ public abstract void setRequestFinishedListenerExecutor(Executor executor);
+
+ /**
* Enables the network quality estimator, which collects and reports
* measurements of round trip time (RTT) and downstream throughput at
* various layers of the network stack. After enabling the estimator,
@@ -813,22 +855,22 @@ public abstract class CronetEngine {
* only when enabled.
* @param executor an executor that will be used to notified all
* added RTT and throughput listeners.
+ * TODO(tbansal): http://crbug.com/618034 Remove this API.
* @hide as it's a prototype.
*/
public abstract void enableNetworkQualityEstimator(Executor executor);
/**
- * Enables the network quality estimator for testing. This must be called
- * before round trip time and throughput listeners are added. Set both
- * boolean parameters to false for default behavior.
+ * Configures the network quality estimator for testing. This must be called
+ * before round trip time and throughput listeners are added, and after the
+ * network quality estimator has been enabled.
* @param useLocalHostRequests include requests to localhost in estimates.
- * @param useSmallerResponses include small responses in throughput estimates.
- * @param executor an {@link java.util.concurrent.Executor} on which all
- * listeners will be called.
+ * @param useSmallerResponses include small responses in throughput
+ * estimates.
* @hide as it's a prototype.
*/
- abstract void enableNetworkQualityEstimatorForTesting(
- boolean useLocalHostRequests, boolean useSmallerResponses, Executor executor);
+ abstract void configureNetworkQualityEstimatorForTesting(
+ boolean useLocalHostRequests, boolean useSmallerResponses);
/**
* Registers a listener that gets called whenever the network quality
@@ -967,6 +1009,8 @@ public abstract class CronetEngine {
*
* @param listener the listener for finished requests.
*
+ * TODO(tbansal): http://crbug.com/618034 Remove this API, once all embedders have switched to
+ * using a request finished listener that provides its own executor.
* @hide as it's a prototype.
*/
public abstract void addRequestFinishedListener(RequestFinishedListener listener);
@@ -976,6 +1020,8 @@ public abstract class CronetEngine {
*
* @param listener the listener to remove.
*
+ * TODO(tbansal): http://crbug.com/618034 Remove this API, once all embedders have switched to
+ * using a request finished listener that provides its own executor.
* @hide it's a prototype.
*/
public abstract void removeRequestFinishedListener(RequestFinishedListener listener);
@@ -1096,9 +1142,11 @@ public abstract class CronetEngine {
/**
* Interface to listen for finished requests that were created via this CronetEngine instance.
*
+ * TODO(tbansal): http://crbug.com/618034 Remove this API, and replace it with a listener
+ * whose executor is bound to the lifetime of the listener.
* @hide as it's a prototype.
*/
- public interface RequestFinishedListener { // TODO(klm): Add a convenience abstract class.
+ public interface RequestFinishedListener {
/**
* Invoked with request info.
* @param requestInfo {@link UrlRequestInfo} for finished request.
« no previous file with comments | « components/cronet/android/BUILD.gn ('k') | components/cronet/android/api/src/org/chromium/net/JavaCronetEngine.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698