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.UsedByReflection; |
18 | 19 |
19 import java.util.concurrent.Executor; | 20 import java.util.concurrent.Executor; |
20 import java.util.concurrent.atomic.AtomicInteger; | 21 import java.util.concurrent.atomic.AtomicInteger; |
21 | 22 |
22 /** | 23 /** |
23 * UrlRequest context using Chromium HTTP stack implementation. | 24 * UrlRequest context using Chromium HTTP stack implementation. |
24 */ | 25 */ |
25 @JNINamespace("cronet") | 26 @JNINamespace("cronet") |
| 27 @UsedByReflection("UrlRequestContext.java") |
26 public class CronetUrlRequestContext extends UrlRequestContext { | 28 public class CronetUrlRequestContext extends UrlRequestContext { |
27 private static final int LOG_NONE = 3; // LOG(FATAL), no VLOG. | 29 private static final int LOG_NONE = 3; // LOG(FATAL), no VLOG. |
28 private static final int LOG_DEBUG = -1; // LOG(FATAL...INFO), VLOG(1) | 30 private static final int LOG_DEBUG = -1; // LOG(FATAL...INFO), VLOG(1) |
29 private static final int LOG_VERBOSE = -2; // LOG(FATAL...INFO), VLOG(2) | 31 private static final int LOG_VERBOSE = -2; // LOG(FATAL...INFO), VLOG(2) |
30 static final String LOG_TAG = "ChromiumNetwork"; | 32 static final String LOG_TAG = "ChromiumNetwork"; |
31 | 33 |
32 /** | 34 /** |
33 * Synchronize access to mUrlRequestContextAdapter and shutdown routine. | 35 * Synchronize access to mUrlRequestContextAdapter and shutdown routine. |
34 */ | 36 */ |
35 private final Object mLock = new Object(); | 37 private final Object mLock = new Object(); |
36 private final ConditionVariable mInitCompleted = new ConditionVariable(false
); | 38 private final ConditionVariable mInitCompleted = new ConditionVariable(false
); |
37 private final AtomicInteger mActiveRequestCount = new AtomicInteger(0); | 39 private final AtomicInteger mActiveRequestCount = new AtomicInteger(0); |
38 | 40 |
39 private long mUrlRequestContextAdapter = 0; | 41 private long mUrlRequestContextAdapter = 0; |
40 private Thread mNetworkThread; | 42 private Thread mNetworkThread; |
41 | 43 |
| 44 @UsedByReflection("UrlRequestContext.java") |
42 public CronetUrlRequestContext(Context context, | 45 public CronetUrlRequestContext(Context context, |
43 UrlRequestContextConfig config) { | 46 UrlRequestContextConfig config) { |
44 CronetLibraryLoader.ensureInitialized(context, config); | 47 CronetLibraryLoader.ensureInitialized(context, config); |
45 nativeSetMinLogLevel(getLoggingLevel()); | 48 nativeSetMinLogLevel(getLoggingLevel()); |
46 mUrlRequestContextAdapter = nativeCreateRequestContextAdapter(config.toS
tring()); | 49 mUrlRequestContextAdapter = nativeCreateRequestContextAdapter(config.toS
tring()); |
47 if (mUrlRequestContextAdapter == 0) { | 50 if (mUrlRequestContextAdapter == 0) { |
48 throw new NullPointerException("Context Adapter creation failed."); | 51 throw new NullPointerException("Context Adapter creation failed."); |
49 } | 52 } |
50 | 53 |
51 // Init native Chromium URLRequestContext on main UI thread. | 54 // Init native Chromium URLRequestContext on main UI thread. |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 207 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
205 private native void nativeStartNetLogToFile(long nativePtr, | 208 private native void nativeStartNetLogToFile(long nativePtr, |
206 String fileName); | 209 String fileName); |
207 | 210 |
208 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 211 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
209 private native void nativeStopNetLog(long nativePtr); | 212 private native void nativeStopNetLog(long nativePtr); |
210 | 213 |
211 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 214 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
212 private native void nativeInitRequestContextOnMainThread(long nativePtr); | 215 private native void nativeInitRequestContextOnMainThread(long nativePtr); |
213 } | 216 } |
OLD | NEW |