| Index: content/public/android/java/src/org/chromium/content/browser/MemoryMonitorAndroid.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/MemoryMonitorAndroid.java b/content/public/android/java/src/org/chromium/content/browser/MemoryMonitorAndroid.java
|
| index 9053da8927fd739279c81716afc09ea1aa60a9f9..0fa1e03b42803ca14cda4b2365b932d51a39de0c 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/MemoryMonitorAndroid.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/MemoryMonitorAndroid.java
|
| @@ -15,12 +15,28 @@ import org.chromium.base.annotations.JNINamespace;
|
| */
|
| @JNINamespace("content")
|
| class MemoryMonitorAndroid {
|
| + private static final ActivityManager.MemoryInfo sMemoryInfo =
|
| + new ActivityManager.MemoryInfo();
|
| +
|
| + /**
|
| + * Get the current MemoryInfo from ActivityManager and invoke the native
|
| + * callback to populate the MemoryInfo.
|
| + *
|
| + * @param context The context of the application.
|
| + * @param outPtr A native output pointer to populate MemoryInfo. This is
|
| + * passed back to the native callback.
|
| + */
|
| @CalledByNative
|
| - private static ActivityManager.MemoryInfo getMemoryInfo(Context context) {
|
| + private static void getMemoryInfo(Context context, long outPtr) {
|
| ActivityManager am = (ActivityManager) context.getSystemService(
|
| Context.ACTIVITY_SERVICE);
|
| - ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo();
|
| - am.getMemoryInfo(info);
|
| - return info;
|
| + am.getMemoryInfo(sMemoryInfo);
|
| + nativeGetMemoryInfoCallback(
|
| + sMemoryInfo.availMem, sMemoryInfo.lowMemory,
|
| + sMemoryInfo.threshold, sMemoryInfo.totalMem, outPtr);
|
| }
|
| +
|
| + private static native void nativeGetMemoryInfoCallback(
|
| + long availMem, boolean lowMemory,
|
| + long threshold, long totalMem, long outPtr);
|
| }
|
|
|