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 c3b3b35fc5ec0b8b6e4e9b5f868d88a5ddd8901b..22513810ec9cf90dd3f45453f3b604dc7c355779 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 |
@@ -47,14 +47,20 @@ public class LibraryLoader { |
// The flag is used to report UMA stats later. |
private static boolean sNativeLibraryHackWasUsed = false; |
+ // TODO(fqian): Remove this method once downstream CL is |
+ // committed. |
+ public static void ensureInitialized(Context context) throws ProcessInitException { |
+ ensureInitialized(context, true); |
+ } |
/** |
- * TODO: http://crbug.com/354655 |
- * remove this method once WebViewChromiumFactoryProvider.java |
- * changes the call to ensureInitialized(null). |
+ * The same as ensureInitialized(null, false), should only be called |
+ * by non-browser processes. |
+ * |
+ * @throws ProcessInitException |
*/ |
public static void ensureInitialized() throws ProcessInitException { |
- ensureInitialized(null); |
+ ensureInitialized(null, false); |
} |
/** |
@@ -70,14 +76,18 @@ public class LibraryLoader { |
* will extract the native libraries from APK. This is a hack used to |
* work around some Sony devices with the following platform bug: |
* http://b/13216167. |
+ * |
+ * @param inBrowserProcess The caller indicates it is running in the browser |
+ * process, so the code will perform browser-specific file cleanup. |
*/ |
- public static void ensureInitialized(Context context) throws ProcessInitException { |
+ public static void ensureInitialized(Context context, boolean inBrowserProcess) |
+ throws ProcessInitException { |
synchronized (sLock) { |
if (sInitialized) { |
// Already initialized, nothing to do. |
return; |
} |
- loadAlreadyLocked(context); |
+ loadAlreadyLocked(context, inBrowserProcess); |
initializeAlreadyLocked(CommandLine.getJavaSwitchesOrNull()); |
} |
} |
@@ -92,17 +102,32 @@ public class LibraryLoader { |
} |
/** |
+ * The same as loadNow(null, false), should only be called by |
+ * non-browser process. |
+ * |
+ * @throws ProcessInitException |
+ */ |
+ public static void loadNow() throws ProcessInitException { |
+ loadNow(null, false); |
+ } |
+ |
+ /** |
* Loads the library and blocks until the load completes. The caller is responsible |
* for subsequently calling ensureInitialized(). |
* May be called on any thread, but should only be called once. Note the thread |
* this is called on will be the thread that runs the native code's static initializers. |
* See the comment in doInBackground() for more considerations on this. |
* |
+ * @param context The context the code is running, or null if it doesn't have one. |
+ * @param inBrowserProcess The flag tells whether the code is running in |
+ * the browser process. |
cjhopman
2014/04/02 22:24:24
It's unclear (from this documentation) what this f
Feng Qian
2014/04/03 00:50:42
ok, I am fine with renaming.
On 2014/04/02 22:24:
|
+ * |
* @throws ProcessInitException if the native library failed to load. |
*/ |
- public static void loadNow(Context context) throws ProcessInitException { |
+ public static void loadNow(Context context, boolean inBrowserProcess) |
+ throws ProcessInitException { |
synchronized (sLock) { |
- loadAlreadyLocked(context); |
+ loadAlreadyLocked(context, inBrowserProcess); |
} |
} |
@@ -120,7 +145,8 @@ public class LibraryLoader { |
} |
// Invoke System.loadLibrary(...), triggering JNI_OnLoad in native code |
- private static void loadAlreadyLocked(Context context) throws ProcessInitException { |
+ private static void loadAlreadyLocked(Context context, boolean inBrowserProcess) |
+ throws ProcessInitException { |
try { |
if (!sLoaded) { |
assert !sInitialized; |
@@ -130,6 +156,7 @@ public class LibraryLoader { |
if (useChromiumLinker) Linker.prepareLibraryLoad(); |
+ boolean workaroundLibrariesDeleted = false; |
for (String library : NativeLibraries.LIBRARIES) { |
Log.i(TAG, "Loading: " + library); |
if (useChromiumLinker) { |
@@ -137,9 +164,12 @@ public class LibraryLoader { |
} else { |
try { |
System.loadLibrary(library); |
- if (context != null) { |
+ if (context != null |
+ && inBrowserProcess |
boliu
2014/04/03 01:03:22
Webview technically only has the browser process,
|
+ && !workaroundLibrariesDeleted) { |
LibraryLoaderHelper.deleteWorkaroundLibrariesAsynchronously( |
context); |
+ workaroundLibrariesDeleted = true; |
cjhopman
2014/04/02 22:24:24
Since we only want this to happen once, how about
Feng Qian
2014/04/03 00:50:42
The code is not just run when sNativeLibraryHackWa
|
} |
} catch (UnsatisfiedLinkError e) { |
if (context != null |