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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 } | 421 } |
421 } | 422 } |
422 | 423 |
423 @Override | 424 @Override |
424 public void removeRequestFinishedListener(RequestFinishedInfo.Listener liste
ner) { | 425 public void removeRequestFinishedListener(RequestFinishedInfo.Listener liste
ner) { |
425 synchronized (mFinishedListenerLock) { | 426 synchronized (mFinishedListenerLock) { |
426 mFinishedListenerList.remove(listener); | 427 mFinishedListenerList.remove(listener); |
427 } | 428 } |
428 } | 429 } |
429 | 430 |
| 431 boolean hasRequestFinishedListener() { |
| 432 synchronized (mFinishedListenerLock) { |
| 433 return !mFinishedListenerList.isEmpty(); |
| 434 } |
| 435 } |
| 436 |
430 @Override | 437 @Override |
431 public URLConnection openConnection(URL url) { | 438 public URLConnection openConnection(URL url) { |
432 return openConnection(url, Proxy.NO_PROXY); | 439 return openConnection(url, Proxy.NO_PROXY); |
433 } | 440 } |
434 | 441 |
435 @Override | 442 @Override |
436 public URLConnection openConnection(URL url, Proxy proxy) { | 443 public URLConnection openConnection(URL url, Proxy proxy) { |
437 if (proxy.type() != Proxy.Type.DIRECT) { | 444 if (proxy.type() != Proxy.Type.DIRECT) { |
438 throw new UnsupportedOperationException(); | 445 throw new UnsupportedOperationException(); |
439 } | 446 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 640 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
634 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); | 641 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); |
635 | 642 |
636 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 643 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
637 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); | 644 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); |
638 | 645 |
639 public boolean isNetworkThread(Thread thread) { | 646 public boolean isNetworkThread(Thread thread) { |
640 return thread == mNetworkThread; | 647 return thread == mNetworkThread; |
641 } | 648 } |
642 } | 649 } |
OLD | NEW |