Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1325)

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/CronetLibraryLoader.java

Issue 1619673004: Add API for custom library loading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: javadoc error Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 14 matching lines...) Expand all
25 /** 25 /**
26 * Ensure that native library is loaded and initialized. Can be called from 26 * Ensure that native library is loaded and initialized. Can be called from
27 * any thread, the load and initialization is performed on main thread. 27 * any thread, the load and initialization is performed on main thread.
28 */ 28 */
29 public static void ensureInitialized( 29 public static void ensureInitialized(
30 final Context context, final CronetEngine.Builder builder) { 30 final Context context, final CronetEngine.Builder builder) {
31 synchronized (sLoadLock) { 31 synchronized (sLoadLock) {
32 if (sInitTaskPosted) { 32 if (sInitTaskPosted) {
33 return; 33 return;
34 } 34 }
35 System.loadLibrary(builder.libraryName()); 35 builder.loadLibrary();
36 if (!Version.CRONET_VERSION.equals(nativeGetCronetVersion())) { 36 if (!Version.CRONET_VERSION.equals(nativeGetCronetVersion())) {
37 throw new RuntimeException(String.format( 37 throw new RuntimeException(String.format(
38 "Expected Cronet version number %s, " 38 "Expected Cronet version number %s, "
39 + "actual version number %s.", 39 + "actual version number %s.",
40 Version.CRONET_VERSION, 40 Version.CRONET_VERSION,
41 nativeGetCronetVersion())); 41 nativeGetCronetVersion()));
42 } 42 }
43 ContextUtils.initApplicationContext(context.getApplicationContext()) ; 43 ContextUtils.initApplicationContext(context.getApplicationContext()) ;
44 // Init native Chromium CronetEngine on Main UI thread. 44 // Init native Chromium CronetEngine on Main UI thread.
45 Runnable task = new Runnable() { 45 Runnable task = new Runnable() {
(...skipping 21 matching lines...) Expand all
67 // observers. Existing observers in the net stack do not 67 // observers. Existing observers in the net stack do not
68 // perform expensive work. 68 // perform expensive work.
69 NetworkChangeNotifier.registerToReceiveNotificationsAlways(); 69 NetworkChangeNotifier.registerToReceiveNotificationsAlways();
70 // registerToReceiveNotificationsAlways() is called before the native 70 // registerToReceiveNotificationsAlways() is called before the native
71 // NetworkChangeNotifierAndroid is created, so as to avoid receiving 71 // NetworkChangeNotifierAndroid is created, so as to avoid receiving
72 // the undesired initial network change observer notification, which 72 // the undesired initial network change observer notification, which
73 // will cause active requests to fail with ERR_NETWORK_CHANGED. 73 // will cause active requests to fail with ERR_NETWORK_CHANGED.
74 nativeCronetInitOnMainThread(); 74 nativeCronetInitOnMainThread();
75 } 75 }
76 76
77 // Native methods are implemented in cronet_loader.cc. 77 // Native methods are implemented in cronet_library_loader.cc.
78 private static native void nativeCronetInitOnMainThread(); 78 private static native void nativeCronetInitOnMainThread();
79 private static native String nativeGetCronetVersion(); 79 private static native String nativeGetCronetVersion();
80 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698