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

Unified Diff: base/sys_info.h

Issue 2558043007: Fix free memory calculation. (Closed)
Patch Set: Fix integer overflow in unittest. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process/process_metrics_win.cc ('k') | base/sys_info_ios.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info.h
diff --git a/base/sys_info.h b/base/sys_info.h
index e35feff735e4ac3783d1870ae04d711ef7cdd7fc..ecaa7317faf9e882aecfe90421cd32af18c55aca 100644
--- a/base/sys_info.h
+++ b/base/sys_info.h
@@ -13,11 +13,18 @@
#include "base/base_export.h"
#include "base/files/file_path.h"
+#include "base/gtest_prod_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
namespace base {
+namespace debug {
+FORWARD_DECLARE_TEST(SystemMetricsTest, ParseMeminfo);
+}
+
+struct SystemMemoryInfoKB;
+
class BASE_EXPORT SysInfo {
public:
// Return the number of logical processors/cores on the current machine.
@@ -28,6 +35,9 @@ class BASE_EXPORT SysInfo {
// Return the number of bytes of current available physical memory on the
// machine.
+ // (The amount of memory that can be allocated without any significant
+ // impact on the system. It can lead to freeing inactive file-backed
+ // and/or speculative file-backed memory).
static int64_t AmountOfAvailablePhysicalMemory();
// Return the number of bytes of virtual memory of this process. A return
@@ -147,6 +157,15 @@ class BASE_EXPORT SysInfo {
// Low-end device refers to devices having less than 512M memory in the
// current implementation.
static bool IsLowEndDevice();
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(SysInfoTest, AmountOfAvailablePhysicalMemory);
+ FRIEND_TEST_ALL_PREFIXES(debug::SystemMetricsTest, ParseMeminfo);
+
+#if defined(OS_LINUX) || defined(OS_ANDROID)
+ static int64_t AmountOfAvailablePhysicalMemory(
+ const SystemMemoryInfoKB& meminfo);
+#endif
};
} // namespace base
« no previous file with comments | « base/process/process_metrics_win.cc ('k') | base/sys_info_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698