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

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: 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 unified diff | Download patch
« no previous file with comments | « base/sys_utils.h ('k') | chrome/browser/android/chrome_startup_flags.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 static const int kLowMemoryDeviceThresholdMB = 512;
16
17 bool detectLowEndDevice() {
piman 2014/04/24 19:50:08 nit: style
c.shu 2014/06/10 17:36:26 Done.
18 CommandLine* command_line = CommandLine::ForCurrentProcess();
19 if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode )) {
20 return true;
21 }
22 if (command_line->HasSwitch(switches::kDisableLowEndDeviceMode)) {
23 return false;
24 }
25
26 if (command_line->HasSwitch(switches::kDetectLowEndDevice)) {
27 int ram_size_mb = base::SysInfo::AmountOfPhysicalMemoryMB();
28 return (ram_size_mb > 0 && ram_size_mb < kLowMemoryDeviceThresholdMB);
29 }
30 return false;
31 }
32
33 static base::LazyInstance<
34 base::internal::LazySysInfoValue<bool, detectLowEndDevice> >::Leaky
35 g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER;
36
37 } // namespace
38
39 namespace base {
40 // static
41 bool SysUtils::IsLowEndDevice() {
42 return g_lazy_low_end_device.Get().value();
piman 2014/04/24 19:50:08 This won't work in subprocesses unless: 1- command
43 }
44 } // namespace base
45 #endif
46
47 namespace base {
48 // static
49 size_t SysUtils::AmountOfPhysicalMemoryKB() {
50 return SysInfo::AmountOfPhysicalMemory() / 1024;
51 }
52
53 SysUtils::SysUtils() { }
54 } // namespace base
OLDNEW
« no previous file with comments | « base/sys_utils.h ('k') | chrome/browser/android/chrome_startup_flags.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698