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

Side by Side Diff: base/sys_info.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 months 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/sys_info.h ('k') | base/sys_info_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "base/sys_info.h"
6
7 #include "base/base_switches.h"
8 #include "base/command_line.h"
9 #include "base/lazy_instance.h"
10 #include "base/metrics/field_trial.h"
11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h"
13 #include "base/sys_info_internal.h"
14 #include "base/time/time.h"
15
16 namespace base {
17
18 #if !defined(OS_ANDROID)
19
20 static const int kLowMemoryDeviceThresholdMB = 512;
21
22 bool DetectLowEndDevice() {
23 CommandLine* command_line = CommandLine::ForCurrentProcess();
24 if (command_line->HasSwitch(switches::kEnableLowEndDeviceMode))
25 return true;
26 if (command_line->HasSwitch(switches::kDisableLowEndDeviceMode))
27 return false;
28
29 int ram_size_mb = SysInfo::AmountOfPhysicalMemoryMB();
30 return (ram_size_mb > 0 && ram_size_mb < kLowMemoryDeviceThresholdMB);
31 }
32
33 static LazyInstance<
34 internal::LazySysInfoValue<bool, DetectLowEndDevice> >::Leaky
35 g_lazy_low_end_device = LAZY_INSTANCE_INITIALIZER;
36
37 // static
38 bool SysInfo::IsLowEndDevice() {
39 const std::string group_name =
40 base::FieldTrialList::FindFullName("MemoryReduction");
41
42 // Low End Device Mode will be enabled if this client is assigned to
43 // one of those EnabledXXX groups.
44 if (StartsWith(group_name, "Enabled", CompareCase::SENSITIVE))
45 return true;
46
47 return g_lazy_low_end_device.Get().value();
48 }
49 #endif
50
51 #if (!defined(OS_MACOSX) || defined(OS_IOS)) && !defined(OS_ANDROID)
52 std::string SysInfo::HardwareModelName() {
53 return std::string();
54 }
55 #endif
56
57 // static
58 int64 SysInfo::Uptime() {
59 // This code relies on an implementation detail of TimeTicks::Now() - that
60 // its return value happens to coincide with the system uptime value in
61 // microseconds, on Win/Mac/iOS/Linux/ChromeOS and Android.
62 int64 uptime_in_microseconds = TimeTicks::Now().ToInternalValue();
63 return uptime_in_microseconds / 1000;
64 }
65
66 } // namespace base
OLDNEW
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698