OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.Handler; | 8 import android.os.Handler; |
9 import android.os.Looper; | 9 import android.os.Looper; |
10 | 10 |
11 import org.chromium.base.ContextUtils; | 11 import org.chromium.base.ContextUtils; |
12 import org.chromium.base.Log; | 12 import org.chromium.base.Log; |
mef
2016/07/13 19:15:58
Some implementation modules use android.util.Log,
pauljensen
2016/08/17 11:58:33
Done.
| |
13 import org.chromium.base.annotations.JNINamespace; | 13 import org.chromium.base.annotations.JNINamespace; |
14 | 14 |
15 /** | 15 /** |
16 * CronetLibraryLoader loads and initializes native library on main thread. | 16 * CronetLibraryLoader loads and initializes native library on main thread. |
17 */ | 17 */ |
18 @JNINamespace("cronet") | 18 @JNINamespace("cronet") |
19 class CronetLibraryLoader { | 19 class CronetLibraryLoader { |
20 // Synchronize initialization. | 20 // Synchronize initialization. |
21 private static final Object sLoadLock = new Object(); | 21 private static final Object sLoadLock = new Object(); |
22 private static final String TAG = "CronetLibraryLoader"; | 22 private static final String TAG = CronetLibraryLoader.class.getSimpleName(); |
23 // Has library loading commenced? Setting guarded by sLoadLock. | 23 // Has library loading commenced? Setting guarded by sLoadLock. |
24 private static volatile boolean sInitStarted = false; | 24 private static volatile boolean sInitStarted = false; |
25 // Has ensureMainThreadInitialized() completed? Only accessed on main threa d. | 25 // Has ensureMainThreadInitialized() completed? Only accessed on main threa d. |
26 private static boolean sMainThreadInitDone = false; | 26 private static boolean sMainThreadInitDone = false; |
27 | 27 |
28 /** | 28 /** |
29 * Ensure that native library is loaded and initialized. Can be called from | 29 * Ensure that native library is loaded and initialized. Can be called from |
30 * any thread, the load and initialization is performed on main thread. | 30 * any thread, the load and initialization is performed on main thread. |
31 */ | 31 */ |
32 static void ensureInitialized(final Context context, final CronetEngine.Buil der builder) { | 32 static void ensureInitialized(final Context context, final CronetEngine.Buil der builder) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 // the undesired initial network change observer notification, which | 88 // the undesired initial network change observer notification, which |
89 // will cause active requests to fail with ERR_NETWORK_CHANGED. | 89 // will cause active requests to fail with ERR_NETWORK_CHANGED. |
90 nativeCronetInitOnMainThread(); | 90 nativeCronetInitOnMainThread(); |
91 sMainThreadInitDone = true; | 91 sMainThreadInitDone = true; |
92 } | 92 } |
93 | 93 |
94 // Native methods are implemented in cronet_library_loader.cc. | 94 // Native methods are implemented in cronet_library_loader.cc. |
95 private static native void nativeCronetInitOnMainThread(); | 95 private static native void nativeCronetInitOnMainThread(); |
96 private static native String nativeGetCronetVersion(); | 96 private static native String nativeGetCronetVersion(); |
97 } | 97 } |
OLD | NEW |