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 25 matching lines...) Expand all Loading... |
36 public static void ensureInitialized( | 36 public static void ensureInitialized( |
37 final Context applicationContext, final CronetEngineBuilderImpl buil
der) { | 37 final Context applicationContext, final CronetEngineBuilderImpl buil
der) { |
38 synchronized (sLoadLock) { | 38 synchronized (sLoadLock) { |
39 if (!sLibraryLoaded) { | 39 if (!sLibraryLoaded) { |
40 ContextUtils.initApplicationContext(applicationContext); | 40 ContextUtils.initApplicationContext(applicationContext); |
41 if (builder.libraryLoader() != null) { | 41 if (builder.libraryLoader() != null) { |
42 builder.libraryLoader().loadLibrary(LIBRARY_NAME); | 42 builder.libraryLoader().loadLibrary(LIBRARY_NAME); |
43 } else { | 43 } else { |
44 System.loadLibrary(LIBRARY_NAME); | 44 System.loadLibrary(LIBRARY_NAME); |
45 } | 45 } |
46 ContextUtils.initApplicationContextForNative(); | |
47 String implVersion = ImplVersion.getCronetVersion(); | 46 String implVersion = ImplVersion.getCronetVersion(); |
48 if (!implVersion.equals(nativeGetCronetVersion())) { | 47 if (!implVersion.equals(nativeGetCronetVersion())) { |
49 throw new RuntimeException(String.format("Expected Cronet ve
rsion number %s, " | 48 throw new RuntimeException(String.format("Expected Cronet ve
rsion number %s, " |
50 + "actual version number %s.", | 49 + "actual version number %s.", |
51 implVersion, nativeGetCronetVersion())); | 50 implVersion, nativeGetCronetVersion())); |
52 } | 51 } |
53 Log.i(TAG, "Cronet version: %s, arch: %s", implVersion, | 52 Log.i(TAG, "Cronet version: %s, arch: %s", implVersion, |
54 System.getProperty("os.arch")); | 53 System.getProperty("os.arch")); |
55 sLibraryLoaded = true; | 54 sLibraryLoaded = true; |
56 } | 55 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // the undesired initial network change observer notification, which | 97 // the undesired initial network change observer notification, which |
99 // will cause active requests to fail with ERR_NETWORK_CHANGED. | 98 // will cause active requests to fail with ERR_NETWORK_CHANGED. |
100 nativeCronetInitOnMainThread(); | 99 nativeCronetInitOnMainThread(); |
101 sMainThreadInitDone = true; | 100 sMainThreadInitDone = true; |
102 } | 101 } |
103 | 102 |
104 // Native methods are implemented in cronet_library_loader.cc. | 103 // Native methods are implemented in cronet_library_loader.cc. |
105 private static native void nativeCronetInitOnMainThread(); | 104 private static native void nativeCronetInitOnMainThread(); |
106 private static native String nativeGetCronetVersion(); | 105 private static native String nativeGetCronetVersion(); |
107 } | 106 } |
OLD | NEW |