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

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: Addressed remaining comments Created 5 years, 3 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. This must be called before round
98 * trip time and throughput observers are added.
99 * @param executor An executor on which all observers will be called.
100 */
101 public abstract void enableNetworkQualityEstimator(Executor executor);
102
103 /**
104 * Enables the network quality estimator for testing. This must be called
105 * before round trip time and throughput observers are added. Set both
106 * boolean parameters to false for default behavior.
107 * @param useLocalHostRequests Include requests to localhost in estimates.
108 * @param useSmallerResponses Include small responses in throughput estimate s.
109 * @param executor An executor on which all observers will be called.
110 */
111 abstract void enableNetworkQualityEstimator(
112 boolean useLocalHostRequests, boolean useSmallerResponses, Executor executor);
113
114 /**
115 * Adds an observer of round trip time observations. This must be called
116 * after {@link #enableNetworkQualityEstimator}.
117 * @param observer The observer of round trip times.
118 */
119 public abstract void addRttObserver(NetworkQualityRttObserver observer);
120
121 /**
122 * Removes an observer of round trip times if on the observer list. This
123 * should be called after an RttObserver is added in order to stop
124 * receiving observations.
125 * @param observer The observer of round trip times.
126 */
127 public abstract void removeRttObserver(NetworkQualityRttObserver observer);
128
129 /**
130 * Adds an observer of throughout. This must be called after
131 * {@link #enableNetworkQualityEstimator}.
132 * @param observer The observer of throughput.
133 */
134 public abstract void addThroughputObserver(NetworkQualityThroughputObserver observer);
135
136 /**
137 * Removes an observer of throughput. This should be called after a
138 * ThroughputObserver is added in order to stop receiving observations.
139 * @param observer The observer of throughput.
140 */
141 public abstract void removeThroughputObserver(NetworkQualityThroughputObserv er observer);
142
143 /**
97 * Creates a {@link UrlRequestContext} with the given 144 * Creates a {@link UrlRequestContext} with the given
98 * {@link UrlRequestContextConfig}. 145 * {@link UrlRequestContextConfig}.
99 * @param context Android {@link Context}. 146 * @param context Android {@link Context}.
100 * @param config context configuration. 147 * @param config context configuration.
101 */ 148 */
102 public static UrlRequestContext createContext(Context context, 149 public static UrlRequestContext createContext(Context context,
103 UrlRequestContextConfig config) { 150 UrlRequestContextConfig config) {
104 UrlRequestContext urlRequestContext = null; 151 UrlRequestContext urlRequestContext = null;
105 if (config.userAgent().isEmpty()) { 152 if (config.userAgent().isEmpty()) {
106 config.setUserAgent(UserAgent.from(context)); 153 config.setUserAgent(UserAgent.from(context));
(...skipping 30 matching lines...) Expand all
137 } catch (ClassNotFoundException e) { 184 } catch (ClassNotFoundException e) {
138 // Leave as null. 185 // Leave as null.
139 } catch (Exception e) { 186 } catch (Exception e) {
140 throw new IllegalStateException( 187 throw new IllegalStateException(
141 "Cannot instantiate: " + CRONET_URL_REQUEST_CONTEXT, 188 "Cannot instantiate: " + CRONET_URL_REQUEST_CONTEXT,
142 e); 189 e);
143 } 190 }
144 return urlRequestContext; 191 return urlRequestContext;
145 } 192 }
146 } 193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698