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

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 javadoc 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 =
xunjieli 2016/10/19 23:32:28 Can you get rid of this and use RttThroughputValue
tbansal1 2016/10/20 00:29:18 Done.
787 RttThroughputValues.INVALID_RTT_THROUGHPUT_VALUE;
788
783 private static final String TAG = "UrlRequestFactory"; 789 private static final String TAG = "UrlRequestFactory";
784 private static final String CRONET_URL_REQUEST_CONTEXT = 790 private static final String CRONET_URL_REQUEST_CONTEXT =
785 "org.chromium.net.impl.CronetUrlRequestContext"; 791 "org.chromium.net.impl.CronetUrlRequestContext";
786 792
787 /** 793 /**
788 * Creates a {@link UrlRequest} object. All callbacks will 794 * Creates a {@link UrlRequest} object. All callbacks will
789 * be called on {@code executor}'s thread. {@code executor} must not run 795 * be called on {@code executor}'s thread. {@code executor} must not run
790 * tasks on the current thread to prevent blocking networking operations 796 * tasks on the current thread to prevent blocking networking operations
791 * and causing exceptions during shutdown. Request is given medium priority, 797 * and causing exceptions during shutdown. Request is given medium priority,
792 * see {@link UrlRequest.Builder#REQUEST_PRIORITY_MEDIUM}. To specify other 798 * 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(); 992 public abstract byte[] getGlobalMetricsDeltas();
987 993
988 /** 994 /**
989 * Returns the effective connection type computed by the network quality 995 * Returns the effective connection type computed by the network quality
990 * estimator. 996 * estimator.
991 * @hide as it's a prototype. 997 * @hide as it's a prototype.
992 */ 998 */
993 public abstract int getEffectiveConnectionType(); 999 public abstract int getEffectiveConnectionType();
994 1000
995 /** 1001 /**
1002 * Returns the HTTP RTT estimate (in milliseconds) computed by the network
1003 * quality estimator. Set to {@link INVALID_RTT_THROUGHPUT} if a valid value
1004 * is unavailable. This must be called after
1005 * {@link #enableNetworkQualityEstimator}, and will throw an
1006 * exception otherwise.
1007 * @hide as it's a prototype.
1008 * @return Estimate of the HTTP RTT in milliseconds.
1009 */
1010 public abstract int getHttpRttMs();
1011
1012 /**
1013 * Returns the transport RTT estimate (in milliseconds) computed by the
1014 * network quality estimator. Set to {@link INVALID_RTT_THROUGHPUT} if a
1015 * valid value is unavailable. This must be called after
1016 * {@link #enableNetworkQualityEstimator}, and will throw an
1017 * exception otherwise.
1018 * @hide as it's a prototype.
1019 * @return Estimate of the transport RTT in milliseconds.
1020 */
1021 public abstract int getTransportRttMs();
1022
1023 /**
1024 * Returns the downstream throughput estimate (in kilobits per second)
1025 * computed by the network quality estimator. Set to
1026 * {@link INVALID_RTT_THROUGHPUT} if a valid value is unavailable. This
1027 * must be called after {@link #enableNetworkQualityEstimator}, and will
1028 * throw an exception otherwise.
1029 * @hide as it's a prototype.
1030 * @return Estimate of the downstream throughput in kilobits per second.
1031 */
1032 public abstract int getDownstreamThroughputKbps();
1033
1034 /**
996 * Configures the network quality estimator for testing. This must be called 1035 * Configures the network quality estimator for testing. This must be called
997 * before round trip time and throughput listeners are added, and after the 1036 * before round trip time and throughput listeners are added, and after the
998 * network quality estimator has been enabled. 1037 * network quality estimator has been enabled.
999 * @param useLocalHostRequests include requests to localhost in estimates. 1038 * @param useLocalHostRequests include requests to localhost in estimates.
1000 * @param useSmallerResponses include small responses in throughput 1039 * @param useSmallerResponses include small responses in throughput
1001 * estimates. 1040 * estimates.
1002 * @hide as it's a prototype. 1041 * @hide as it's a prototype.
1003 */ 1042 */
1004 public abstract void configureNetworkQualityEstimatorForTesting( 1043 public abstract void configureNetworkQualityEstimatorForTesting(
1005 boolean useLocalHostRequests, boolean useSmallerResponses); 1044 boolean useLocalHostRequests, boolean useSmallerResponses);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 * 1203 *
1165 * @param url URL for the generated requests. 1204 * @param url URL for the generated requests.
1166 * @param callback callback object that gets invoked on different events. 1205 * @param callback callback object that gets invoked on different events.
1167 * @param executor {@link Executor} on which all callbacks will be invoked. 1206 * @param executor {@link Executor} on which all callbacks will be invoked.
1168 */ 1207 */
1169 public UrlRequest.Builder newUrlRequestBuilder( 1208 public UrlRequest.Builder newUrlRequestBuilder(
1170 String url, UrlRequest.Callback callback, Executor executor) { 1209 String url, UrlRequest.Callback callback, Executor executor) {
1171 return new UrlRequest.Builder(url, callback, executor, this); 1210 return new UrlRequest.Builder(url, callback, executor, this);
1172 } 1211 }
1173 } 1212 }
OLDNEW
« no previous file with comments | « components/cronet/android/BUILD.gn ('k') | components/cronet/android/api/src/org/chromium/net/JavaCronetEngine.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698