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