Commit 6c24049a authored by Eric Karl's avatar Eric Karl Committed by Commit Bot

Make --enable-low-end-device-mode apply in C++ on Android

Currently, Android supports --enable-low-end-device-mode, but requires
that the flag be set/visible to Java. This limits the usefulness, as
we can't apply this flag via C++ in test scenarios. This change
modifies SysInfo::IsLowEndDevice to behave like
SysInfo::AmountOfAvailablePhysicalMemory in its handling of flags:
flags are checked / applied in platform-independent C++ before
forwarding to a platform-specific impl function in the case that
the default behavior was not overridden.

Change-Id: Ic2952ed5d2eb199f4daaa60aa2f1eb6dad87d205
Reviewed-on: https://chromium-review.googlesource.com/959301Reviewed-by: default avatardanakj <danakj@chromium.org>
Commit-Queue: Eric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542823}
parent 40ac85ca
......@@ -44,6 +44,15 @@ int64_t SysInfo::AmountOfAvailablePhysicalMemory() {
return AmountOfAvailablePhysicalMemoryImpl();
}
bool SysInfo::IsLowEndDevice() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableLowEndDeviceMode)) {
return true;
}
return IsLowEndDeviceImpl();
}
#if !defined(OS_ANDROID)
bool DetectLowEndDevice() {
......@@ -62,7 +71,7 @@ static LazyInstance<
g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER;
// static
bool SysInfo::IsLowEndDevice() {
bool SysInfo::IsLowEndDeviceImpl() {
return g_lazy_low_end_device.Get().value();
}
#endif
......
......@@ -172,6 +172,7 @@ class BASE_EXPORT SysInfo {
static int64_t AmountOfPhysicalMemoryImpl();
static int64_t AmountOfAvailablePhysicalMemoryImpl();
static bool IsLowEndDeviceImpl();
#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_AIX)
static int64_t AmountOfAvailablePhysicalMemory(
......
......@@ -222,7 +222,7 @@ static base::LazyInstance<
android::SysUtils::IsLowEndDeviceFromJni> >::Leaky
g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER;
bool SysInfo::IsLowEndDevice() {
bool SysInfo::IsLowEndDeviceImpl() {
// This code might be used in some environments
// which might not have a Java environment.
// Note that we need to call the Java version here.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment