OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.app.ActivityManager; | 7 import android.app.ActivityManager; |
8 import android.content.ComponentCallbacks2; | 8 import android.content.ComponentCallbacks2; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.res.Configuration; | 10 import android.content.res.Configuration; |
11 | 11 |
12 import org.chromium.base.Log; | 12 import org.chromium.base.Log; |
13 import org.chromium.base.annotations.CalledByNative; | 13 import org.chromium.base.annotations.CalledByNative; |
14 import org.chromium.base.annotations.JNINamespace; | 14 import org.chromium.base.annotations.JNINamespace; |
15 | 15 |
16 /** | 16 /** |
17 * Android implementation of MemoryMonitor. | 17 * Android implementation of MemoryMonitor. |
18 */ | 18 */ |
19 @JNINamespace("content") | 19 @JNINamespace("content") |
20 class MemoryMonitorAndroid { | 20 class MemoryMonitorAndroid { |
21 private static final String TAG = "MemoryMonitorAndroid"; | 21 private static final String TAG = "MemoryMonitorAndroid"; |
22 private static final ActivityManager.MemoryInfo sMemoryInfo = | 22 private static final ActivityManager.MemoryInfo sMemoryInfo = |
23 new ActivityManager.MemoryInfo(); | 23 new ActivityManager.MemoryInfo(); |
24 private static ComponentCallbacks2 sCallbacks = null; | 24 private static ComponentCallbacks2 sCallbacks; |
25 | 25 |
26 private MemoryMonitorAndroid() { | 26 private MemoryMonitorAndroid() { |
27 } | 27 } |
28 | 28 |
29 /** | 29 /** |
30 * Get the current MemoryInfo from ActivityManager and invoke the native | 30 * Get the current MemoryInfo from ActivityManager and invoke the native |
31 * callback to populate the MemoryInfo. | 31 * callback to populate the MemoryInfo. |
32 * | 32 * |
33 * @param context The context of the application. | 33 * @param context The context of the application. |
34 * @param outPtr A native output pointer to populate MemoryInfo. This is | 34 * @param outPtr A native output pointer to populate MemoryInfo. This is |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 }; | 80 }; |
81 context.registerComponentCallbacks(sCallbacks); | 81 context.registerComponentCallbacks(sCallbacks); |
82 } | 82 } |
83 | 83 |
84 private static native void nativeGetMemoryInfoCallback( | 84 private static native void nativeGetMemoryInfoCallback( |
85 long availMem, boolean lowMemory, | 85 long availMem, boolean lowMemory, |
86 long threshold, long totalMem, long outPtr); | 86 long threshold, long totalMem, long outPtr); |
87 | 87 |
88 private static native void nativeOnTrimMemory(int level); | 88 private static native void nativeOnTrimMemory(int level); |
89 } | 89 } |
OLD | NEW |