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

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

Issue 2417643007: Expose RTT and throughput estimates from Cronet (Closed)
Patch Set: Fix the java doc Created 4 years, 2 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;
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 cronetEngine = new JavaCronetEngine(getUserAgent()); 773 cronetEngine = new JavaCronetEngine(getUserAgent());
774 } 774 }
775 Log.i(TAG, "Using network stack: " + cronetEngine.getVersionString() ); 775 Log.i(TAG, "Using network stack: " + cronetEngine.getVersionString() );
776 // Clear MOCK_CERT_VERIFIER reference if there is any, since 776 // Clear MOCK_CERT_VERIFIER reference if there is any, since
777 // the ownership has been transferred to the engine. 777 // the ownership has been transferred to the engine.
778 mMockCertVerifier = 0; 778 mMockCertVerifier = 0;
779 return cronetEngine; 779 return cronetEngine;
780 } 780 }
781 } 781 }
782 782
783 /**
784 * Value used for RTT and throughput estimates if a valid value is unavailab le.
785 */
786 public static final int INVALID_RTT_THROUGHPUT = -1;
xunjieli 2016/10/18 21:52:00 nit: Reuse the one that you generated in RttThroug
tbansal1 2016/10/19 21:51:39 Done.
787
783 private static final String TAG = "UrlRequestFactory"; 788 private static final String TAG = "UrlRequestFactory";
784 private static final String CRONET_URL_REQUEST_CONTEXT = 789 private static final String CRONET_URL_REQUEST_CONTEXT =
785 "org.chromium.net.impl.CronetUrlRequestContext"; 790 "org.chromium.net.impl.CronetUrlRequestContext";
786 791
787 /** 792 /**
788 * Creates a {@link UrlRequest} object. All callbacks will 793 * Creates a {@link UrlRequest} object. All callbacks will
789 * be called on {@code executor}'s thread. {@code executor} must not run 794 * be called on {@code executor}'s thread. {@code executor} must not run
790 * tasks on the current thread to prevent blocking networking operations 795 * tasks on the current thread to prevent blocking networking operations
791 * and causing exceptions during shutdown. Request is given medium priority, 796 * and causing exceptions during shutdown. Request is given medium priority,
792 * see {@link UrlRequest.Builder#REQUEST_PRIORITY_MEDIUM}. To specify other 797 * see {@link UrlRequest.Builder#REQUEST_PRIORITY_MEDIUM}. To specify other
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 public abstract byte[] getGlobalMetricsDeltas(); 991 public abstract byte[] getGlobalMetricsDeltas();
987 992
988 /** 993 /**
989 * Returns the effective connection type computed by the network quality 994 * Returns the effective connection type computed by the network quality
990 * estimator. 995 * estimator.
991 * @hide as it's a prototype. 996 * @hide as it's a prototype.
992 */ 997 */
993 public abstract int getEffectiveConnectionType(); 998 public abstract int getEffectiveConnectionType();
994 999
995 /** 1000 /**
1001 * Returns the HTTP RTT estimate (in milliseconds) computed by the network
1002 * quality estimator. Set to {@link INVALID_RTT_THROUGHPUT} if a valid value
1003 * is unavailable. This must be called after
1004 * {@link #enableNetworkQualityEstimator}, and will throw an
1005 * exception otherwise.
1006 * @hide as it's a prototype.
1007 * @return Estimate of the HTTP RTT in milliseconds.
1008 */
1009 public abstract int getHttpRttMs();
1010
1011 /**
1012 * Returns the transport RTT estimate (in milliseconds) computed by the
1013 * network quality estimator. Set to {@link INVALID_RTT_THROUGHPUT} if a
1014 * valid value is unavailable. This must be called after
1015 * {@link #enableNetworkQualityEstimator}, and will throw an
1016 * exception otherwise.
1017 * @hide as it's a prototype.
1018 * @return Estimate of the transport RTT in milliseconds.
1019 */
1020 public abstract int getTransportRttMs();
1021
1022 /**
1023 * Returns the downstream throughput estimate (in kilobits per second)
1024 * computed by the network quality estimator. Set to
1025 * {@link INVALID_RTT_THROUGHPUT} if a valid value is unavailable. This
1026 * must be called after {@link #enableNetworkQualityEstimator}, and will
1027 * throw an exception otherwise.
1028 * @hide as it's a prototype.
1029 * @return Estimate of the downstream throughput in kilobits per second.
1030 */
1031 public abstract int getDownstreamThroughputKbps();
1032
1033 /**
996 * Configures the network quality estimator for testing. This must be called 1034 * Configures the network quality estimator for testing. This must be called
997 * before round trip time and throughput listeners are added, and after the 1035 * before round trip time and throughput listeners are added, and after the
998 * network quality estimator has been enabled. 1036 * network quality estimator has been enabled.
999 * @param useLocalHostRequests include requests to localhost in estimates. 1037 * @param useLocalHostRequests include requests to localhost in estimates.
1000 * @param useSmallerResponses include small responses in throughput 1038 * @param useSmallerResponses include small responses in throughput
1001 * estimates. 1039 * estimates.
1002 * @hide as it's a prototype. 1040 * @hide as it's a prototype.
1003 */ 1041 */
1004 public abstract void configureNetworkQualityEstimatorForTesting( 1042 public abstract void configureNetworkQualityEstimatorForTesting(
1005 boolean useLocalHostRequests, boolean useSmallerResponses); 1043 boolean useLocalHostRequests, boolean useSmallerResponses);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 * 1202 *
1165 * @param url URL for the generated requests. 1203 * @param url URL for the generated requests.
1166 * @param callback callback object that gets invoked on different events. 1204 * @param callback callback object that gets invoked on different events.
1167 * @param executor {@link Executor} on which all callbacks will be invoked. 1205 * @param executor {@link Executor} on which all callbacks will be invoked.
1168 */ 1206 */
1169 public UrlRequest.Builder newUrlRequestBuilder( 1207 public UrlRequest.Builder newUrlRequestBuilder(
1170 String url, UrlRequest.Callback callback, Executor executor) { 1208 String url, UrlRequest.Callback callback, Executor executor) {
1171 return new UrlRequest.Builder(url, callback, executor, this); 1209 return new UrlRequest.Builder(url, callback, executor, this);
1172 } 1210 }
1173 } 1211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698