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

Side by Side Diff: android/java/src/org/chromium/base/library_loader/LibraryLoader.java

Issue 2050803003: Update to Chromium //base at Chromium commit e3a753f17bac62738b0dbf0b36510f767b081e4b. (Closed) Base URL: https://github.com/domokit/base.git@master
Patch Set: Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.base.library_loader; 5 package org.chromium.base.library_loader;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.pm.ApplicationInfo; 9 import android.content.pm.ApplicationInfo;
10 import android.content.pm.PackageInfo; 10 import android.content.pm.PackageInfo;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 213
214 // Invoke either Linker.loadLibrary(...) or System.loadLibrary(...), trigger ing 214 // Invoke either Linker.loadLibrary(...) or System.loadLibrary(...), trigger ing
215 // JNI_OnLoad in native code 215 // JNI_OnLoad in native code
216 private void loadAlreadyLocked(Context context) throws ProcessInitException { 216 private void loadAlreadyLocked(Context context) throws ProcessInitException {
217 try { 217 try {
218 if (!mLoaded) { 218 if (!mLoaded) {
219 assert !mInitialized; 219 assert !mInitialized;
220 220
221 long startTime = SystemClock.uptimeMillis(); 221 long startTime = SystemClock.uptimeMillis();
222 Linker linker = Linker.getInstance();
223 boolean useChromiumLinker = linker.isUsed();
224 222
225 if (useChromiumLinker) { 223 if (Linker.isUsed()) {
226 // Determine the APK file path.
227 String apkFilePath = getLibraryApkPath(context);
228 // Load libraries using the Chromium linker. 224 // Load libraries using the Chromium linker.
225 Linker linker = Linker.getInstance();
229 linker.prepareLibraryLoad(); 226 linker.prepareLibraryLoad();
230 227
231 for (String library : NativeLibraries.LIBRARIES) { 228 for (String library : NativeLibraries.LIBRARIES) {
232 // Don't self-load the linker. This is because the build system is 229 // Don't self-load the linker. This is because the build system is
233 // not clever enough to understand that all the librarie s packaged 230 // not clever enough to understand that all the librarie s packaged
234 // in the final .apk don't need to be explicitly loaded. 231 // in the final .apk don't need to be explicitly loaded.
235 if (linker.isChromiumLinkerLibrary(library)) { 232 if (linker.isChromiumLinkerLibrary(library)) {
236 if (DEBUG) Log.i(TAG, "ignoring self-linker load"); 233 if (DEBUG) Log.i(TAG, "ignoring self-linker load");
237 continue; 234 continue;
238 } 235 }
239 236
240 // Determine where the library should be loaded from. 237 // Determine where the library should be loaded from.
241 String zipFilePath = null; 238 String zipFilePath = null;
242 String libFilePath = System.mapLibraryName(library); 239 String libFilePath = System.mapLibraryName(library);
243 if (linker.isInZipFile()) { 240 if (linker.isInZipFile()) {
244 // Load directly from the APK. 241 // Load directly from the APK.
245 zipFilePath = apkFilePath; 242 zipFilePath = getLibraryApkPath(context);
246 Log.i(TAG, "Loading " + library + " from within " + apkFilePath); 243 Log.i(TAG, "Loading " + library + " from within " + zipFilePath);
247 } else { 244 } else {
248 // The library is in its own file. 245 // The library is in its own file.
249 Log.i(TAG, "Loading " + library); 246 Log.i(TAG, "Loading " + library);
250 } 247 }
251 248
252 // Load the library using this Linker. May throw Unsatis fiedLinkError. 249 // Load the library using this Linker. May throw Unsatis fiedLinkError.
253 loadLibrary(linker, zipFilePath, libFilePath); 250 loadLibrary(linker, zipFilePath, libFilePath);
254 } 251 }
255 252
256 linker.finishLibraryLoad(); 253 linker.finishLibraryLoad();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 436
440 // Get the version of the native library. This is needed so that we can chec k we 437 // Get the version of the native library. This is needed so that we can chec k we
441 // have the right version before initializing the (rest of the) JNI. 438 // have the right version before initializing the (rest of the) JNI.
442 private native String nativeGetVersionNumber(); 439 private native String nativeGetVersionNumber();
443 440
444 // Finds the ranges corresponding to the native library pages, forks a new 441 // Finds the ranges corresponding to the native library pages, forks a new
445 // process to prefetch these pages and waits for it. The new process then 442 // process to prefetch these pages and waits for it. The new process then
446 // terminates. This is blocking. 443 // terminates. This is blocking.
447 private static native boolean nativeForkAndPrefetchNativeLibrary(); 444 private static native boolean nativeForkAndPrefetchNativeLibrary();
448 } 445 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698