Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | |
|
pauljensen
2015/10/05 14:49:40
@VisibleForTesting
bengr
2015/10/06 16:16:50
Done.
| |
| 122 abstract void enableNetworkQualityEstimator( | |
|
pauljensen
2015/10/05 14:49:40
nit: might be good to add "ForTesting" suffix
bengr
2015/10/06 16:16:50
Done.
| |
| 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}. Round trip times may be | |
|
pauljensen
2015/10/05 14:49:40
might be good to mention what happens if not calle
bengr
2015/10/06 16:16:50
Done.
| |
| 129 * recorded at various layers of the network stack, including TCP, QUIC, | |
| 130 * and at the URL request layer. The listener is called on the | |
| 131 * {@link java.util.concurrent.Executor} that is passed to | |
| 132 * {@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 on the listener list. This | |
|
pauljensen
2015/10/05 14:49:40
"the listener list" is not a term a reader might b
bengr
2015/10/06 16:16:50
Done.
| |
| 140 * should be called after a NetworkQualityRttListener is added in order to | |
|
pauljensen
2015/10/05 14:49:40
wrap NQERttListener in @link
bengr
2015/10/06 16:16:50
Done.
| |
| 141 * stop receiving observations. | |
| 142 * @param listener the listener of round trip times. | |
| 143 * @deprecated not really deprecated but hidden for now as it's a prototype. | |
| 144 */ | |
| 145 @Deprecated public abstract void removeRttListener(NetworkQualityRttListener listener); | |
| 146 | |
| 147 /** | |
| 148 * Registers a listener that gets called whenever the network quality | |
| 149 * estimator witnesses a sample throughput measurement. This must be called | |
| 150 * after {@link #enableNetworkQualityEstimator}. Throughput observations | |
| 151 * are computed by measuring bytes read over the active network interface | |
| 152 * at times when at least one URL response is being received. The listener | |
| 153 * is called on the {@link java.util.concurrent.Executor} that is passed to | |
| 154 * {@link #enableNetworkQualityEstimator}. | |
| 155 * @param listener the listener of throughput. | |
| 156 * @deprecated not really deprecated but hidden for now as it's a prototype. | |
| 157 */ | |
| 158 @Deprecated | |
| 159 public abstract void addThroughputListener(NetworkQualityThroughputListener listener); | |
| 160 | |
| 161 /** | |
| 162 * Removes a listener of throughput. This should be called after a | |
| 163 * NetworkQualityThroughputListener is added in order to stop receiving | |
|
pauljensen
2015/10/05 14:49:40
"is added"->"is added with {@link #addThroughputLi
pauljensen
2015/10/05 14:49:40
wrap NetworkQualityThroughputListener in @link
bengr
2015/10/06 16:16:50
Done.
bengr
2015/10/06 16:16:50
Done.
| |
| 164 * observations. | |
| 165 * @param listener the listener of throughput. | |
| 166 * @deprecated not really deprecated but hidden for now as it's a prototype. | |
| 167 */ | |
| 168 @Deprecated | |
| 169 public abstract void removeThroughputListener(NetworkQualityThroughputListen er listener); | |
| 170 | |
| 171 /** | |
| 97 * Creates a {@link UrlRequestContext} with the given | 172 * Creates a {@link UrlRequestContext} with the given |
| 98 * {@link UrlRequestContextConfig}. | 173 * {@link UrlRequestContextConfig}. |
| 99 * @param context Android {@link Context}. | 174 * @param context Android {@link Context}. |
| 100 * @param config context configuration. | 175 * @param config context configuration. |
| 101 */ | 176 */ |
| 102 public static UrlRequestContext createContext(Context context, | 177 public static UrlRequestContext createContext(Context context, |
| 103 UrlRequestContextConfig config) { | 178 UrlRequestContextConfig config) { |
| 104 UrlRequestContext urlRequestContext = null; | 179 UrlRequestContext urlRequestContext = null; |
| 105 if (config.userAgent().isEmpty()) { | 180 if (config.userAgent().isEmpty()) { |
| 106 config.setUserAgent(UserAgent.from(context)); | 181 config.setUserAgent(UserAgent.from(context)); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 137 } catch (ClassNotFoundException e) { | 212 } catch (ClassNotFoundException e) { |
| 138 // Leave as null. | 213 // Leave as null. |
| 139 } catch (Exception e) { | 214 } catch (Exception e) { |
| 140 throw new IllegalStateException( | 215 throw new IllegalStateException( |
| 141 "Cannot instantiate: " + CRONET_URL_REQUEST_CONTEXT, | 216 "Cannot instantiate: " + CRONET_URL_REQUEST_CONTEXT, |
| 142 e); | 217 e); |
| 143 } | 218 } |
| 144 return urlRequestContext; | 219 return urlRequestContext; |
| 145 } | 220 } |
| 146 } | 221 } |
| OLD | NEW |