1 // Copyright (c) 2012 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.
5 #include "base/sys_info.h"
7 #include "base/base_switches.h"
8 #include "base/command_line.h"
9 #include "base/lazy_instance.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/sys_info_internal.h"
12 #include "base/time/time.h"
16 #if !defined(OS_ANDROID)
18 static const int kLowMemoryDeviceThresholdMB
= 512;
20 bool DetectLowEndDevice() {
21 CommandLine
* command_line
= CommandLine::ForCurrentProcess();
23 if (command_line
->HasSwitch(switches::kLowEndDeviceMode
)) {
24 std::string string_value
=
25 command_line
->GetSwitchValueASCII(switches::kLowEndDeviceMode
);
26 StringToInt(string_value
, &int_value
);
33 int ram_size_mb
= SysInfo::AmountOfPhysicalMemoryMB();
34 return (ram_size_mb
> 0 && ram_size_mb
< kLowMemoryDeviceThresholdMB
);
38 internal::LazySysInfoValue
<bool, DetectLowEndDevice
> >::Leaky
39 g_lazy_low_end_device
= LAZY_INSTANCE_INITIALIZER
;
42 bool SysInfo::IsLowEndDevice() {
43 return g_lazy_low_end_device
.Get().value();
47 #if !defined(OS_MACOSX) || defined(OS_IOS)
48 std::string
SysInfo::HardwareModelName() {
54 int64
SysInfo::Uptime() {
55 // This code relies on an implementation detail of TimeTicks::Now() - that
56 // its return value happens to coincide with the system uptime value in
57 // microseconds, on Win/Mac/iOS/Linux/ChromeOS and Android.
58 int64 uptime_in_microseconds
= TimeTicks::Now().ToInternalValue();
59 return uptime_in_microseconds
/ 1000;