Chromium Code Reviews| Index: components/cronet/android/api/src/org/chromium/net/NetworkQualityRttListener.java |
| diff --git a/components/cronet/android/api/src/org/chromium/net/NetworkQualityRttListener.java b/components/cronet/android/api/src/org/chromium/net/NetworkQualityRttListener.java |
| index cd04f6ebfcca635cbaba2f0d9888c2aae6c7d383..4eb87307fdc460caaa6b5b0a0203f4df7ec3f52f 100644 |
| --- a/components/cronet/android/api/src/org/chromium/net/NetworkQualityRttListener.java |
| +++ b/components/cronet/android/api/src/org/chromium/net/NetworkQualityRttListener.java |
| @@ -4,19 +4,50 @@ |
| package org.chromium.net; |
| +import java.util.concurrent.Executor; |
| + |
| /** |
| - * Interface to watch for observations of various round trip times (RTTs) at |
| - * various layers of the network stack. These include RTT estimates by QUIC |
| - * and TCP, as well as the time between when a URL request is sent and when |
| - * the first byte of the response is received. |
| + * Watches observations of various round trip times (RTTs) at various layers of |
| + * the network stack. These include RTT estimates by QUIC and TCP, as well as |
| + * the time between when a URL request is sent and when the first byte of the |
| + * response is received. |
| * {@hide} as it's a prototype. |
| */ |
| -public interface NetworkQualityRttListener { |
| +public abstract class NetworkQualityRttListener { |
| + /** |
| + * The executor on which this listener will be notified. Set as a final |
| + * field, so it can be safely accessed across threads. |
| + */ |
| + private final Executor mExecutor; |
| + |
| + // TODO(tbansal): http://crbug.com/618034 Remove this constructor. |
| + public NetworkQualityRttListener() { |
| + mExecutor = null; |
| + } |
| + |
| + /** |
| + * @param executor The executor on which the observations are reported. |
| + */ |
| + public NetworkQualityRttListener(Executor executor) { |
| + // TODO(tbansal): http://crbug.com/618034 Uncomment this block, once |
| + // all embedders start providing a non-null executor. |
|
mef
2016/06/20 16:50:27
Wouldn't existing embedders use default constructo
tbansal1
2016/06/20 20:06:57
Good point. Done. I had to modify the test code a
|
| + /* |
| + if (executor == null) { |
| + throw new IllegalStateException("Executor must not be null"); |
| + } |
| + */ |
| + mExecutor = executor; |
| + } |
| + |
| + public Executor getExecutor() { |
| + return mExecutor; |
| + } |
| + |
| /** |
| * Reports a new round trip time observation. |
| * @param rttMs the round trip time in milliseconds. |
| * @param whenMs milliseconds since the Epoch (January 1st 1970, 00:00:00.000). |
| * @param source the observation source from {@link NetworkQualityObservationSource}. |
| */ |
| - public void onRttObservation(int rttMs, long whenMs, int source); |
| + public abstract void onRttObservation(int rttMs, long whenMs, int source); |
| } |