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

Unified Diff: base/sys_info.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: address review comments. Created 6 years, 6 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
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info.cc
diff --git a/base/sys_info.cc b/base/sys_info.cc
index d43e9320bc4ec2a4898fd372cd363be3d46d8e02..0b3b317fc8bf2a92a72bcf2991af8da3470ac2b0 100644
--- a/base/sys_info.cc
+++ b/base/sys_info.cc
@@ -4,10 +4,46 @@
#include "base/sys_info.h"
+#include "base/base_switches.h"
+#include "base/command_line.h"
+#include "base/lazy_instance.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/sys_info_internal.h"
#include "base/time/time.h"
namespace base {
+#if !defined(OS_ANDROID)
+
+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)
+ return true;
+ if (int_value != 2)
+ return false;
+
+ int ram_size_mb = SysInfo::AmountOfPhysicalMemoryMB();
+ return (ram_size_mb > 0 && ram_size_mb < kLowMemoryDeviceThresholdMB);
+}
+
+static LazyInstance<
+ internal::LazySysInfoValue<bool, DetectLowEndDevice> >::Leaky
+ g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER;
+
+// static
+bool SysInfo::IsLowEndDevice() {
+ return g_lazy_low_end_device.Get().value();
+}
+#endif
+
// static
int64 SysInfo::Uptime() {
// This code relies on an implementation detail of TimeTicks::Now() - that
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698