Chromium Code Reviews| Index: base/sys_utils.cc |
| diff --git a/base/sys_utils.cc b/base/sys_utils.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9e724170d25b886d066dc7bf070a6102a1355040 |
| --- /dev/null |
| +++ b/base/sys_utils.cc |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/sys_utils.h" |
| + |
| +#include "base/base_switches.h" |
| +#include "base/command_line.h" |
| +#include "base/sys_info.h" |
| + |
| +namespace base { |
| + |
| +#if !defined(OS_ANDROID) |
| +static const int LOW_MEMORY_DEVICE_THRESHOLD_MB = 512; |
| + |
| +static bool detectLowEndDevice() { |
| + CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode )) { |
| + return true; |
| + } |
| + if (command_line->HasSwitch(switches::kDisableLowEndDeviceMode)) { |
| + return false; |
| + } |
| + |
| + int ramSizeKB = SysUtils::AmountOfPhysicalMemoryKB(); |
|
willchan no longer on Chromium
2013/12/26 19:02:39
ram_size_kb
ostap
2014/01/20 08:12:24
Done.
|
| + return (ramSizeKB > 0 && ramSizeKB / 1024 < LOW_MEMORY_DEVICE_THRESHOLD_MB); |
| +} |
| + |
| +// static |
| +bool SysUtils::IsLowEndDevice() { |
| + static bool isLowEndDevice = detectLowEndDevice(); |
|
willchan no longer on Chromium
2013/12/26 19:02:39
We disable the compiler generated locks around fun
ostap
2014/01/20 08:12:24
Done.
|
| + return isLowEndDevice; |
| +} |
| + |
| +// static |
| +size_t SysUtils::AmountOfPhysicalMemoryKB() { |
| + return SysInfo::AmountOfPhysicalMemory() / 1024; |
|
piman
2014/01/08 04:41:50
I'm not sure SysInfo::AmountOfPhysicalMemory() wor
ostap
2014/01/20 08:12:24
Should work.
At least initializeV8Common() in WebK
|
| +} |
| +#endif |
| + |
| +SysUtils::SysUtils() { } |
| + |
| +} // namespace base |