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

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

Issue 258663002: Expose a low-end device mode override flags for non-android OSs as well (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
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.os.Build; 7 import android.os.Build;
8 import android.util.Log; 8 import android.util.Log;
9 9
10 import java.io.BufferedReader; 10 import java.io.BufferedReader;
(...skipping 19 matching lines...) Expand all
30 private SysUtils() { } 30 private SysUtils() { }
31 31
32 /** 32 /**
33 * Return the amount of physical memory on this device in kilobytes. 33 * Return the amount of physical memory on this device in kilobytes.
34 * Note: the only reason this is public is for testability reason. 34 * Note: the only reason this is public is for testability reason.
35 * @return Amount of physical memory in kilobytes, or 0 if there was 35 * @return Amount of physical memory in kilobytes, or 0 if there was
36 * an error trying to access the information. 36 * an error trying to access the information.
37 * 37 *
38 * Note that this is CalledByNative for testing purpose only. 38 * Note that this is CalledByNative for testing purpose only.
39 */ 39 */
40 @CalledByNative
41 public static int amountOfPhysicalMemoryKB() { 40 public static int amountOfPhysicalMemoryKB() {
42 // Extract total memory RAM size by parsing /proc/meminfo, note that 41 // Extract total memory RAM size by parsing /proc/meminfo, note that
43 // this is exactly what the implementation of sysconf(_SC_PHYS_PAGES) 42 // this is exactly what the implementation of sysconf(_SC_PHYS_PAGES)
44 // does. However, it can't be called because this method must be 43 // does. However, it can't be called because this method must be
45 // usable before any native code is loaded. 44 // usable before any native code is loaded.
46 45
47 // An alternative is to use ActivityManager.getMemoryInfo(), but this 46 // An alternative is to use ActivityManager.getMemoryInfo(), but this
48 // requires a valid ActivityManager handle, which can only come from 47 // requires a valid ActivityManager handle, which can only come from
49 // a valid Context object, which itself cannot be retrieved 48 // a valid Context object, which itself cannot be retrieved
50 // during early startup, where this method is called. And making it 49 // during early startup, where this method is called. And making it
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 118 }
120 119
121 if (Build.VERSION.SDK_INT <= ANDROID_LOW_MEMORY_ANDROID_SDK_THRESHOLD) { 120 if (Build.VERSION.SDK_INT <= ANDROID_LOW_MEMORY_ANDROID_SDK_THRESHOLD) {
122 return false; 121 return false;
123 } 122 }
124 123
125 int ramSizeKB = amountOfPhysicalMemoryKB(); 124 int ramSizeKB = amountOfPhysicalMemoryKB();
126 return (ramSizeKB > 0 && ramSizeKB / 1024 < ANDROID_LOW_MEMORY_DEVICE_TH RESHOLD_MB); 125 return (ramSizeKB > 0 && ramSizeKB / 1024 < ANDROID_LOW_MEMORY_DEVICE_TH RESHOLD_MB);
127 } 126 }
128 } 127 }
OLDNEW
« no previous file with comments | « base/android/base_jni_registrar.cc ('k') | base/android/sys_utils.h » ('j') | base/sys_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698