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 #ifndef BASE_SYS_INFO_H_ | 5 #ifndef BASE_SYS_INFO_H_ |
6 #define BASE_SYS_INFO_H_ | 6 #define BASE_SYS_INFO_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/base_export.h" | 14 #include "base/base_export.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/gtest_prod_util.h" | |
17 #include "base/time/time.h" | 16 #include "base/time/time.h" |
18 #include "build/build_config.h" | 17 #include "build/build_config.h" |
19 | 18 |
20 namespace base { | 19 namespace base { |
21 | 20 |
22 namespace debug { | |
23 FORWARD_DECLARE_TEST(SystemMetricsTest, ParseMeminfo); | |
24 } | |
25 | |
26 struct SystemMemoryInfoKB; | |
27 | |
28 class BASE_EXPORT SysInfo { | 21 class BASE_EXPORT SysInfo { |
29 public: | 22 public: |
30 // Return the number of logical processors/cores on the current machine. | 23 // Return the number of logical processors/cores on the current machine. |
31 static int NumberOfProcessors(); | 24 static int NumberOfProcessors(); |
32 | 25 |
33 // Return the number of bytes of physical memory on the current machine. | 26 // Return the number of bytes of physical memory on the current machine. |
34 static int64_t AmountOfPhysicalMemory(); | 27 static int64_t AmountOfPhysicalMemory(); |
35 | 28 |
36 // Return the number of bytes of current available physical memory on the | 29 // Return the number of bytes of current available physical memory on the |
37 // machine. | 30 // machine. |
38 // (The amount of memory that can be allocated without any significant | |
39 // impact on the system. It can lead to freeing inactive file-backed | |
40 // and/or speculative file-backed memory). | |
41 static int64_t AmountOfAvailablePhysicalMemory(); | 31 static int64_t AmountOfAvailablePhysicalMemory(); |
42 | 32 |
43 // Return the number of bytes of virtual memory of this process. A return | 33 // Return the number of bytes of virtual memory of this process. A return |
44 // value of zero means that there is no limit on the available virtual | 34 // value of zero means that there is no limit on the available virtual |
45 // memory. | 35 // memory. |
46 static int64_t AmountOfVirtualMemory(); | 36 static int64_t AmountOfVirtualMemory(); |
47 | 37 |
48 // Return the number of megabytes of physical memory on the current machine. | 38 // Return the number of megabytes of physical memory on the current machine. |
49 static int AmountOfPhysicalMemoryMB() { | 39 static int AmountOfPhysicalMemoryMB() { |
50 return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024); | 40 return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 static std::string GetAndroidBuildID(); | 140 static std::string GetAndroidBuildID(); |
151 | 141 |
152 static int DalvikHeapSizeMB(); | 142 static int DalvikHeapSizeMB(); |
153 static int DalvikHeapGrowthLimitMB(); | 143 static int DalvikHeapGrowthLimitMB(); |
154 #endif // defined(OS_ANDROID) | 144 #endif // defined(OS_ANDROID) |
155 | 145 |
156 // Returns true if this is a low-end device. | 146 // Returns true if this is a low-end device. |
157 // Low-end device refers to devices having less than 512M memory in the | 147 // Low-end device refers to devices having less than 512M memory in the |
158 // current implementation. | 148 // current implementation. |
159 static bool IsLowEndDevice(); | 149 static bool IsLowEndDevice(); |
160 | |
161 private: | |
162 FRIEND_TEST_ALL_PREFIXES(SysInfoTest, AmountOfAvailablePhysicalMemory); | |
163 FRIEND_TEST_ALL_PREFIXES(debug::SystemMetricsTest, ParseMeminfo); | |
164 | |
165 #if defined(OS_LINUX) || defined(OS_ANDROID) | |
166 static int64_t AmountOfAvailablePhysicalMemory( | |
167 const SystemMemoryInfoKB& meminfo); | |
168 #endif | |
169 }; | 150 }; |
170 | 151 |
171 } // namespace base | 152 } // namespace base |
172 | 153 |
173 #endif // BASE_SYS_INFO_H_ | 154 #endif // BASE_SYS_INFO_H_ |
OLD | NEW |