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

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

Issue 2470903002: Add default implementation of experimental methods (Closed)
Patch Set: Added EFFECTIVE_ prefix to CONNECTION_TYPE constants Created 4 years, 1 month 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/ExperimentalCronetEngine.java
diff --git a/components/cronet/android/api/src/org/chromium/net/ExperimentalCronetEngine.java b/components/cronet/android/api/src/org/chromium/net/ExperimentalCronetEngine.java
index 8c17262f6c38005aca4737304b0ddb56a452ebc4..831245792e116179a3894143d1ad6ec92fcb877b 100644
--- a/components/cronet/android/api/src/org/chromium/net/ExperimentalCronetEngine.java
+++ b/components/cronet/android/api/src/org/chromium/net/ExperimentalCronetEngine.java
@@ -23,6 +23,41 @@ import java.util.concurrent.Executor;
*/
public abstract class ExperimentalCronetEngine extends CronetEngine {
/**
+ * Unknown rtt throughput value.
pauljensen 2016/11/08 14:00:32 What is "rtt throughput"? rtt should be capitalize
kapishnikov 2016/11/08 15:29:45 Renamed to CONNECTION_METRIC_UNKNOWN and changed t
+ */
+ public static final int RTT_THROUGHPUT_UNKNOWN = -1;
pauljensen 2016/11/08 14:00:32 We need a better name than "RTT_THROUGHPUT". Perha
kapishnikov 2016/11/08 15:29:45 Done.
+
+ /**
+ * The connection type is unknown.
pauljensen 2016/11/08 14:00:32 This needs a lot more description. It should ment
kapishnikov 2016/11/08 15:29:45 Done.
+ */
+ public static final int EFFECTIVE_CONNECTION_TYPE_UNKNOWN = 0;
+
+ /**
+ * The device is offline.
+ */
+ public static final int EFFECTIVE_CONNECTION_TYPE_OFFLINE = 1;
+
+ /**
+ * The connection type is slow 2G.
+ */
+ public static final int EFFECTIVE_CONNECTION_TYPE_SLOW_2G = 2;
+
+ /**
+ * The connection type is 2G.
+ */
+ public static final int EFFECTIVE_CONNECTION_TYPE_2G = 3;
+
+ /**
+ * The connection type is 3G.
+ */
+ public static final int EFFECTIVE_CONNECTION_TYPE_3G = 4;
+
+ /**
+ * The connection type is 4G.
+ */
+ public static final int EFFECTIVE_CONNECTION_TYPE_4G = 5;
+
+ /**
* Builder for building {@link ExperimentalCronetEngine}.
*/
public static class Builder extends CronetEngine.Builder {
@@ -235,13 +270,15 @@ public abstract class ExperimentalCronetEngine extends CronetEngine {
* @param maxSize the maximum total disk space in bytes that should be used by NetLog. Actual
* disk space usage may exceed this limit slightly.
*/
- public abstract void startNetLogToDisk(String dirPath, boolean logAll, int maxSize);
+ public void startNetLogToDisk(String dirPath, boolean logAll, int maxSize){};
/**
* Returns the effective connection type computed by the network quality
* estimator.
pauljensen 2016/11/08 14:00:32 Add "Call {@link Builder#enableNetworkQualityEstim
kapishnikov 2016/11/08 15:29:45 Done.
*/
- public abstract int getEffectiveConnectionType();
+ public int getEffectiveConnectionType() {
+ return EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
+ };
/**
* Configures the network quality estimator for testing. This must be called
@@ -251,8 +288,8 @@ public abstract class ExperimentalCronetEngine extends CronetEngine {
* @param useSmallerResponses include small responses in throughput
* estimates.
*/
- public abstract void configureNetworkQualityEstimatorForTesting(
- boolean useLocalHostRequests, boolean useSmallerResponses);
+ public void configureNetworkQualityEstimatorForTesting(
+ boolean useLocalHostRequests, boolean useSmallerResponses){};
/**
* Registers a listener that gets called whenever the network quality
@@ -264,7 +301,7 @@ public abstract class ExperimentalCronetEngine extends CronetEngine {
* is passed to {@link Builder#enableNetworkQualityEstimator}.
* @param listener the listener of round trip times.
*/
- public abstract void addRttListener(NetworkQualityRttListener listener);
+ public void addRttListener(NetworkQualityRttListener listener){};
/**
* Removes a listener of round trip times if previously registered with
@@ -273,7 +310,7 @@ public abstract class ExperimentalCronetEngine extends CronetEngine {
* observations.
* @param listener the listener of round trip times.
*/
- public abstract void removeRttListener(NetworkQualityRttListener listener);
+ public void removeRttListener(NetworkQualityRttListener listener){};
/**
* Registers a listener that gets called whenever the network quality
@@ -285,7 +322,7 @@ public abstract class ExperimentalCronetEngine extends CronetEngine {
* {@link Builder#enableNetworkQualityEstimator}.
* @param listener the listener of throughput.
*/
- public abstract void addThroughputListener(NetworkQualityThroughputListener listener);
+ public void addThroughputListener(NetworkQualityThroughputListener listener){};
/**
* Removes a listener of throughput. This should be called after a
@@ -293,7 +330,7 @@ public abstract class ExperimentalCronetEngine extends CronetEngine {
* {@link #addThroughputListener} in order to stop receiving observations.
* @param listener the listener of throughput.
*/
- public abstract void removeThroughputListener(NetworkQualityThroughputListener listener);
+ public void removeThroughputListener(NetworkQualityThroughputListener listener){};
/**
* Establishes a new connection to the resource specified by the {@link URL} {@code url}
@@ -308,7 +345,9 @@ public abstract class ExperimentalCronetEngine extends CronetEngine {
* @throws IOException if an error occurs while opening the connection.
*/
// TODO(pauljensen): Expose once implemented, http://crbug.com/418111
- public abstract URLConnection openConnection(URL url, Proxy proxy) throws IOException;
+ public URLConnection openConnection(URL url, Proxy proxy) throws IOException {
+ return url.openConnection(proxy);
+ }
/**
* Registers a listener that gets called after the end of each request with the request info.
@@ -318,14 +357,14 @@ public abstract class ExperimentalCronetEngine extends CronetEngine {
*
* @param listener the listener for finished requests.
*/
- public abstract void addRequestFinishedListener(RequestFinishedInfo.Listener listener);
+ public void addRequestFinishedListener(RequestFinishedInfo.Listener listener){};
/**
* Removes a finished request listener.
*
* @param listener the listener to remove.
*/
- public abstract void removeRequestFinishedListener(RequestFinishedInfo.Listener listener);
+ public void removeRequestFinishedListener(RequestFinishedInfo.Listener listener){};
/**
* Returns serialized representation of certificate verifier's cache
@@ -338,38 +377,44 @@ public abstract class ExperimentalCronetEngine extends CronetEngine {
* @return serialized representation of certificate verification results
* data.
*/
- public abstract String getCertVerifierData(long timeout);
+ public String getCertVerifierData(long timeout) {
+ return "";
+ };
/**
* Returns the HTTP RTT estimate (in milliseconds) computed by the network
- * quality estimator. Set to
- * {@link RttThroughputValues.INVALID_RTT_THROUGHPUT} if a valid value
+ * quality estimator. Set to {@link #RTT_THROUGHPUT_UNKNOWN} if a valid value
pauljensen 2016/11/08 14:00:32 "if a valid value is unavailable" made more sense
kapishnikov 2016/11/08 15:29:45 Changed to CONNECTION_METRIC_UNKNOWN + made small
* is unavailable. This must be called after
* {@link Builder#enableNetworkQualityEstimator}, and will throw an
* exception otherwise.
* @return Estimate of the HTTP RTT in milliseconds.
*/
- public abstract int getHttpRttMs();
+ public int getHttpRttMs() {
+ return RTT_THROUGHPUT_UNKNOWN;
+ };
/**
* Returns the transport RTT estimate (in milliseconds) computed by the
- * network quality estimator. Set to
- * {@link RttThroughputValues.INVALID_RTT_THROUGHPUT} if a valid value is
- * unavailable. This must be called after
+ * network quality estimator. Set to {@link #RTT_THROUGHPUT_UNKNOWN} if
+ * a valid value is unavailable. This must be called after
* {@link Builder#enableNetworkQualityEstimator}, and will throw an
* exception otherwise.
* @return Estimate of the transport RTT in milliseconds.
*/
- public abstract int getTransportRttMs();
+ public int getTransportRttMs() {
+ return RTT_THROUGHPUT_UNKNOWN;
+ }
/**
* Returns the downstream throughput estimate (in kilobits per second)
* computed by the network quality estimator. Set to
- * {@link RttThroughputValues.INVALID_RTT_THROUGHPUT} if a valid value is
+ * {@link #RTT_THROUGHPUT_UNKNOWN} if a valid value is
* unavailable. This must be called after
* {@link Builder#enableNetworkQualityEstimator}, and will
* throw an exception otherwise.
* @return Estimate of the downstream throughput in kilobits per second.
*/
- public abstract int getDownstreamThroughputKbps();
+ public int getDownstreamThroughputKbps() {
+ return RTT_THROUGHPUT_UNKNOWN;
+ };
}

Powered by Google App Engine
This is Rietveld 408576698