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

Unified Diff: base/sys_info_posix.cc

Issue 227113011: Expose the virtual memory limit to blink (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 6 years, 8 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/sys_info.h ('k') | base/sys_info_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_posix.cc
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc
index 07d08b72bbcb51fd8e550ab79409c55c6dff9af4..90baa69a2f61ec6489dcc36d32932a8c5de7dcb0 100644
--- a/base/sys_info_posix.cc
+++ b/base/sys_info_posix.cc
@@ -7,6 +7,7 @@
#include <errno.h>
#include <string.h>
#include <sys/param.h>
+#include <sys/resource.h>
#include <sys/utsname.h>
#include <unistd.h>
@@ -45,6 +46,20 @@ base::LazyInstance<
g_lazy_number_of_processors = LAZY_INSTANCE_INITIALIZER;
#endif
+int64 AmountOfVirtualMemory() {
+ struct rlimit limit;
+ int result = getrlimit(RLIMIT_DATA, &limit);
+ if (result != 0) {
+ NOTREACHED();
+ return 0;
+ }
+ return limit.rlim_cur == RLIM_INFINITY ? 0 : limit.rlim_cur;
+}
+
+base::LazyInstance<
+ base::internal::LazySysInfoValue<int64, AmountOfVirtualMemory> >::Leaky
+ g_lazy_virtual_memory = LAZY_INSTANCE_INITIALIZER;
+
} // namespace
namespace base {
@@ -56,6 +71,11 @@ int SysInfo::NumberOfProcessors() {
#endif
// static
+int64 SysInfo::AmountOfVirtualMemory() {
+ return g_lazy_virtual_memory.Get().value();
+}
+
+// static
int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) {
base::ThreadRestrictions::AssertIOAllowed();
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698