OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/sys_info.h" | 5 #include "base/sys_info.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 static const int kLowMemoryDeviceThresholdMB = 512; | 21 static const int kLowMemoryDeviceThresholdMB = 512; |
22 | 22 |
23 bool DetectLowEndDevice() { | 23 bool DetectLowEndDevice() { |
24 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 24 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
25 if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode)) | 25 if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode)) |
26 return true; | 26 return true; |
27 if (command_line->HasSwitch(switches::kDisableLowEndDeviceMode)) | 27 if (command_line->HasSwitch(switches::kDisableLowEndDeviceMode)) |
28 return false; | 28 return false; |
29 | 29 |
30 int ram_size_mb = SysInfo::AmountOfPhysicalMemoryMB(); | 30 int ram_size_mb = SysInfo::AmountOfPhysicalMemoryMB(); |
31 return (ram_size_mb > 0 && ram_size_mb < kLowMemoryDeviceThresholdMB); | 31 return (ram_size_mb > 0 && ram_size_mb <= kLowMemoryDeviceThresholdMB); |
32 } | 32 } |
33 | 33 |
34 static LazyInstance< | 34 static LazyInstance< |
35 internal::LazySysInfoValue<bool, DetectLowEndDevice> >::Leaky | 35 internal::LazySysInfoValue<bool, DetectLowEndDevice> >::Leaky |
36 g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER; | 36 g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER; |
37 | 37 |
38 // static | 38 // static |
39 bool SysInfo::IsLowEndDevice() { | 39 bool SysInfo::IsLowEndDevice() { |
40 const std::string group_name = | 40 const std::string group_name = |
41 base::FieldTrialList::FindFullName("MemoryReduction"); | 41 base::FieldTrialList::FindFullName("MemoryReduction"); |
(...skipping 16 matching lines...) Expand all Loading... |
58 // static | 58 // static |
59 base::TimeDelta SysInfo::Uptime() { | 59 base::TimeDelta SysInfo::Uptime() { |
60 // This code relies on an implementation detail of TimeTicks::Now() - that | 60 // This code relies on an implementation detail of TimeTicks::Now() - that |
61 // its return value happens to coincide with the system uptime value in | 61 // its return value happens to coincide with the system uptime value in |
62 // microseconds, on Win/Mac/iOS/Linux/ChromeOS and Android. | 62 // microseconds, on Win/Mac/iOS/Linux/ChromeOS and Android. |
63 int64_t uptime_in_microseconds = TimeTicks::Now().ToInternalValue(); | 63 int64_t uptime_in_microseconds = TimeTicks::Now().ToInternalValue(); |
64 return base::TimeDelta::FromMicroseconds(uptime_in_microseconds); | 64 return base::TimeDelta::FromMicroseconds(uptime_in_microseconds); |
65 } | 65 } |
66 | 66 |
67 } // namespace base | 67 } // namespace base |
OLD | NEW |