| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.net; | 5 package org.chromium.net; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.net.http.HttpResponseCache; | 9 import android.net.http.HttpResponseCache; |
| 10 import android.support.annotation.IntDef; | 10 import android.support.annotation.IntDef; |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 * useful data as no metrics have yet been collected. | 952 * useful data as no metrics have yet been collected. |
| 953 * | 953 * |
| 954 * @return differences in metrics collected by Cronet, since the last call | 954 * @return differences in metrics collected by Cronet, since the last call |
| 955 * to {@code getGlobalMetricsDeltas()}, serialized as a | 955 * to {@code getGlobalMetricsDeltas()}, serialized as a |
| 956 * <a href=https://developers.google.com/protocol-buffers>protobuf | 956 * <a href=https://developers.google.com/protocol-buffers>protobuf |
| 957 * </a>. | 957 * </a>. |
| 958 */ | 958 */ |
| 959 public abstract byte[] getGlobalMetricsDeltas(); | 959 public abstract byte[] getGlobalMetricsDeltas(); |
| 960 | 960 |
| 961 /** | 961 /** |
| 962 * Sets the executor which will be used to notify RequestFinished | |
| 963 * listeners, and to notify network quality RTT listeners | |
| 964 * that do not provide an executor. | |
| 965 * TODO(tbansal): http://crbug.com/618034 Remove this API. In short term, | |
| 966 * once all Cronet embedders supply a valid executor with | |
| 967 * NetworkQualityRTTListener, update the above comment to reflect that | |
| 968 * {@link executor} is only used to notify RequestFinishedListeners. | |
| 969 * @hide as it's a prototype. | |
| 970 */ | |
| 971 public abstract void setRequestFinishedListenerExecutor(Executor executor); | |
| 972 | |
| 973 /** | |
| 974 * Enables the network quality estimator, which collects and reports | |
| 975 * measurements of round trip time (RTT) and downstream throughput at | |
| 976 * various layers of the network stack. After enabling the estimator, | |
| 977 * listeners of RTT and throughput can be added with | |
| 978 * {@link #addRttListener} and {@link #addThroughputListener} and | |
| 979 * removed with {@link #removeRttListener} and | |
| 980 * {@link #removeThroughputListener}. The estimator uses memory and CPU | |
| 981 * only when enabled. | |
| 982 * @param executor an executor that will be used to notified all | |
| 983 * added RTT and throughput listeners. | |
| 984 * TODO(tbansal): http://crbug.com/618034 Remove this API. | |
| 985 * @hide as it's a prototype. | |
| 986 */ | |
| 987 public abstract void enableNetworkQualityEstimator(Executor executor); | |
| 988 | |
| 989 /** | |
| 990 * Configures the network quality estimator for testing. This must be called | 962 * Configures the network quality estimator for testing. This must be called |
| 991 * before round trip time and throughput listeners are added, and after the | 963 * before round trip time and throughput listeners are added, and after the |
| 992 * network quality estimator has been enabled. | 964 * network quality estimator has been enabled. |
| 993 * @param useLocalHostRequests include requests to localhost in estimates. | 965 * @param useLocalHostRequests include requests to localhost in estimates. |
| 994 * @param useSmallerResponses include small responses in throughput | 966 * @param useSmallerResponses include small responses in throughput |
| 995 * estimates. | 967 * estimates. |
| 996 * @hide as it's a prototype. | 968 * @hide as it's a prototype. |
| 997 */ | 969 */ |
| 998 public abstract void configureNetworkQualityEstimatorForTesting( | 970 public abstract void configureNetworkQualityEstimatorForTesting( |
| 999 boolean useLocalHostRequests, boolean useSmallerResponses); | 971 boolean useLocalHostRequests, boolean useSmallerResponses); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 * Registers a listener that gets called after the end of each request with
the request info. | 1101 * Registers a listener that gets called after the end of each request with
the request info. |
| 1130 * | 1102 * |
| 1131 * <p>This must be called after {@link #enableNetworkQualityEstimator} and w
ill throw an | 1103 * <p>This must be called after {@link #enableNetworkQualityEstimator} and w
ill throw an |
| 1132 * exception otherwise. | 1104 * exception otherwise. |
| 1133 * | 1105 * |
| 1134 * <p>The listener is called on the {@link java.util.concurrent.Executor} th
at | 1106 * <p>The listener is called on the {@link java.util.concurrent.Executor} th
at |
| 1135 * is passed to {@link #enableNetworkQualityEstimator}. | 1107 * is passed to {@link #enableNetworkQualityEstimator}. |
| 1136 * | 1108 * |
| 1137 * @param listener the listener for finished requests. | 1109 * @param listener the listener for finished requests. |
| 1138 * | 1110 * |
| 1139 * TODO(tbansal): http://crbug.com/618034 Remove this API, once all embedde
rs have switched to | |
| 1140 * using a request finished listener that provides its own executor. | |
| 1141 * @hide as it's a prototype. | 1111 * @hide as it's a prototype. |
| 1142 */ | 1112 */ |
| 1143 public abstract void addRequestFinishedListener(RequestFinishedListener list
ener); | 1113 public abstract void addRequestFinishedListener(RequestFinishedListener list
ener); |
| 1144 | 1114 |
| 1145 /** | 1115 /** |
| 1146 * Removes a finished request listener. | 1116 * Removes a finished request listener. |
| 1147 * | 1117 * |
| 1148 * @param listener the listener to remove. | 1118 * @param listener the listener to remove. |
| 1149 * | 1119 * |
| 1150 * TODO(tbansal): http://crbug.com/618034 Remove this API, once all embedde
rs have switched to | |
| 1151 * using a request finished listener that provides its own executor. | |
| 1152 * @hide it's a prototype. | 1120 * @hide it's a prototype. |
| 1153 */ | 1121 */ |
| 1154 public abstract void removeRequestFinishedListener(RequestFinishedListener l
istener); | 1122 public abstract void removeRequestFinishedListener(RequestFinishedListener l
istener); |
| 1155 | 1123 |
| 1156 /** | 1124 /** |
| 1157 * Information about a finished request. Passed to {@link RequestFinishedLis
tener}. | 1125 * Information about a finished request. Passed to {@link RequestFinishedLis
tener}. |
| 1158 * | 1126 * |
| 1159 * @hide as it's a prototype. | 1127 * @hide as it's a prototype. |
| 1160 */ | 1128 */ |
| 1161 public static final class UrlRequestInfo { | 1129 public static final class UrlRequestInfo { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 | 1230 |
| 1263 /** | 1231 /** |
| 1264 * Returns total bytes received over the network transport layer, or nul
l if not collected. | 1232 * Returns total bytes received over the network transport layer, or nul
l if not collected. |
| 1265 */ | 1233 */ |
| 1266 @Nullable | 1234 @Nullable |
| 1267 public Long getReceivedBytesCount() { | 1235 public Long getReceivedBytesCount() { |
| 1268 return mReceivedBytesCount; | 1236 return mReceivedBytesCount; |
| 1269 } | 1237 } |
| 1270 } | 1238 } |
| 1271 } | 1239 } |
| OLD | NEW |