Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: base/sys_info.cc

Issue 816543004: Update from https://crrev.com/308996 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/memory/memory_pressure_listener.cc ('k') | base/tuple.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/sys_info_internal.h" 11 #include "base/sys_info_internal.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 #if !defined(OS_ANDROID) 16 #if !defined(OS_ANDROID)
17 17
18 static const int kLowMemoryDeviceThresholdMB = 512; 18 static const int kLowMemoryDeviceThresholdMB = 512;
19 19
20 bool DetectLowEndDevice() { 20 bool DetectLowEndDevice() {
21 CommandLine* command_line = CommandLine::ForCurrentProcess(); 21 CommandLine* command_line = CommandLine::ForCurrentProcess();
22 int int_value = 0; 22 if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode))
23 if (command_line->HasSwitch(switches::kLowEndDeviceMode)) {
24 std::string string_value =
25 command_line->GetSwitchValueASCII(switches::kLowEndDeviceMode);
26 StringToInt(string_value, &int_value);
27 }
28 if (int_value == 1)
29 return true; 23 return true;
30 if (int_value != 2) 24 if (command_line->HasSwitch(switches::kDisableLowEndDeviceMode))
31 return false; 25 return false;
32 26
33 int ram_size_mb = SysInfo::AmountOfPhysicalMemoryMB(); 27 int ram_size_mb = SysInfo::AmountOfPhysicalMemoryMB();
34 return (ram_size_mb > 0 && ram_size_mb < kLowMemoryDeviceThresholdMB); 28 return (ram_size_mb > 0 && ram_size_mb < kLowMemoryDeviceThresholdMB);
35 } 29 }
36 30
37 static LazyInstance< 31 static LazyInstance<
38 internal::LazySysInfoValue<bool, DetectLowEndDevice> >::Leaky 32 internal::LazySysInfoValue<bool, DetectLowEndDevice> >::Leaky
39 g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER; 33 g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER;
40 34
(...skipping 12 matching lines...) Expand all
53 // static 47 // static
54 int64 SysInfo::Uptime() { 48 int64 SysInfo::Uptime() {
55 // This code relies on an implementation detail of TimeTicks::Now() - that 49 // This code relies on an implementation detail of TimeTicks::Now() - that
56 // its return value happens to coincide with the system uptime value in 50 // its return value happens to coincide with the system uptime value in
57 // microseconds, on Win/Mac/iOS/Linux/ChromeOS and Android. 51 // microseconds, on Win/Mac/iOS/Linux/ChromeOS and Android.
58 int64 uptime_in_microseconds = TimeTicks::Now().ToInternalValue(); 52 int64 uptime_in_microseconds = TimeTicks::Now().ToInternalValue();
59 return uptime_in_microseconds / 1000; 53 return uptime_in_microseconds / 1000;
60 } 54 }
61 55
62 } // namespace base 56 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/memory_pressure_listener.cc ('k') | base/tuple.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698