| 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.impl; | 5 package org.chromium.net.impl; |
| 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 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 * any thread, the load and initialization is performed on main thread. | 34 * any thread, the load and initialization is performed on main thread. |
| 35 */ | 35 */ |
| 36 public static void ensureInitialized( | 36 public static void ensureInitialized( |
| 37 final Context context, final CronetEngine.Builder builder) { | 37 final Context context, final CronetEngine.Builder builder) { |
| 38 synchronized (sLoadLock) { | 38 synchronized (sLoadLock) { |
| 39 if (sInitStarted) { | 39 if (sInitStarted) { |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 sInitStarted = true; | 42 sInitStarted = true; |
| 43 ContextUtils.initApplicationContext(context.getApplicationContext())
; | 43 ContextUtils.initApplicationContext(context.getApplicationContext())
; |
| 44 builder.loadLibrary(); | 44 if (builder.libraryLoader() != null) { |
| 45 builder.libraryLoader().loadLibrary(builder.libraryName()); |
| 46 } else { |
| 47 System.loadLibrary(builder.libraryName()); |
| 48 } |
| 45 ContextUtils.initApplicationContextForNative(); | 49 ContextUtils.initApplicationContextForNative(); |
| 46 if (!ImplVersion.CRONET_VERSION.equals(nativeGetCronetVersion())) { | 50 if (!ImplVersion.CRONET_VERSION.equals(nativeGetCronetVersion())) { |
| 47 throw new RuntimeException(String.format("Expected Cronet versio
n number %s, " | 51 throw new RuntimeException(String.format("Expected Cronet versio
n number %s, " |
| 48 + "actual version number %s.", | 52 + "actual version number %s.", |
| 49 ImplVersion.CRONET_VERSION, nativeGetCronetVersion())); | 53 ImplVersion.CRONET_VERSION, nativeGetCronetVersion())); |
| 50 } | 54 } |
| 51 Log.i(TAG, "Cronet version: %s, arch: %s", ImplVersion.CRONET_VERSIO
N, | 55 Log.i(TAG, "Cronet version: %s, arch: %s", ImplVersion.CRONET_VERSIO
N, |
| 52 System.getProperty("os.arch")); | 56 System.getProperty("os.arch")); |
| 53 // Init native Chromium CronetEngine on Main UI thread. | 57 // Init native Chromium CronetEngine on Main UI thread. |
| 54 Runnable task = new Runnable() { | 58 Runnable task = new Runnable() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // the undesired initial network change observer notification, which | 95 // the undesired initial network change observer notification, which |
| 92 // will cause active requests to fail with ERR_NETWORK_CHANGED. | 96 // will cause active requests to fail with ERR_NETWORK_CHANGED. |
| 93 nativeCronetInitOnMainThread(); | 97 nativeCronetInitOnMainThread(); |
| 94 sMainThreadInitDone = true; | 98 sMainThreadInitDone = true; |
| 95 } | 99 } |
| 96 | 100 |
| 97 // Native methods are implemented in cronet_library_loader.cc. | 101 // Native methods are implemented in cronet_library_loader.cc. |
| 98 private static native void nativeCronetInitOnMainThread(); | 102 private static native void nativeCronetInitOnMainThread(); |
| 99 private static native String nativeGetCronetVersion(); | 103 private static native String nativeGetCronetVersion(); |
| 100 } | 104 } |
| OLD | NEW |