Chromium Code Reviews| Index: base/android/java/src/org/chromium/base/MemoryPressureHandler.java |
| diff --git a/base/android/java/src/org/chromium/base/MemoryPressureHandler.java b/base/android/java/src/org/chromium/base/MemoryPressureHandler.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e12512c31dc1b2901d931fe82e48d9f852b12c92 |
| --- /dev/null |
| +++ b/base/android/java/src/org/chromium/base/MemoryPressureHandler.java |
| @@ -0,0 +1,29 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.base; |
| + |
| +import android.content.ComponentCallbacks2; |
| + |
| +import org.chromium.base.MemoryPressureList; |
| + |
| + |
|
joth
2013/06/05 16:51:23
remove \n
bulach
2013/06/05 19:02:11
Done.
|
| +public class MemoryPressureHandler { |
|
joth
2013/06/05 16:51:23
private? Comment this is an internal impl. detail
bulach
2013/06/05 19:02:11
Done.
|
| + public static void onMemoryPressure(int memoryPressureType) { |
|
joth
2013/06/05 16:51:23
Ah I see.
So, we can make this self-contained, no
bulach
2013/06/05 19:02:11
a-ha! good idea, I didn't know about this registra
|
| + nativeOnMemoryPressure(translate(memoryPressureType)); |
| + } |
| + |
| + private static int translate(int memoryPressureType) { |
| + if (memoryPressureType == ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW) { |
| + return MemoryPressureList.MEMORY_PRESSURE_LOW; |
| + } else if (memoryPressureType == ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE) { |
| + return MemoryPressureList.MEMORY_PRESSURE_MODERATE; |
| + } else if (memoryPressureType == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) { |
| + return MemoryPressureList.MEMORY_PRESSURE_CRITICAL; |
| + } |
| + return MemoryPressureList.MEMORY_PRESSURE_CRITICAL; |
| + } |
| + |
| + private static native void nativeOnMemoryPressure(int memoryPressureType); |
| +} |