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

Side by Side 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: Fix Android unittest build. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/sys_utils.h"
6
7 #include "base/base_switches.h"
8 #include "base/command_line.h"
9 #include "base/lazy_instance.h"
10 #include "base/sys_info.h"
11 #include "base/sys_info_internal.h"
12
13 #if !defined(OS_ANDROID)
14 namespace {
15
16 static const int kLowMemoryDeviceThresholdMB = 512;
17
18 bool DetectLowEndDevice() {
19 CommandLine* command_line = CommandLine::ForCurrentProcess();
20 if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode )) {
21 return true;
22 }
23 if (command_line->HasSwitch(switches::kDisableLowEndDeviceMode)) {
24 return false;
25 }
26
27 if (command_line->HasSwitch(switches::kDetectLowEndDevice)) {
28 int ram_size_mb = base::SysInfo::AmountOfPhysicalMemoryMB();
29 return (ram_size_mb > 0 && ram_size_mb < kLowMemoryDeviceThresholdMB);
30 }
31 return false;
32 }
33
34 static base::LazyInstance<
35 base::internal::LazySysInfoValue<bool, DetectLowEndDevice> >::Leaky
36 g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER;
37
38 } // namespace
39
40 namespace base {
41
42 // static
43 bool SysUtils::IsLowEndDevice() {
44 return g_lazy_low_end_device.Get().value();
45 }
46 } // namespace base
47 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698