Chromium Code Reviews| 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 { | |
|
brettw
2014/06/09 22:49:57
blank lines around this, also check other namespac
c.shu
2014/06/10 17:36:26
Done.
| |
| 15 static const int kLowMemoryDeviceThresholdMB = 512; | |
| 16 | |
| 17 bool DetectLowEndDevice() { | |
| 18 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 19 if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode )) { | |
| 20 return true; | |
|
brettw
2014/06/09 22:49:57
Check indenting.
c.shu
2014/06/10 17:36:26
Done.
| |
| 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(); | |
|
brettw
2014/06/09 22:49:57
I think this leaky stuff is overkill for this use
ostap
2014/06/10 17:05:57
There are several places in base/sys-*.cc where La
| |
| 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 | |
| OLD | NEW |