summaryrefslogtreecommitdiffstats
path: root/base/sys_info_posix.cc
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 02:01:51 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 02:01:51 +0000
commit59658423f8a374ac79bd8abb122c87ee8c9b8685 (patch)
tree56cf53acd0e91bf33a9e1f7b2cf67e7a5af82f64 /base/sys_info_posix.cc
parente5a3ea33e830593b16f140429896940be276f1ca (diff)
downloadchromium_src-59658423f8a374ac79bd8abb122c87ee8c9b8685.zip
chromium_src-59658423f8a374ac79bd8abb122c87ee8c9b8685.tar.gz
chromium_src-59658423f8a374ac79bd8abb122c87ee8c9b8685.tar.bz2
Under the OS X Sandbox, some system calls are blocked.
This CL adds a facility to cache system info values on renderer startup. Review URL: http://codereview.chromium.org/20250 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9545 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/sys_info_posix.cc')
-rw-r--r--base/sys_info_posix.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc
index 9ea3cab..b46d1b4 100644
--- a/base/sys_info_posix.cc
+++ b/base/sys_info_posix.cc
@@ -24,7 +24,7 @@ namespace base {
int SysInfo::NumberOfProcessors() {
// It seems that sysconf returns the number of "logical" processors on both
// mac and linux. So we get the number of "online logical" processors.
- long res = sysconf(_SC_NPROCESSORS_ONLN);
+ static long res = sysconf(_SC_NPROCESSORS_ONLN);
if (res == -1) {
NOTREACHED();
return 1;
@@ -48,7 +48,7 @@ int64 SysInfo::AmountOfPhysicalMemory() {
NOTREACHED();
return 0;
}
-
+
return static_cast<int64>(hostinfo.max_mem);
#else
long pages = sysconf(_SC_PHYS_PAGES);
@@ -134,4 +134,13 @@ size_t SysInfo::VMAllocationGranularity() {
return getpagesize();
}
+// static
+void SysInfo::CacheSysInfo() {
+ // Due to startup time concerns [premature optimization?] we only cache values
+ // from functions we know to be called in the renderer & fail when the sandbox
+ // is enabled.
+ NumberOfProcessors();
+
+}
+
} // namespace base