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

Unified Diff: base/sys_utils.cc

Issue 119493005: Expose a low-end device mode override flags for non-android OSs as well (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Put low end device detection under the flag for all platforms except android. Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: base/sys_utils.cc
diff --git a/base/sys_utils.cc b/base/sys_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f2e8008eb102831da420cf189dae1976eb433460
--- /dev/null
+++ b/base/sys_utils.cc
@@ -0,0 +1,55 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/sys_utils.h"
+
+#include "base/base_switches.h"
+#include "base/command_line.h"
+#include "base/lazy_instance.h"
+#include "base/sys_info.h"
+#include "base/sys_info_internal.h"
+
+#if !defined(OS_ANDROID)
+namespace {
+static const int LOW_MEMORY_DEVICE_THRESHOLD_MB = 512;
piman 2014/01/21 21:23:49 nit: kLowMemoryDeviceThresholdMB.
+
+bool detectLowEndDevice() {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode )) {
+ return true;
+ }
+ if (command_line->HasSwitch(switches::kDisableLowEndDeviceMode)) {
+ return false;
+ }
+#if defined(ENABLE_LOW_END_DEVICE_DETECTION)
piman 2014/01/21 21:23:49 Command-line flag instead of compile-time flag?
+ int ram_size_mb = base::SysInfo::AmountOfPhysicalMemoryMB();
+ return (ram_size_mb > 0 &&
+ ram_size_mb < LOW_MEMORY_DEVICE_THRESHOLD_MB);
+#else
+ return false;
+#endif // defined(ENABLE_LOW_END_DEVICE_DETECTION)
+}
+
+static base::LazyInstance<
+ base::internal::LazySysInfoValue<bool, detectLowEndDevice> >::Leaky
+ g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+namespace base {
+// static
+bool SysUtils::IsLowEndDevice() {
+ return g_lazy_low_end_device.Get().value();
+}
+} // namespace base
+#endif
+
+namespace base {
+// static
+size_t SysUtils::AmountOfPhysicalMemoryKB() {
+ return SysInfo::AmountOfPhysicalMemory() / 1024;
+}
+
+SysUtils::SysUtils() { }
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698