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.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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 @GuardedBy("mNetworkQualityLock") | 70 @GuardedBy("mNetworkQualityLock") |
71 private final ObserverList<NetworkQualityThroughputListener> mThroughputList
enerList = | 71 private final ObserverList<NetworkQualityThroughputListener> mThroughputList
enerList = |
72 new ObserverList<NetworkQualityThroughputListener>(); | 72 new ObserverList<NetworkQualityThroughputListener>(); |
73 | 73 |
74 @GuardedBy("mNetworkQualityLock") | 74 @GuardedBy("mNetworkQualityLock") |
75 private final ObserverList<RequestFinishedListener> mFinishedListenerList = | 75 private final ObserverList<RequestFinishedListener> mFinishedListenerList = |
76 new ObserverList<RequestFinishedListener>(); | 76 new ObserverList<RequestFinishedListener>(); |
77 | 77 |
78 @UsedByReflection("CronetEngine.java") | 78 @UsedByReflection("CronetEngine.java") |
79 public CronetUrlRequestContext(final CronetEngine.Builder builder) { | 79 public CronetUrlRequestContext(CronetEngine.Builder builder) { |
80 CronetLibraryLoader.ensureInitialized(builder.getContext(), builder); | 80 CronetLibraryLoader.ensureInitialized(builder.getContext(), builder); |
81 nativeSetMinLogLevel(getLoggingLevel()); | 81 nativeSetMinLogLevel(getLoggingLevel()); |
82 synchronized (mLock) { | 82 synchronized (mLock) { |
83 mUrlRequestContextAdapter = nativeCreateRequestContextAdapter( | 83 mUrlRequestContextAdapter = nativeCreateRequestContextAdapter( |
84 createNativeUrlRequestContextConfig(builder.getContext(), bu
ilder)); | 84 createNativeUrlRequestContextConfig(builder.getContext(), bu
ilder)); |
85 if (mUrlRequestContextAdapter == 0) { | 85 if (mUrlRequestContextAdapter == 0) { |
86 throw new NullPointerException("Context Adapter creation failed.
"); | 86 throw new NullPointerException("Context Adapter creation failed.
"); |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 // Init native Chromium URLRequestContext on main UI thread. | 90 // Init native Chromium URLRequestContext on main UI thread. |
91 Runnable task = new Runnable() { | 91 Runnable task = new Runnable() { |
92 @Override | 92 @Override |
93 public void run() { | 93 public void run() { |
94 CronetLibraryLoader.ensureInitializedOnMainThread(builder.getCon
text()); | |
95 synchronized (mLock) { | 94 synchronized (mLock) { |
96 // mUrlRequestContextAdapter is guaranteed to exist until | 95 // mUrlRequestContextAdapter is guaranteed to exist until |
97 // initialization on main and network threads completes and | 96 // initialization on main and network threads completes and |
98 // initNetworkThread is called back on network thread. | 97 // initNetworkThread is called back on network thread. |
99 nativeInitRequestContextOnMainThread(mUrlRequestContextAdapt
er); | 98 nativeInitRequestContextOnMainThread(mUrlRequestContextAdapt
er); |
100 } | 99 } |
101 } | 100 } |
102 }; | 101 }; |
103 // Run task immediately or post it to the UI thread. | 102 // Run task immediately or post it to the UI thread. |
104 if (Looper.getMainLooper() == Looper.myLooper()) { | 103 if (Looper.getMainLooper() == Looper.myLooper()) { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 505 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
507 private native void nativeEnableNetworkQualityEstimator( | 506 private native void nativeEnableNetworkQualityEstimator( |
508 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp
onses); | 507 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp
onses); |
509 | 508 |
510 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 509 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
511 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); | 510 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); |
512 | 511 |
513 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 512 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
514 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); | 513 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); |
515 } | 514 } |
OLD | NEW |