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

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

Issue 1273173002: Added Network Quality Estimator Real-time interface to Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.content.Context; 7 import android.content.Context;
8 import android.util.Log; 8 import android.util.Log;
9 9
10 import java.lang.reflect.Constructor; 10 import java.lang.reflect.Constructor;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 */ 87 */
88 public abstract void startNetLogToFile(String fileName, boolean logAll); 88 public abstract void startNetLogToFile(String fileName, boolean logAll);
89 89
90 /** 90 /**
91 * Stops NetLog logging and flushes file to disk. If a logging session is 91 * Stops NetLog logging and flushes file to disk. If a logging session is
92 * not in progress, this call is ignored. 92 * not in progress, this call is ignored.
93 */ 93 */
94 public abstract void stopNetLog(); 94 public abstract void stopNetLog();
95 95
96 /** 96 /**
97 * Enables the network quality estimator, which collects and reports
98 * measurements of round trip time (RTT) and downstream throughput at
99 * various layers of the network stack. After enabling the estimator,
100 * listeners of RTT and throughput can be added with
101 * {@link #addRttListener} and {@link #addThroughputListener} and
102 * removed with {@link #removeRttListener} and
103 * {@link #removeThroughputListener}. The estimator uses memory and CPU
104 * only when enabled.
105 * @param executor an executor that will be used to notified all
106 * added RTT and throughput listeners.
107 * @deprecated not really deprecated but hidden for now as it's a prototype.
108 */
109 @Deprecated public abstract void enableNetworkQualityEstimator(Executor exec utor);
110
111 /**
112 * Enables the network quality estimator for testing. This must be called
113 * before round trip time and throughput listeners are added. Set both
114 * boolean parameters to false for default behavior.
115 * @param useLocalHostRequests include requests to localhost in estimates.
116 * @param useSmallerResponses include small responses in throughput estimate s.
117 * @param executor an {@link java.util.concurrent.Executor} on which all
118 * listeners will be called.
119 * @deprecated not really deprecated but hidden for now as it's a prototype.
120 */
121 @Deprecated
122 abstract void enableNetworkQualityEstimatorForTesting(
123 boolean useLocalHostRequests, boolean useSmallerResponses, Executor executor);
124
125 /**
126 * Registers a listener that gets called whenever the network quality
127 * estimator witnesses a sample round trip time. This must be called
128 * after {@link #enableNetworkQualityEstimator}, and with throw an
129 * exception otherwise. Round trip times may be recorded at various layers
130 * of the network stack, including TCP, QUIC, and at the URL request layer.
131 * The listener is called on the {@link java.util.concurrent.Executor} that
132 * is passed to {@link #enableNetworkQualityEstimator}.
133 * @param listener the listener of round trip times.
134 * @deprecated not really deprecated but hidden for now as it's a prototype.
135 */
136 @Deprecated public abstract void addRttListener(NetworkQualityRttListener li stener);
137
138 /**
139 * Removes a listener of round trip times if previously registered with
140 * {@link #addRttListener}. This should be called after a
141 * {@link NetworkQualityRttListener} is added in order to stop receiving
142 * observations.
143 * @param listener the listener of round trip times.
144 * @deprecated not really deprecated but hidden for now as it's a prototype.
145 */
146 @Deprecated public abstract void removeRttListener(NetworkQualityRttListener listener);
147
148 /**
149 * Registers a listener that gets called whenever the network quality
150 * estimator witnesses a sample throughput measurement. This must be called
151 * after {@link #enableNetworkQualityEstimator}. Throughput observations
152 * are computed by measuring bytes read over the active network interface
153 * at times when at least one URL response is being received. The listener
154 * is called on the {@link java.util.concurrent.Executor} that is passed to
155 * {@link #enableNetworkQualityEstimator}.
156 * @param listener the listener of throughput.
157 * @deprecated not really deprecated but hidden for now as it's a prototype.
158 */
159 @Deprecated
160 public abstract void addThroughputListener(NetworkQualityThroughputListener listener);
161
162 /**
163 * Removes a listener of throughput. This should be called after a
164 * {@link NetworkQualityThroughputListener} is added with
165 * {@link #addThroughputListener} in order to stop receiving observations.
166 * @param listener the listener of throughput.
167 * @deprecated not really deprecated but hidden for now as it's a prototype.
168 */
169 @Deprecated
170 public abstract void removeThroughputListener(NetworkQualityThroughputListen er listener);
171
172 /**
97 * Creates a {@link UrlRequestContext} with the given 173 * Creates a {@link UrlRequestContext} with the given
98 * {@link UrlRequestContextConfig}. 174 * {@link UrlRequestContextConfig}.
99 * @param context Android {@link Context}. 175 * @param context Android {@link Context}.
100 * @param config context configuration. 176 * @param config context configuration.
101 */ 177 */
102 public static UrlRequestContext createContext(Context context, 178 public static UrlRequestContext createContext(Context context,
103 UrlRequestContextConfig config) { 179 UrlRequestContextConfig config) {
104 UrlRequestContext urlRequestContext = null; 180 UrlRequestContext urlRequestContext = null;
105 if (config.userAgent().isEmpty()) { 181 if (config.userAgent().isEmpty()) {
106 config.setUserAgent(UserAgent.from(context)); 182 config.setUserAgent(UserAgent.from(context));
(...skipping 30 matching lines...) Expand all
137 } catch (ClassNotFoundException e) { 213 } catch (ClassNotFoundException e) {
138 // Leave as null. 214 // Leave as null.
139 } catch (Exception e) { 215 } catch (Exception e) {
140 throw new IllegalStateException( 216 throw new IllegalStateException(
141 "Cannot instantiate: " + CRONET_URL_REQUEST_CONTEXT, 217 "Cannot instantiate: " + CRONET_URL_REQUEST_CONTEXT,
142 e); 218 e);
143 } 219 }
144 return urlRequestContext; 220 return urlRequestContext;
145 } 221 }
146 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698