Index: base/sys_utils.cc |
diff --git a/base/sys_utils.cc b/base/sys_utils.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..340bb46ce81747718c65bf38815f7a52e551fd29 |
--- /dev/null |
+++ b/base/sys_utils.cc |
@@ -0,0 +1,47 @@ |
+// 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 kLowMemoryDeviceThresholdMB = 512; |
+ |
+bool DetectLowEndDevice() { |
+ CommandLine* command_line = CommandLine::ForCurrentProcess(); |
+ if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode )) { |
+ return true; |
+ } |
+ 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(); |
+} |
+} // namespace base |
+#endif |