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 |
| 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 |
OLD | NEW |