Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.os.Bundle; | 7 import android.os.Bundle; |
| 8 import android.os.Parcel; | 8 import android.os.Parcel; |
| 9 import android.os.ParcelFileDescriptor; | 9 import android.os.ParcelFileDescriptor; |
| 10 import android.os.Parcelable; | 10 import android.os.Parcelable; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 // for testing by calling setMemoryDeviceConfig(). | 189 // for testing by calling setMemoryDeviceConfig(). |
| 190 private static int sMemoryDeviceConfig = MEMORY_DEVICE_CONFIG_INIT; | 190 private static int sMemoryDeviceConfig = MEMORY_DEVICE_CONFIG_INIT; |
| 191 | 191 |
| 192 // Becomes true after linker initialization. | 192 // Becomes true after linker initialization. |
| 193 private static boolean sInitialized = false; | 193 private static boolean sInitialized = false; |
| 194 | 194 |
| 195 // Set to true to indicate that the system supports safe sharing of RELRO se ctions. | 195 // Set to true to indicate that the system supports safe sharing of RELRO se ctions. |
| 196 private static boolean sRelroSharingSupported = false; | 196 private static boolean sRelroSharingSupported = false; |
| 197 | 197 |
| 198 // Set to true if this runs in the browser process. Disabled by initServiceP rocess(). | 198 // Set to true if this runs in the browser process. Disabled by initServiceP rocess(). |
| 199 // TODO(petrcermak): This flag can be incorrectly set to false (even though this might run in | |
| 200 // the browser process) on low-memory devices. | |
| 199 private static boolean sInBrowserProcess = true; | 201 private static boolean sInBrowserProcess = true; |
| 200 | 202 |
| 201 // Becomes true to indicate this process needs to wait for a shared RELRO in | 203 // Becomes true to indicate this process needs to wait for a shared RELRO in |
| 202 // finishLibraryLoad(). | 204 // finishLibraryLoad(). |
| 203 private static boolean sWaitForSharedRelros = false; | 205 private static boolean sWaitForSharedRelros = false; |
| 204 | 206 |
| 205 // Becomes true when initialization determines that the browser process can use the | 207 // Becomes true when initialization determines that the browser process can use the |
| 206 // shared RELRO. | 208 // shared RELRO. |
| 207 private static boolean sBrowserUsesSharedRelro = false; | 209 private static boolean sBrowserUsesSharedRelro = false; |
| 208 | 210 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 * for the browser process. | 377 * for the browser process. |
| 376 */ | 378 */ |
| 377 public static boolean isUsingBrowserSharedRelros() { | 379 public static boolean isUsingBrowserSharedRelros() { |
| 378 synchronized (Linker.class) { | 380 synchronized (Linker.class) { |
| 379 ensureInitializedLocked(); | 381 ensureInitializedLocked(); |
| 380 return sBrowserUsesSharedRelro; | 382 return sBrowserUsesSharedRelro; |
| 381 } | 383 } |
| 382 } | 384 } |
| 383 | 385 |
| 384 /** | 386 /** |
| 385 * Call this method to determine if the linker is running in the browser | |
| 386 * process. | |
| 387 * | |
| 388 * @return true if the linker is running in the browser process. | |
| 389 */ | |
| 390 public static boolean isInBrowserProcess() { | |
| 391 synchronized (Linker.class) { | |
| 392 ensureInitializedLocked(); | |
| 393 return sInBrowserProcess; | |
| 394 } | |
| 395 } | |
| 396 | |
| 397 /** | |
| 398 * Call this method to determine if the chromium project must load | 387 * Call this method to determine if the chromium project must load |
| 399 * the library directly from the zip file. | 388 * the library directly from the zip file. |
| 400 */ | 389 */ |
| 401 public static boolean isInZipFile() { | 390 public static boolean isInZipFile() { |
| 402 return NativeLibraries.sUseLibraryInZipFile; | 391 return NativeLibraries.sUseLibraryInZipFile; |
| 403 } | 392 } |
| 404 | 393 |
| 405 /** | 394 /** |
| 406 * Call this method just before loading any native shared libraries in this process. | 395 * Call this method just before loading any native shared libraries in this process. |
| 407 */ | 396 */ |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 828 } | 817 } |
| 829 | 818 |
| 830 sLoadedLibraries.put(libName, libInfo); | 819 sLoadedLibraries.put(libName, libInfo); |
| 831 if (DEBUG) Log.i(TAG, "Library details " + libInfo.toString()); | 820 if (DEBUG) Log.i(TAG, "Library details " + libInfo.toString()); |
| 832 } | 821 } |
| 833 } | 822 } |
| 834 | 823 |
| 835 /** | 824 /** |
| 836 * Check whether the device supports loading a library directly from the APK file. | 825 * Check whether the device supports loading a library directly from the APK file. |
| 837 * | 826 * |
| 838 * @param apkFile Filename of the APK. | 827 * @param apkFile Filename of the APK (not null). |
|
rmcilroy
2014/10/20 10:42:39
this is usually implied (with params which can be
petrcermak
2014/10/20 15:33:22
Removed.
| |
| 839 * @return true if supported. | 828 * @return true if supported. |
| 840 */ | 829 */ |
| 841 public static boolean checkLibraryLoadFromApkSupport(String apkFile) { | 830 public static boolean checkLibraryLoadFromApkSupport(String apkFile) { |
| 831 assert apkFile != null; | |
| 842 synchronized (Linker.class) { | 832 synchronized (Linker.class) { |
| 843 ensureInitializedLocked(); | 833 ensureInitializedLocked(); |
| 844 | 834 |
| 845 if (DEBUG) Log.i(TAG, "checkLibraryLoadFromApkSupported: " + apkFile ); | 835 if (DEBUG) Log.i(TAG, "checkLibraryLoadFromApkSupported: " + apkFile ); |
| 846 boolean supported = nativeCheckLibraryLoadFromApkSupport(apkFile); | 836 boolean supported = nativeCheckLibraryLoadFromApkSupport(apkFile); |
| 847 if (DEBUG) Log.i(TAG, "Loading a library directly from the APK file " + | 837 if (DEBUG) Log.i(TAG, "Loading a library directly from the APK file " + |
| 848 (supported ? "" : "NOT ") + "supported"); | 838 (supported ? "" : "NOT ") + "supported"); |
| 849 return supported; | 839 return supported; |
| 850 } | 840 } |
| 851 } | 841 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1085 } | 1075 } |
| 1086 } | 1076 } |
| 1087 | 1077 |
| 1088 // The map of libraries that are currently loaded in this process. | 1078 // The map of libraries that are currently loaded in this process. |
| 1089 private static HashMap<String, LibInfo> sLoadedLibraries = null; | 1079 private static HashMap<String, LibInfo> sLoadedLibraries = null; |
| 1090 | 1080 |
| 1091 // Used to pass the shared RELRO Bundle through Binder. | 1081 // Used to pass the shared RELRO Bundle through Binder. |
| 1092 public static final String EXTRA_LINKER_SHARED_RELROS = | 1082 public static final String EXTRA_LINKER_SHARED_RELROS = |
| 1093 "org.chromium.base.android.linker.shared_relros"; | 1083 "org.chromium.base.android.linker.shared_relros"; |
| 1094 } | 1084 } |
| OLD | NEW |