| 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.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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 private boolean mNetworkQualityEstimatorEnabled; | 75 private boolean mNetworkQualityEstimatorEnabled; |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * Locks operations on network quality listeners, because listener | 78 * Locks operations on network quality listeners, because listener |
| 79 * addition and removal may occur on a different thread from notification. | 79 * addition and removal may occur on a different thread from notification. |
| 80 */ | 80 */ |
| 81 private final Object mNetworkQualityLock = new Object(); | 81 private final Object mNetworkQualityLock = new Object(); |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * Locks operations on the list of RequestFinishedInfo.Listeners, because op
erations can happen | 84 * Locks operations on the list of RequestFinishedInfo.Listeners, because op
erations can happen |
| 85 * on any thread. | 85 * on any thread. This should be used for fine-grained locking only. In part
icular, don't call |
| 86 * any UrlRequest methods that acquire mUrlRequestAdapterLock while holding
this lock. |
| 86 */ | 87 */ |
| 87 private final Object mFinishedListenerLock = new Object(); | 88 private final Object mFinishedListenerLock = new Object(); |
| 88 | 89 |
| 89 /** | 90 /** |
| 90 * Current effective connection type as computed by the network quality | 91 * Current effective connection type as computed by the network quality |
| 91 * estimator. | 92 * estimator. |
| 92 */ | 93 */ |
| 93 @GuardedBy("mNetworkQualityLock") | 94 @GuardedBy("mNetworkQualityLock") |
| 94 private int mEffectiveConnectionType = EffectiveConnectionType.TYPE_UNKNOWN; | 95 private int mEffectiveConnectionType = EffectiveConnectionType.TYPE_UNKNOWN; |
| 95 | 96 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 } | 424 } |
| 424 } | 425 } |
| 425 | 426 |
| 426 @Override | 427 @Override |
| 427 public void removeRequestFinishedListener(RequestFinishedInfo.Listener liste
ner) { | 428 public void removeRequestFinishedListener(RequestFinishedInfo.Listener liste
ner) { |
| 428 synchronized (mFinishedListenerLock) { | 429 synchronized (mFinishedListenerLock) { |
| 429 mFinishedListenerList.remove(listener); | 430 mFinishedListenerList.remove(listener); |
| 430 } | 431 } |
| 431 } | 432 } |
| 432 | 433 |
| 434 boolean hasRequestFinishedListener() { |
| 435 synchronized (mFinishedListenerLock) { |
| 436 return !mFinishedListenerList.isEmpty(); |
| 437 } |
| 438 } |
| 439 |
| 433 @Override | 440 @Override |
| 434 public URLConnection openConnection(URL url) { | 441 public URLConnection openConnection(URL url) { |
| 435 return openConnection(url, Proxy.NO_PROXY); | 442 return openConnection(url, Proxy.NO_PROXY); |
| 436 } | 443 } |
| 437 | 444 |
| 438 @Override | 445 @Override |
| 439 public URLConnection openConnection(URL url, Proxy proxy) { | 446 public URLConnection openConnection(URL url, Proxy proxy) { |
| 440 if (proxy.type() != Proxy.Type.DIRECT) { | 447 if (proxy.type() != Proxy.Type.DIRECT) { |
| 441 throw new UnsupportedOperationException(); | 448 throw new UnsupportedOperationException(); |
| 442 } | 449 } |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 643 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 637 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); | 644 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); |
| 638 | 645 |
| 639 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 646 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 640 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); | 647 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); |
| 641 | 648 |
| 642 public boolean isNetworkThread(Thread thread) { | 649 public boolean isNetworkThread(Thread thread) { |
| 643 return thread == mNetworkThread; | 650 return thread == mNetworkThread; |
| 644 } | 651 } |
| 645 } | 652 } |
| OLD | NEW |