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

Unified Diff: components/cronet/android/api/src/org/chromium/net/RequestFinishedInfo.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, 5 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/RequestFinishedInfo.java
diff --git a/components/cronet/android/api/src/org/chromium/net/RequestFinishedInfo.java b/components/cronet/android/api/src/org/chromium/net/RequestFinishedInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..8d7f69871f0feef17c21a74ad6901094c04ad16d
--- /dev/null
+++ b/components/cronet/android/api/src/org/chromium/net/RequestFinishedInfo.java
@@ -0,0 +1,70 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.net;
+
+import android.support.annotation.Nullable;
+
+import java.util.Collection;
+
+/**
+ * Information about a finished request. Passed to {@link RequestFinishedListener}.
+ *
+ * {@hide} as it's a prototype.
+ */
+public final class RequestFinishedInfo {
xunjieli 2016/08/01 20:40:05 I like the new name! What do you think about movin
+ private final String mUrl;
+ private final Collection<Object> mAnnotations;
+ private final UrlRequestMetrics mMetrics;
+ @Nullable
+ private final UrlResponseInfo mResponseInfo;
+
+ /**
+ * @hide only used by internal implementation.
+ */
+ public RequestFinishedInfo(String url, Collection<Object> annotations,
+ UrlRequestMetrics metrics, @Nullable UrlResponseInfo responseInfo) {
+ mUrl = url;
+ mAnnotations = annotations;
+ mMetrics = metrics;
+ mResponseInfo = responseInfo;
+ }
+
+ /** Returns the request's original URL. */
+ public String getUrl() {
+ return mUrl;
+ }
+
+ /** Returns the objects that the caller has supplied when initiating the request. */
+ public Collection<Object> getAnnotations() {
+ return mAnnotations;
+ }
+
+ // TODO(klm): Collect and return a chain of Metrics objects for redirect responses.
+ /**
+ * Returns metrics collected for this request.
+ *
+ * <p>The reported times and bytes account for all redirects, i.e.
+ * the TTFB is from the start of the original request to the ultimate response headers,
+ * the TTLB is from the start of the original request to the end of the ultimate response,
+ * the received byte count is for all redirects and the ultimate response combined.
+ * These cumulative metric definitions are debatable, but are chosen to make sense
+ * for user-facing latency analysis.
+ *
+ * <p>Must call {@link #enableNetworkQualityEstimator} to enable request metrics collection.
+ * @return metrics collected for this request.
+ */
+ public UrlRequestMetrics getMetrics() {
+ return mMetrics;
+ }
+
+ /**
+ * Returns a {@link UrlResponseInfo} for the request, if its response had started.
+ * @return {@link UrlResponseInfo} for the request, if its response had started.
+ */
+ @Nullable
+ public UrlResponseInfo getResponseInfo() {
+ return mResponseInfo;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698