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

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

Issue 2188553002: Delete old NetworkQualityEstimator Cronet API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metrics-executor
Patch Set: rebase again. ugh. Created 4 years, 4 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
« no previous file with comments | « components/cronet/android/cronet_url_request_context_adapter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.impl; 5 package org.chromium.net.impl;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Build; 8 import android.os.Build;
9 import android.os.ConditionVariable; 9 import android.os.ConditionVariable;
10 import android.os.Handler; 10 import android.os.Handler;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 /** 56 /**
57 * Synchronize access to mUrlRequestContextAdapter and shutdown routine. 57 * Synchronize access to mUrlRequestContextAdapter and shutdown routine.
58 */ 58 */
59 private final Object mLock = new Object(); 59 private final Object mLock = new Object();
60 private final ConditionVariable mInitCompleted = new ConditionVariable(false ); 60 private final ConditionVariable mInitCompleted = new ConditionVariable(false );
61 private final AtomicInteger mActiveRequestCount = new AtomicInteger(0); 61 private final AtomicInteger mActiveRequestCount = new AtomicInteger(0);
62 62
63 private long mUrlRequestContextAdapter = 0; 63 private long mUrlRequestContextAdapter = 0;
64 private Thread mNetworkThread; 64 private Thread mNetworkThread;
65 65
66 private Executor mNetworkQualityExecutor;
67 private boolean mNetworkQualityEstimatorEnabled; 66 private boolean mNetworkQualityEstimatorEnabled;
68 67
69 /** 68 /**
70 * Locks operations on network quality listeners, because listener 69 * Locks operations on network quality listeners, because listener
71 * addition and removal may occur on a different thread from notification. 70 * addition and removal may occur on a different thread from notification.
72 */ 71 */
73 private final Object mNetworkQualityLock = new Object(); 72 private final Object mNetworkQualityLock = new Object();
74 73
75 /** 74 /**
76 * Locks operations on the list of RequestFinishedListeners, because operati ons can happen on 75 * Locks operations on the list of RequestFinishedListeners, because operati ons can happen on
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 return mCertVerifierData; 253 return mCertVerifierData;
255 } 254 }
256 255
257 // This method is intentionally non-static to ensure Cronet native library 256 // This method is intentionally non-static to ensure Cronet native library
258 // is loaded by class constructor. 257 // is loaded by class constructor.
259 @Override 258 @Override
260 public byte[] getGlobalMetricsDeltas() { 259 public byte[] getGlobalMetricsDeltas() {
261 return nativeGetHistogramDeltas(); 260 return nativeGetHistogramDeltas();
262 } 261 }
263 262
264 /**
265 * TODO(tbansal): http://crbug.com/618034 Remove this API once all
266 * embedders have switched to using a request finished listener that
267 * provides its own executor.
268 */
269 @Override
270 public void setRequestFinishedListenerExecutor(Executor executor) {
271 if (!mNetworkQualityEstimatorEnabled) {
272 throw new IllegalStateException("Network quality estimator not enabl ed");
273 }
274 if (executor == null) {
275 throw new NullPointerException("Request finished listener requires a n executor");
276 }
277 if (mNetworkQualityExecutor != null) {
278 throw new NullPointerException("Request finished listener executor a lready set");
279 }
280 mNetworkQualityExecutor = executor;
281 }
282
283 /**
284 * TODO(tbansal): http://crbug.com/618034 Remove this API once all
285 * embedders have switched to using CronetEngine builder for enabling
286 * network quality estimator.
287 */
288 @Override
289 public void enableNetworkQualityEstimator(Executor executor) {
290 if (mNetworkQualityEstimatorEnabled) {
291 throw new IllegalStateException("Network quality estimator already e nabled");
292 }
293 mNetworkQualityEstimatorEnabled = true;
294 if (executor == null) {
295 throw new NullPointerException("Network quality estimator requires a n executor");
296 }
297 mNetworkQualityExecutor = executor;
298 synchronized (mLock) {
299 checkHaveAdapter();
300 nativeEnableNetworkQualityEstimator(mUrlRequestContextAdapter);
301 }
302 }
303
304 @VisibleForTesting 263 @VisibleForTesting
305 @Override 264 @Override
306 public void configureNetworkQualityEstimatorForTesting( 265 public void configureNetworkQualityEstimatorForTesting(
307 boolean useLocalHostRequests, boolean useSmallerResponses) { 266 boolean useLocalHostRequests, boolean useSmallerResponses) {
308 if (!mNetworkQualityEstimatorEnabled) { 267 if (!mNetworkQualityEstimatorEnabled) {
309 throw new IllegalStateException("Network quality estimator must be e nabled"); 268 throw new IllegalStateException("Network quality estimator must be e nabled");
310 } 269 }
311 synchronized (mLock) { 270 synchronized (mLock) {
312 checkHaveAdapter(); 271 checkHaveAdapter();
313 nativeConfigureNetworkQualityEstimatorForTesting( 272 nativeConfigureNetworkQualityEstimatorForTesting(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 mThroughputListenerList.removeObserver(listener); 331 mThroughputListenerList.removeObserver(listener);
373 if (mThroughputListenerList.isEmpty()) { 332 if (mThroughputListenerList.isEmpty()) {
374 synchronized (mLock) { 333 synchronized (mLock) {
375 checkHaveAdapter(); 334 checkHaveAdapter();
376 nativeProvideThroughputObservations(mUrlRequestContextAdapte r, false); 335 nativeProvideThroughputObservations(mUrlRequestContextAdapte r, false);
377 } 336 }
378 } 337 }
379 } 338 }
380 } 339 }
381 340
382 /**
383 * TODO(tbansal): http://crbug.com/618034 Remove this API once all
384 * embedders have switched to using a request finished listener that
385 * provides its own executor.
386 */
387 @Override 341 @Override
388 public void addRequestFinishedListener(RequestFinishedListener listener) { 342 public void addRequestFinishedListener(RequestFinishedListener listener) {
389 synchronized (mFinishedListenerLock) { 343 synchronized (mFinishedListenerLock) {
390 mFinishedListenerList.add(listener); 344 mFinishedListenerList.add(listener);
391 } 345 }
392 } 346 }
393 347
394 /**
395 * TODO(tbansal): http://crbug.com/618034 Remove this API.
396 */
397 @Override 348 @Override
398 public void removeRequestFinishedListener(RequestFinishedListener listener) { 349 public void removeRequestFinishedListener(RequestFinishedListener listener) {
399 synchronized (mFinishedListenerLock) { 350 synchronized (mFinishedListenerLock) {
400 mFinishedListenerList.remove(listener); 351 mFinishedListenerList.remove(listener);
401 } 352 }
402 } 353 }
403 354
404 @Override 355 @Override
405 public URLConnection openConnection(URL url) { 356 public URLConnection openConnection(URL url) {
406 return openConnection(url, Proxy.NO_PROXY); 357 return openConnection(url, Proxy.NO_PROXY);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 private native void nativeGetCertVerifierData(long nativePtr); 536 private native void nativeGetCertVerifierData(long nativePtr);
586 537
587 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 538 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
588 private native void nativeInitRequestContextOnMainThread(long nativePtr); 539 private native void nativeInitRequestContextOnMainThread(long nativePtr);
589 540
590 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 541 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
591 private native void nativeConfigureNetworkQualityEstimatorForTesting( 542 private native void nativeConfigureNetworkQualityEstimatorForTesting(
592 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp onses); 543 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp onses);
593 544
594 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 545 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
595 private native void nativeEnableNetworkQualityEstimator(long nativePtr);
596
597 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
598 private native void nativeProvideRTTObservations(long nativePtr, boolean sho uld); 546 private native void nativeProvideRTTObservations(long nativePtr, boolean sho uld);
599 547
600 @NativeClassQualifiedName("CronetURLRequestContextAdapter") 548 @NativeClassQualifiedName("CronetURLRequestContextAdapter")
601 private native void nativeProvideThroughputObservations(long nativePtr, bool ean should); 549 private native void nativeProvideThroughputObservations(long nativePtr, bool ean should);
602 } 550 }
OLDNEW
« no previous file with comments | « components/cronet/android/cronet_url_request_context_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698