| Index: base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
|
| diff --git a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
|
| index 106b207bf3411b65ec03d4f954663e3bed89cc22..91e53678707f17b3b96a8b8bacaebe6ab07818de 100644
|
| --- a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
|
| +++ b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
|
| @@ -37,6 +37,10 @@ public class LibraryLoader {
|
| // One-way switch becomes true when the libraries are loaded.
|
| private static boolean sLoaded = false;
|
|
|
| + // One-way switch becomes true when the Java command line is switched to
|
| + // native.
|
| + private static boolean sCommandLineSwitched = false;
|
| +
|
| // One-way switch becomes true when the libraries are initialized (
|
| // by calling nativeLibraryLoaded, which forwards to LibraryLoaded(...) in
|
| // library_loader_hooks.cc).
|
| @@ -216,9 +220,6 @@ public class LibraryLoader {
|
| startTime % 10000,
|
| stopTime % 10000));
|
|
|
| - nativeInitCommandLine(CommandLine.getJavaSwitchesOrNull());
|
| - CommandLine.enableNativeProxy();
|
| -
|
| sLoaded = true;
|
| }
|
| } catch (UnsatisfiedLinkError e) {
|
| @@ -235,12 +236,39 @@ public class LibraryLoader {
|
| }
|
| }
|
|
|
| + // The WebView requires the Command Line to be switched over before
|
| + // initialization is done. This is okay in the WebView's case since the
|
| + // JNI is already loaded by this point.
|
| + public static void switchCommandLineForWebView() {
|
| + synchronized (sLock) {
|
| + ensureCommandLineSwitchedAlreadyLocked();
|
| + }
|
| + }
|
| +
|
| + // Switch the CommandLine over from Java to native if it hasn't already been done.
|
| + // This must happen after the code is loaded and after JNI is ready (since after the
|
| + // switch the Java CommandLine will delegate all calls the native CommandLine).
|
| + private static void ensureCommandLineSwitchedAlreadyLocked() {
|
| + assert sLoaded;
|
| + if (sCommandLineSwitched) {
|
| + return;
|
| + }
|
| + nativeInitCommandLine(CommandLine.getJavaSwitchesOrNull());
|
| + CommandLine.enableNativeProxy();
|
| + sCommandLineSwitched = true;
|
| + }
|
| +
|
| // Invoke base::android::LibraryLoaded in library_loader_hooks.cc
|
| private static void initializeAlreadyLocked() throws ProcessInitException {
|
| if (sInitialized) {
|
| return;
|
| }
|
|
|
| + // Setup the native command line if necessary.
|
| + if (!sCommandLineSwitched) {
|
| + nativeInitCommandLine(CommandLine.getJavaSwitchesOrNull());
|
| + }
|
| +
|
| if (!nativeLibraryLoaded()) {
|
| Log.e(TAG, "error calling nativeLibraryLoaded");
|
| throw new ProcessInitException(LoaderErrors.LOADER_ERROR_FAILED_TO_REGISTER_JNI);
|
| @@ -250,6 +278,13 @@ public class LibraryLoader {
|
| // following calls).
|
| sInitialized = true;
|
|
|
| + // The Chrome JNI is registered by now so we can switch the Java
|
| + // command line over to delegating to native if it's necessary.
|
| + if (!sCommandLineSwitched) {
|
| + CommandLine.enableNativeProxy();
|
| + sCommandLineSwitched = true;
|
| + }
|
| +
|
| // From now on, keep tracing in sync with native.
|
| TraceEvent.registerNativeEnabledObserver();
|
| }
|
|
|