summaryrefslogtreecommitdiffstats
path: root/base/sys_info_posix.cc
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-08 23:19:16 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-08 23:19:16 +0000
commit275a29deaf8a70834e4c5dc7d2f9458bedd80154 (patch)
treeabd2741729a3d672a83b45043227331c45f754bc /base/sys_info_posix.cc
parent2993010b5f527912cea918a16fad4cc7b5ded5dc (diff)
downloadchromium_src-275a29deaf8a70834e4c5dc7d2f9458bedd80154.zip
chromium_src-275a29deaf8a70834e4c5dc7d2f9458bedd80154.tar.gz
chromium_src-275a29deaf8a70834e4c5dc7d2f9458bedd80154.tar.bz2
Expose the virtual memory limit to blink
V8 queries the limit before sandbox initialization via static initializers. We should pass it in like the other memory related values instead. BUG=none R=mark@chromium.org Review URL: https://codereview.chromium.org/227113011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/sys_info_posix.cc')
-rw-r--r--base/sys_info_posix.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc
index 07d08b7..90baa69 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();