| 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 |
| 19 namespace base { | 20 namespace base { |
| 20 | 21 |
| 22 namespace debug { |
| 23 FORWARD_DECLARE_TEST(SystemMetricsTest, ParseMeminfo); |
| 24 } |
| 25 |
| 26 struct SystemMemoryInfoKB; |
| 27 |
| 21 class BASE_EXPORT SysInfo { | 28 class BASE_EXPORT SysInfo { |
| 22 public: | 29 public: |
| 23 // Return the number of logical processors/cores on the current machine. | 30 // Return the number of logical processors/cores on the current machine. |
| 24 static int NumberOfProcessors(); | 31 static int NumberOfProcessors(); |
| 25 | 32 |
| 26 // Return the number of bytes of physical memory on the current machine. | 33 // Return the number of bytes of physical memory on the current machine. |
| 27 static int64_t AmountOfPhysicalMemory(); | 34 static int64_t AmountOfPhysicalMemory(); |
| 28 | 35 |
| 29 // Return the number of bytes of current available physical memory on the | 36 // Return the number of bytes of current available physical memory on the |
| 30 // machine. | 37 // 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). |
| 31 static int64_t AmountOfAvailablePhysicalMemory(); | 41 static int64_t AmountOfAvailablePhysicalMemory(); |
| 32 | 42 |
| 33 // Return the number of bytes of virtual memory of this process. A return | 43 // 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 | 44 // value of zero means that there is no limit on the available virtual |
| 35 // memory. | 45 // memory. |
| 36 static int64_t AmountOfVirtualMemory(); | 46 static int64_t AmountOfVirtualMemory(); |
| 37 | 47 |
| 38 // Return the number of megabytes of physical memory on the current machine. | 48 // Return the number of megabytes of physical memory on the current machine. |
| 39 static int AmountOfPhysicalMemoryMB() { | 49 static int AmountOfPhysicalMemoryMB() { |
| 40 return static_cast<int>(AmountOfPhysicalMemory() / 1024 / 1024); | 50 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(); | 150 static std::string GetAndroidBuildID(); |
| 141 | 151 |
| 142 static int DalvikHeapSizeMB(); | 152 static int DalvikHeapSizeMB(); |
| 143 static int DalvikHeapGrowthLimitMB(); | 153 static int DalvikHeapGrowthLimitMB(); |
| 144 #endif // defined(OS_ANDROID) | 154 #endif // defined(OS_ANDROID) |
| 145 | 155 |
| 146 // Returns true if this is a low-end device. | 156 // Returns true if this is a low-end device. |
| 147 // Low-end device refers to devices having less than 512M memory in the | 157 // Low-end device refers to devices having less than 512M memory in the |
| 148 // current implementation. | 158 // current implementation. |
| 149 static bool IsLowEndDevice(); | 159 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 |
| 150 }; | 169 }; |
| 151 | 170 |
| 152 } // namespace base | 171 } // namespace base |
| 153 | 172 |
| 154 #endif // BASE_SYS_INFO_H_ | 173 #endif // BASE_SYS_INFO_H_ |
| OLD | NEW |