Index: base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java |
diff --git a/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java |
similarity index 81% |
copy from content/public/android/java/src/org/chromium/content/app/LibraryLoader.java |
copy to base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java |
index 635a15335abe510b91e923fb682ffcc2b3ced06c..590edd85ca75dfeb6a2ded7c7ab4f3768b4e4383 100644 |
--- a/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java |
+++ b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-package org.chromium.content.app; |
+package org.chromium.base.library_loader; |
import android.util.Log; |
@@ -10,8 +10,6 @@ import org.chromium.base.CommandLine; |
import org.chromium.base.JNINamespace; |
import org.chromium.base.SysUtils; |
import org.chromium.base.TraceEvent; |
-import org.chromium.content.common.ProcessInitException; |
-import org.chromium.content.common.ResultCodes; |
/** |
* This class provides functionality to load and register the native libraries. |
@@ -24,10 +22,10 @@ import org.chromium.content.common.ResultCodes; |
* primitives are used to ensure that overlapping requests from different |
* threads are handled sequentially. |
* |
- * See also content/app/android/library_loader_hooks.cc, which contains |
+ * See also base/android/library_loader/library_loader_hooks.cc, which contains |
* the native counterpart to this class. |
*/ |
-@JNINamespace("content") |
+@JNINamespace("base::android") |
public class LibraryLoader { |
private static final String TAG = "LibraryLoader"; |
@@ -96,7 +94,7 @@ public class LibraryLoader { |
* @param initCommandLine The command line arguments that native command line will |
* be initialized with. |
*/ |
- static void initialize(String[] initCommandLine) throws ProcessInitException { |
+ public static void initialize(String[] initCommandLine) throws ProcessInitException { |
synchronized (sLock) { |
initializeAlreadyLocked(initCommandLine); |
} |
@@ -110,19 +108,19 @@ public class LibraryLoader { |
assert !sInitialized; |
long startTime = System.currentTimeMillis(); |
- boolean useContentLinker = Linker.isUsed(); |
+ boolean useChromiumLinker = Linker.isUsed(); |
- if (useContentLinker) |
+ if (useChromiumLinker) |
Linker.prepareLibraryLoad(); |
for (String library : NativeLibraries.LIBRARIES) { |
Log.i(TAG, "Loading: " + library); |
- if (useContentLinker) |
+ if (useChromiumLinker) |
Linker.loadLibrary(library); |
else |
System.loadLibrary(library); |
} |
- if (useContentLinker) |
+ if (useChromiumLinker) |
Linker.finishLibraryLoad(); |
long stopTime = System.currentTimeMillis(); |
Log.i(TAG, String.format("Time to load native libraries: %d ms (timestamps %d-%d)", |
@@ -132,7 +130,7 @@ public class LibraryLoader { |
sLoaded = true; |
} |
} catch (UnsatisfiedLinkError e) { |
- throw new ProcessInitException(ResultCodes.RESULT_CODE_NATIVE_LIBRARY_LOAD_FAILED, e); |
+ throw new ProcessInitException(LoaderErrors.LOADER_ERROR_NATIVE_LIBRARY_LOAD_FAILED, e); |
} |
// Check that the version of the library we have loaded matches the version we expect |
Log.i(TAG, String.format( |
@@ -141,22 +139,21 @@ public class LibraryLoader { |
NativeLibraries.VERSION_NUMBER, |
nativeGetVersionNumber())); |
if (!NativeLibraries.VERSION_NUMBER.equals(nativeGetVersionNumber())) { |
- throw new ProcessInitException(ResultCodes.RESULT_CODE_NATIVE_LIBRARY_WRONG_VERSION); |
+ throw new ProcessInitException(LoaderErrors.LOADER_ERROR_NATIVE_LIBRARY_WRONG_VERSION); |
} |
} |
- // Invoke content::LibraryLoaded in library_loader_hooks.cc |
+ // Invoke base::android::LibraryLoaded in library_loader_hooks.cc |
private static void initializeAlreadyLocked(String[] initCommandLine) |
throws ProcessInitException { |
if (sInitialized) { |
return; |
} |
- int resultCode = nativeLibraryLoaded(initCommandLine); |
- if (resultCode != 0) { |
+ if (!nativeLibraryLoaded(initCommandLine)) { |
Log.e(TAG, "error calling nativeLibraryLoaded"); |
- throw new ProcessInitException(resultCode); |
+ throw new ProcessInitException(LoaderErrors.LOADER_ERROR_FAILED_TO_REGISTER_JNI); |
} |
// From this point on, native code is ready to use and checkIsReady() |
// shouldn't complain from now on (and in fact, it's used by the |
@@ -164,25 +161,24 @@ public class LibraryLoader { |
sInitialized = true; |
CommandLine.enableNativeProxy(); |
TraceEvent.setEnabledToMatchNative(); |
- // Record histogram for the content linker. |
+ // Record histogram for the Chromium linker. |
if (Linker.isUsed()) |
- nativeRecordContentAndroidLinkerHistogram(Linker.loadAtFixedAddressFailed(), |
+ nativeRecordChromiumAndroidLinkerHistogram(Linker.loadAtFixedAddressFailed(), |
SysUtils.isLowEndDevice()); |
} |
// Only methods needed before or during normal JNI registration are during System.OnLoad. |
// nativeLibraryLoaded is then called to register everything else. This process is called |
// "initialization". This method will be mapped (by generated code) to the LibraryLoaded |
- // definition in content/app/android/library_loader_hooks.cc. |
+ // definition in base/android/library_loader/library_loader_hooks.cc. |
// |
- // Return 0 on success, otherwise return the error code from |
- // content/public/common/result_codes.h. |
- private static native int nativeLibraryLoaded(String[] initCommandLine); |
+ // Return true on success and false on failure. |
+ private static native boolean nativeLibraryLoaded(String[] initCommandLine); |
- // Method called to record statistics about the content linker operation, |
+ // Method called to record statistics about the Chromium linker operation, |
// i.e. whether the library failed to be loaded at a fixed address, and |
// whether the device is 'low-memory'. |
- private static native void nativeRecordContentAndroidLinkerHistogram( |
+ private static native void nativeRecordChromiumAndroidLinkerHistogram( |
boolean loadedAtFixedAddressFailed, |
boolean isLowMemoryDevice); |