OLD | NEW |
---|---|
(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 LOW_MEMORY_DEVICE_THRESHOLD_MB = 512; | |
piman
2014/01/21 21:23:49
nit: kLowMemoryDeviceThresholdMB.
| |
16 | |
17 bool detectLowEndDevice() { | |
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 #if defined(ENABLE_LOW_END_DEVICE_DETECTION) | |
piman
2014/01/21 21:23:49
Command-line flag instead of compile-time flag?
| |
26 int ram_size_mb = base::SysInfo::AmountOfPhysicalMemoryMB(); | |
27 return (ram_size_mb > 0 && | |
28 ram_size_mb < LOW_MEMORY_DEVICE_THRESHOLD_MB); | |
29 #else | |
30 return false; | |
31 #endif // defined(ENABLE_LOW_END_DEVICE_DETECTION) | |
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 // static | |
42 bool SysUtils::IsLowEndDevice() { | |
43 return g_lazy_low_end_device.Get().value(); | |
44 } | |
45 } // namespace base | |
46 #endif | |
47 | |
48 namespace base { | |
49 // static | |
50 size_t SysUtils::AmountOfPhysicalMemoryKB() { | |
51 return SysInfo::AmountOfPhysicalMemory() / 1024; | |
52 } | |
53 | |
54 SysUtils::SysUtils() { } | |
55 } // namespace base | |
OLD | NEW |