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

Unified Diff: base/sys_utils.cc

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: Forward command-line flags to renderer and gpu processes 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 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..e53dc9ce75614a78c656da7f632b6966b4b5b3ea
--- /dev/null
+++ b/base/sys_utils.cc
@@ -0,0 +1,54 @@
+// 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 {
brettw 2014/06/09 22:49:57 blank lines around this, also check other namespac
c.shu 2014/06/10 17:36:26 Done.
+static const int kLowMemoryDeviceThresholdMB = 512;
+
+bool DetectLowEndDevice() {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode )) {
+ return true;
brettw 2014/06/09 22:49:57 Check indenting.
c.shu 2014/06/10 17:36:26 Done.
+ }
+ if (command_line->HasSwitch(switches::kDisableLowEndDeviceMode)) {
+ return false;
+ }
+
+ if (command_line->HasSwitch(switches::kDetectLowEndDevice)) {
+ int ram_size_mb = base::SysInfo::AmountOfPhysicalMemoryMB();
+ return (ram_size_mb > 0 && ram_size_mb < kLowMemoryDeviceThresholdMB);
+ }
+ return false;
+}
+
+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();
brettw 2014/06/09 22:49:57 I think this leaky stuff is overkill for this use
ostap 2014/06/10 17:05:57 There are several places in base/sys-*.cc where La
+}
+} // 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