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

Side by Side Diff: base/android/java/src/org/chromium/base/MemoryPressureListener.java

Issue 22911017: [Android] Make TRIM_MEMORY_COMPLETE check >= rather than == (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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; 5 package org.chromium.base;
6 6
7 import android.content.ComponentCallbacks2; 7 import android.content.ComponentCallbacks2;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.res.Configuration; 9 import android.content.res.Configuration;
10 10
11 11
12 /** 12 /**
13 * This is an internal implementation of the C++ counterpart. 13 * This is an internal implementation of the C++ counterpart.
14 * It registers a ComponentCallbacks2 with the system, and dispatches into 14 * It registers a ComponentCallbacks2 with the system, and dispatches into
15 * native. 15 * native for levels that are considered actionable.
16 */ 16 */
17 public class MemoryPressureListener { 17 public class MemoryPressureListener {
18 @CalledByNative 18 @CalledByNative
19 private static void registerSystemCallback(Context context) { 19 private static void registerSystemCallback(Context context) {
20 context.registerComponentCallbacks( 20 context.registerComponentCallbacks(
21 new ComponentCallbacks2() { 21 new ComponentCallbacks2() {
22 @Override 22 @Override
23 public void onTrimMemory(int level) { 23 public void onTrimMemory(int level) {
24 maybeNotifyMemoryPresure(level); 24 maybeNotifyMemoryPresure(level);
25 } 25 }
(...skipping 10 matching lines...) Expand all
36 } 36 }
37 37
38 /** 38 /**
39 * Used by applications to simulate a memory pressure signal. 39 * Used by applications to simulate a memory pressure signal.
40 */ 40 */
41 public static void simulateMemoryPressureSignal(int level) { 41 public static void simulateMemoryPressureSignal(int level) {
42 maybeNotifyMemoryPresure(level); 42 maybeNotifyMemoryPresure(level);
43 } 43 }
44 44
45 private static void maybeNotifyMemoryPresure(int level) { 45 private static void maybeNotifyMemoryPresure(int level) {
46 if (level == ComponentCallbacks2.TRIM_MEMORY_COMPLETE) { 46 if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
47 nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_CRITICA L); 47 nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_CRITICA L);
48 } else if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND || 48 } else if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND ||
49 level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) { 49 level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
50 // Don't notifiy on TRIM_MEMORY_UI_HIDDEN, since this class only
51 // dispatches actionable memory pressure signals to native.
50 nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_MODERAT E); 52 nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_MODERAT E);
51 } 53 }
52 } 54 }
53 55
54 private static native void nativeOnMemoryPressure(int memoryPressureType); 56 private static native void nativeOnMemoryPressure(int memoryPressureType);
55 } 57 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698