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

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

Issue 2204533002: Move Cronet metrics-related classes into their own files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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;
11 import android.support.annotation.Nullable;
12 import android.support.annotation.VisibleForTesting; 11 import android.support.annotation.VisibleForTesting;
13 import android.util.Log; 12 import android.util.Log;
14 13
15 import java.io.File; 14 import java.io.File;
16 import java.io.IOException; 15 import java.io.IOException;
17 import java.lang.annotation.Retention; 16 import java.lang.annotation.Retention;
18 import java.lang.annotation.RetentionPolicy; 17 import java.lang.annotation.RetentionPolicy;
19 import java.lang.reflect.Constructor; 18 import java.lang.reflect.Constructor;
20 import java.net.IDN; 19 import java.net.IDN;
21 import java.net.Proxy; 20 import java.net.Proxy;
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 public abstract void addRequestFinishedListener(RequestFinishedListener list ener); 1112 public abstract void addRequestFinishedListener(RequestFinishedListener list ener);
1114 1113
1115 /** 1114 /**
1116 * Removes a finished request listener. 1115 * Removes a finished request listener.
1117 * 1116 *
1118 * @param listener the listener to remove. 1117 * @param listener the listener to remove.
1119 * 1118 *
1120 * @hide it's a prototype. 1119 * @hide it's a prototype.
1121 */ 1120 */
1122 public abstract void removeRequestFinishedListener(RequestFinishedListener l istener); 1121 public abstract void removeRequestFinishedListener(RequestFinishedListener l istener);
1123
1124 /**
1125 * Information about a finished request. Passed to {@link RequestFinishedLis tener}.
1126 *
1127 * @hide as it's a prototype.
1128 */
1129 public static final class UrlRequestInfo {
1130 private final String mUrl;
1131 private final Collection<Object> mAnnotations;
1132 private final UrlRequestMetrics mMetrics;
1133 @Nullable private final UrlResponseInfo mResponseInfo;
1134
1135 /**
1136 * @hide only used by internal implementation.
1137 */
1138 public UrlRequestInfo(String url, Collection<Object> annotations, UrlReq uestMetrics metrics,
1139 @Nullable UrlResponseInfo responseInfo) {
1140 mUrl = url;
1141 mAnnotations = annotations;
1142 mMetrics = metrics;
1143 mResponseInfo = responseInfo;
1144 }
1145
1146 /** Returns the request's original URL. */
1147 public String getUrl() {
1148 return mUrl;
1149 }
1150
1151 /** Returns the objects that the caller has supplied when initiating the request. */
1152 public Collection<Object> getAnnotations() {
1153 return mAnnotations;
1154 }
1155
1156 // TODO(klm): Collect and return a chain of Metrics objects for redirect responses.
1157 /**
1158 * Returns metrics collected for this request.
1159 *
1160 * <p>The reported times and bytes account for all redirects, i.e.
1161 * the TTFB is from the start of the original request to the ultimate re sponse headers,
1162 * the TTLB is from the start of the original request to the end of the ultimate response,
1163 * the received byte count is for all redirects and the ultimate respons e combined.
1164 * These cumulative metric definitions are debatable, but are chosen to make sense
1165 * for user-facing latency analysis.
1166 *
1167 * <p>Must call {@link #enableNetworkQualityEstimator} to enable request metrics collection.
1168 * @return metrics collected for this request.
1169 */
1170 public UrlRequestMetrics getMetrics() {
1171 return mMetrics;
1172 }
1173
1174 /**
1175 * Returns a {@link UrlResponseInfo} for the request, if its response ha d started.
1176 * @return {@link UrlResponseInfo} for the request, if its response had started.
1177 */
1178 @Nullable
1179 public UrlResponseInfo getResponseInfo() {
1180 return mResponseInfo;
1181 }
1182 }
1183
1184 /**
1185 * Metrics collected for a single request.
1186 *
1187 * <p>Must call {@link #enableNetworkQualityEstimator} to enable request met rics collection.
1188 *
1189 * @hide as it's a prototype.
1190 */
1191 public static final class UrlRequestMetrics {
1192 @Nullable private final Long mTtfbMs;
1193 @Nullable private final Long mTotalTimeMs;
1194 @Nullable private final Long mSentBytesCount;
1195 @Nullable private final Long mReceivedBytesCount;
1196
1197 public UrlRequestMetrics(@Nullable Long ttfbMs, @Nullable Long totalTime Ms,
1198 @Nullable Long sentBytesCount, @Nullable Long receivedBytesCount ) {
1199 mTtfbMs = ttfbMs;
1200 mTotalTimeMs = totalTimeMs;
1201 mSentBytesCount = sentBytesCount;
1202 mReceivedBytesCount = receivedBytesCount;
1203 }
1204
1205 /**
1206 * Returns milliseconds between request initiation and first byte of res ponse headers,
1207 * or null if not collected.
1208 */
1209 @Nullable
1210 public Long getTtfbMs() {
1211 return mTtfbMs;
1212 }
1213
1214 /**
1215 * Returns milliseconds between request initiation and finish,
1216 * including a failure or cancellation, or null if not collected.
1217 */
1218 @Nullable
1219 public Long getTotalTimeMs() {
1220 return mTotalTimeMs;
1221 }
1222
1223 /**
1224 * Returns total bytes sent over the network transport layer, or null if not collected.
1225 */
1226 @Nullable
1227 public Long getSentBytesCount() {
1228 return mSentBytesCount;
1229 }
1230
1231 /**
1232 * Returns total bytes received over the network transport layer, or nul l if not collected.
1233 */
1234 @Nullable
1235 public Long getReceivedBytesCount() {
1236 return mReceivedBytesCount;
1237 }
1238 }
1239 } 1122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698