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.content.Context; | 7 import android.content.Context; |
| 8 import android.os.AsyncTask; | 8 import android.os.AsyncTask; |
| 9 import android.os.SystemClock; | 9 import android.os.SystemClock; |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 private LibraryLoader(int libraryProcessType) { | 125 private LibraryLoader(int libraryProcessType) { |
| 126 mLibraryProcessType = libraryProcessType; | 126 mLibraryProcessType = libraryProcessType; |
| 127 mPrefetchLibraryHasBeenCalled = new AtomicBoolean(); | 127 mPrefetchLibraryHasBeenCalled = new AtomicBoolean(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 /** | 130 /** |
| 131 * This method blocks until the library is fully loaded and initialized. | 131 * This method blocks until the library is fully loaded and initialized. |
| 132 * | 132 * |
| 133 * @param context The context in which the method is called. | 133 * @param context The context in which the method is called. |
| 134 */ | 134 */ |
| 135 public void ensureInitialized(Context context) throws ProcessInitException { | 135 public void ensureInitialized(Context context) throws ProcessInitException { |
|
Torne
2016/08/18 14:44:55
Why do we still need to pass the app context in he
Peter Wen
2016/08/18 16:30:01
Done.
We can actually do this at all the places w
| |
| 136 // TODO(wnwen): Move this call appropriately down to the tests that need it. | |
| 137 ContextUtils.initApplicationContext(context.getApplicationContext()); | |
| 138 synchronized (sLock) { | 136 synchronized (sLock) { |
| 139 if (mInitialized) { | 137 if (mInitialized) { |
| 140 // Already initialized, nothing to do. | 138 // Already initialized, nothing to do. |
| 141 return; | 139 return; |
| 142 } | 140 } |
| 143 loadAlreadyLocked(context); | 141 loadAlreadyLocked(context); |
| 144 initializeAlreadyLocked(); | 142 initializeAlreadyLocked(); |
| 145 } | 143 } |
| 146 } | 144 } |
| 147 | 145 |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 | 477 |
| 480 // Finds the ranges corresponding to the native library pages, forks a new | 478 // Finds the ranges corresponding to the native library pages, forks a new |
| 481 // process to prefetch these pages and waits for it. The new process then | 479 // process to prefetch these pages and waits for it. The new process then |
| 482 // terminates. This is blocking. | 480 // terminates. This is blocking. |
| 483 private static native boolean nativeForkAndPrefetchNativeLibrary(); | 481 private static native boolean nativeForkAndPrefetchNativeLibrary(); |
| 484 | 482 |
| 485 // Returns the percentage of the native library code page that are currently reseident in | 483 // Returns the percentage of the native library code page that are currently reseident in |
| 486 // memory. | 484 // memory. |
| 487 private static native int nativePercentageOfResidentNativeLibraryCode(); | 485 private static native int nativePercentageOfResidentNativeLibraryCode(); |
| 488 } | 486 } |
| OLD | NEW |