Skip to content

Commit

Permalink
Removed discrepancy in low-end-device-mode flag
Browse files Browse the repository at this point in the history
Removed the flag low-end-device-mode and added two flags enable-low-end-device-mode and disable-low-end-device-mode. This removes discrepancies between the flag values (integers) when used in different platforms and makes it simple to use with the just the flags and no values passed.

BUG=437778

Review URL: https://codereview.chromium.org/761783004

Cr-Commit-Position: refs/heads/master@{#308593}
  • Loading branch information
ssiddhartha authored and Commit bot committed Dec 16, 2014
1 parent fddf247 commit feb3f47
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 25 deletions.
9 changes: 5 additions & 4 deletions base/android/java/src/org/chromium/base/BaseSwitches.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ public abstract class BaseSwitches {
// Block ChildProcessMain thread of render process service until a Java debugger is attached.
public static final String RENDERER_WAIT_FOR_JAVA_DEBUGGER = "renderer-wait-for-java-debugger";

// Force low-end device when set to 1;
// Force non-low-end device when set to 0;
// Auto-detect low-end device when set to other values or empty;
public static final String LOW_END_DEVICE_MODE = "low-end-device-mode";
// Force low-end device mode when set.
public static final String ENABLE_LOW_END_DEVICE_MODE = "enable-low-end-device-mode";

// Force disabling of low-end device mode when set.
public static final String DISABLE_LOW_END_DEVICE_MODE = "disable-low-end-device-mode";

// Adds additional thread idle time information into the trace event output.
public static final String ENABLE_IDLE_TRACING = "enable-idle-tracing";
Expand Down
11 changes: 5 additions & 6 deletions base/android/java/src/org/chromium/base/SysUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,12 @@ public static boolean isLowEndDevice() {

private static boolean detectLowEndDevice() {
assert CommandLine.isInitialized();
if (CommandLine.getInstance().hasSwitch(BaseSwitches.LOW_END_DEVICE_MODE)) {
int mode = Integer.parseInt(CommandLine.getInstance().getSwitchValue(
BaseSwitches.LOW_END_DEVICE_MODE));
if (mode == 1) return true;
if (mode == 0) return false;
if (CommandLine.getInstance().hasSwitch(BaseSwitches.ENABLE_LOW_END_DEVICE_MODE)) {
return true;
}
if (CommandLine.getInstance().hasSwitch(BaseSwitches.DISABLE_LOW_END_DEVICE_MODE)) {
return false;
}

if (Build.VERSION.SDK_INT <= ANDROID_LOW_MEMORY_ANDROID_SDK_THRESHOLD) {
return false;
}
Expand Down
9 changes: 5 additions & 4 deletions base/base_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ const char kEnableCrashReporter[] = "enable-crash-reporter";
// Generates full memory crash dump.
const char kFullMemoryCrashReport[] = "full-memory-crash-report";

// Force low-end device when set to 1;
// Auto-detect low-end device when set to 2;
// Force non-low-end device when set to other values or empty;
const char kLowEndDeviceMode[] = "low-end-device-mode";
// Force low-end device mode when set.
const char kEnableLowEndDeviceMode[] = "enable-low-end-device-mode";

// Force disabling of low-end device mode when set.
const char kDisableLowEndDeviceMode[] = "disable-low-end-device-mode";

// Suppresses all error dialogs when present.
const char kNoErrorDialogs[] = "noerrdialogs";
Expand Down
3 changes: 2 additions & 1 deletion base/base_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace switches {
extern const char kDisableBreakpad[];
extern const char kEnableCrashReporter[];
extern const char kFullMemoryCrashReport[];
extern const char kLowEndDeviceMode[];
extern const char kEnableLowEndDeviceMode[];
extern const char kDisableLowEndDeviceMode[];
extern const char kNoErrorDialogs[];
extern const char kProfilerTiming[];
extern const char kProfilerTimingDisabledValue[];
Expand Down
10 changes: 2 additions & 8 deletions base/sys_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,9 @@ static const int kLowMemoryDeviceThresholdMB = 512;

bool DetectLowEndDevice() {
CommandLine* command_line = CommandLine::ForCurrentProcess();
int int_value = 0;
if (command_line->HasSwitch(switches::kLowEndDeviceMode)) {
std::string string_value =
command_line->GetSwitchValueASCII(switches::kLowEndDeviceMode);
StringToInt(string_value, &int_value);
}
if (int_value == 1)
if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode))
return true;
if (int_value != 2)
if (command_line->HasSwitch(switches::kDisableLowEndDeviceMode))
return false;

int ram_size_mb = SysInfo::AmountOfPhysicalMemoryMB();
Expand Down
3 changes: 2 additions & 1 deletion content/browser/gpu/gpu_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ static const char* const kSwitchNames[] = {
switches::kGpuSandboxStartEarly,
switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode,
switches::kLoggingLevel,
switches::kLowEndDeviceMode,
switches::kEnableLowEndDeviceMode,
switches::kDisableLowEndDeviceMode,
switches::kNoSandbox,
switches::kTestGLLib,
switches::kTraceStartup,
Expand Down
3 changes: 2 additions & 1 deletion content/browser/renderer_host/render_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,8 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kEnableWebRtcHWH264Encoding,
switches::kWebRtcMaxCaptureFramerate,
#endif
switches::kLowEndDeviceMode,
switches::kEnableLowEndDeviceMode,
switches::kDisableLowEndDeviceMode,
#if defined(OS_ANDROID)
switches::kDisableGestureRequirementForMediaPlayback,
switches::kDisableWebRTC,
Expand Down

0 comments on commit feb3f47

Please sign in to comment.