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; |
11 import android.os.Looper; | 11 import android.os.Looper; |
12 import android.os.Process; | 12 import android.os.Process; |
13 import android.util.Log; | 13 import android.util.Log; |
14 | 14 |
15 import org.chromium.base.CalledByNative; | 15 import org.chromium.base.CalledByNative; |
16 import org.chromium.base.JNINamespace; | 16 import org.chromium.base.JNINamespace; |
17 import org.chromium.base.NativeClassQualifiedName; | 17 import org.chromium.base.NativeClassQualifiedName; |
| 18 import org.chromium.base.VisibleForTesting; |
18 import org.chromium.base.annotations.UsedByReflection; | 19 import org.chromium.base.annotations.UsedByReflection; |
19 | 20 |
20 import java.util.concurrent.Executor; | 21 import java.util.concurrent.Executor; |
21 import java.util.concurrent.atomic.AtomicInteger; | 22 import java.util.concurrent.atomic.AtomicInteger; |
22 | 23 |
23 /** | 24 /** |
24 * UrlRequest context using Chromium HTTP stack implementation. | 25 * UrlRequest context using Chromium HTTP stack implementation. |
25 */ | 26 */ |
26 @JNINamespace("cronet") | 27 @JNINamespace("cronet") |
27 @UsedByReflection("UrlRequestContext.java") | 28 @UsedByReflection("UrlRequestContext.java") |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } | 146 } |
146 | 147 |
147 /** | 148 /** |
148 * Mark request as completed to allow shutdown when there are no active | 149 * Mark request as completed to allow shutdown when there are no active |
149 * requests. | 150 * requests. |
150 */ | 151 */ |
151 void onRequestDestroyed(UrlRequest urlRequest) { | 152 void onRequestDestroyed(UrlRequest urlRequest) { |
152 mActiveRequestCount.decrementAndGet(); | 153 mActiveRequestCount.decrementAndGet(); |
153 } | 154 } |
154 | 155 |
| 156 @VisibleForTesting |
155 long getUrlRequestContextAdapter() { | 157 long getUrlRequestContextAdapter() { |
156 synchronized (mLock) { | 158 synchronized (mLock) { |
157 checkHaveAdapter(); | 159 checkHaveAdapter(); |
158 return mUrlRequestContextAdapter; | 160 return mUrlRequestContextAdapter; |
159 } | 161 } |
160 } | 162 } |
161 | 163 |
162 private void checkHaveAdapter() throws IllegalStateException { | 164 private void checkHaveAdapter() throws IllegalStateException { |
163 if (!haveRequestContextAdapter()) { | 165 if (!haveRequestContextAdapter()) { |
164 throw new IllegalStateException("Context is shut down."); | 166 throw new IllegalStateException("Context is shut down."); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 209 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
208 private native void nativeStartNetLogToFile(long nativePtr, | 210 private native void nativeStartNetLogToFile(long nativePtr, |
209 String fileName); | 211 String fileName); |
210 | 212 |
211 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 213 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
212 private native void nativeStopNetLog(long nativePtr); | 214 private native void nativeStopNetLog(long nativePtr); |
213 | 215 |
214 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 216 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
215 private native void nativeInitRequestContextOnMainThread(long nativePtr); | 217 private native void nativeInitRequestContextOnMainThread(long nativePtr); |
216 } | 218 } |
OLD | NEW |