Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3048)

Unified Diff: base/android/java/src/org/chromium/base/MemoryPressureHandler.java

Issue 15995014: Adds MemoryPressureListener. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Hooks up with MemoryPurger Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+}

Powered by Google App Engine
This is Rietveld 408576698