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 6665ddfde738544d38fa382a7d0a9da91ede98d0..785827178d91ce0b27a2b36cb6fb4515ba1d66ca 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 |
@@ -13,6 +13,7 @@ import android.os.Build; |
import android.os.SystemClock; |
import org.chromium.base.CommandLine; |
+import org.chromium.base.ContextUtils; |
import org.chromium.base.Log; |
import org.chromium.base.PackageUtils; |
import org.chromium.base.TraceEvent; |
@@ -132,6 +133,8 @@ public class LibraryLoader { |
* @param context The context in which the method is called. |
*/ |
public void ensureInitialized(Context context) throws ProcessInitException { |
+ // TODO(wnwen): Move this call appropriately down to the tests that need it. |
+ ContextUtils.initApplicationContext(context.getApplicationContext()); |
synchronized (sLock) { |
if (mInitialized) { |
// Already initialized, nothing to do. |
@@ -360,6 +363,10 @@ public class LibraryLoader { |
nativeInitCommandLine(CommandLine.getJavaSwitchesOrNull()); |
CommandLine.enableNativeProxy(); |
mCommandLineSwitched = true; |
+ |
+ // Ensure that native side application context is loaded and in sync with java side. Must do |
+ // this here so webview also gets its application context set before fully initializing. |
+ ContextUtils.initApplicationContextForNative(); |
Yaron
2016/04/25 14:09:45
There's still two callers on the native side to In
Peter Wen
2016/04/25 15:30:30
Done.
|
} |
// Invoke base::android::LibraryLoaded in library_loader_hooks.cc |
@@ -368,23 +375,13 @@ public class LibraryLoader { |
return; |
} |
- // Setup the native command line if necessary. |
- if (!mCommandLineSwitched) { |
- nativeInitCommandLine(CommandLine.getJavaSwitchesOrNull()); |
- } |
+ ensureCommandLineSwitchedAlreadyLocked(); |
if (!nativeLibraryLoaded()) { |
Log.e(TAG, "error calling nativeLibraryLoaded"); |
throw new ProcessInitException(LoaderErrors.LOADER_ERROR_FAILED_TO_REGISTER_JNI); |
} |
- // 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 (!mCommandLineSwitched) { |
- CommandLine.enableNativeProxy(); |
- mCommandLineSwitched = true; |
- } |
- |
// From now on, keep tracing in sync with native. |
TraceEvent.registerNativeEnabledObserver(); |