diff options
author | digit@chromium.org <digit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-08 01:04:57 +0000 |
---|---|---|
committer | digit@chromium.org <digit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-08 01:04:57 +0000 |
commit | 095e4dc9888210cb153f712830e7f07e8c9c9a51 (patch) | |
tree | 8524937dae2c4ce3986362f1cb28d455ec356c42 /content/common/android | |
parent | f0ad54cdb589d9054b86f49872d338b682ba590d (diff) | |
download | chromium_src-095e4dc9888210cb153f712830e7f07e8c9c9a51.zip chromium_src-095e4dc9888210cb153f712830e7f07e8c9c9a51.tar.gz chromium_src-095e4dc9888210cb153f712830e7f07e8c9c9a51.tar.bz2 |
android: Make org.chromium.base.SysUtils.isLowEndDevice() work without native code.
This patch modifies the implementation if SysUtils.isLowEndDevice() to
not rely on any native code, which is required to run it before the native
libraries are actually loaded (e.g. when running certain tests).
+ Simplify the content linker that doesn't need a specific native method
anymore to replicate the yet-unloaded native SysUtils::IsLowEndDevice().
BUG=309926
R=dtrainor@chromium.org,tedchoc@chromium.org,frankf@chromium.org,bulach@chromium.org
TEST=build/android/test_runner.py linker
Review URL: https://codereview.chromium.org/59033008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common/android')
-rw-r--r-- | content/common/android/linker/linker_jni.cc | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/content/common/android/linker/linker_jni.cc b/content/common/android/linker/linker_jni.cc index 4254def..7db9fea 100644 --- a/content/common/android/linker/linker_jni.cc +++ b/content/common/android/linker/linker_jni.cc @@ -19,12 +19,6 @@ #include <stdlib.h> #include <unistd.h> -// Any device that reports a physical RAM size less than this, in megabytes -// is considered 'low-end'. IMPORTANT: Read the LinkerLowMemoryThresholdTest -// comments in build/android/pylib/linker/test_case.py before modifying this -// value. -#define ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB 512 - // Set this to 1 to enable debug traces to the Android log. // Note that LOG() from "base/logging.h" cannot be used, since it is // in base/ which hasn't been loaded yet. @@ -388,30 +382,6 @@ jlong GetPageSize(JNIEnv* env, jclass clazz) { return result; } -jboolean IsLowMemoryDevice(JNIEnv* env, jclass clazz) { - // This matches the implementation of org.chromium.base.SysUtils.isLowEnd(), - // however this Java method relies on native code from base/, which isn't - // available since the library hasn't been loaded yet. - // The value ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB is the same for both - // sources. - - // Threshold for low-end memory devices. - const size_t kMegaBytes = 1024 * 1024; - const size_t kLowMemoryDeviceThreshold = - ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB * kMegaBytes; - - // Compute the amount of physical RAM on the device. - size_t pages = static_cast<size_t>(sysconf(_SC_PHYS_PAGES)); - size_t page_size = static_cast<size_t>(sysconf(_SC_PAGESIZE)); - size_t physical_size = pages * page_size; - - LOG_INFO("%s: System physical size is %zu MB\n", - __FUNCTION__, - physical_size / kMegaBytes); - - return physical_size <= kLowMemoryDeviceThreshold; -} - const JNINativeMethod kNativeMethods[] = { {"nativeLoadLibrary", "(" @@ -445,12 +415,7 @@ const JNINativeMethod kNativeMethods[] = { "(" ")" "J", - reinterpret_cast<void*>(&GetPageSize)}, - {"nativeIsLowMemoryDevice", - "(" - ")" - "Z", - reinterpret_cast<void*>(&IsLowMemoryDevice)}, }; + reinterpret_cast<void*>(&GetPageSize)}, }; } // namespace |