summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-02 13:59:08 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-02 13:59:08 +0000
commit0203ed716229301ebcd111f799ecf4367f5b437e (patch)
tree2d9fbcc24ff6cf157de31a8c6550a0da44d4d4d2
parent49751ba42c5fac56bbc2a1235ebc9586c4bf504c (diff)
downloadchromium_src-0203ed716229301ebcd111f799ecf4367f5b437e.zip
chromium_src-0203ed716229301ebcd111f799ecf4367f5b437e.tar.gz
chromium_src-0203ed716229301ebcd111f799ecf4367f5b437e.tar.bz2
We recently enabled reading sysctl values from inside the sandbox. This CL removes workarounds needed when sysctl reads where blocked.
Review URL: http://codereview.chromium.org/151202 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19809 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/sys_info.h12
-rw-r--r--base/sys_info_mac.cc36
-rw-r--r--base/sys_info_posix.cc2
-rw-r--r--chrome/renderer/renderer_main_platform_delegate_mac.mm4
4 files changed, 12 insertions, 42 deletions
diff --git a/base/sys_info.h b/base/sys_info.h
index 16b8690..d083377 100644
--- a/base/sys_info.h
+++ b/base/sys_info.h
@@ -14,8 +14,6 @@ namespace base {
class SysInfo {
public:
// Return the number of logical processors/cores on the current machine.
- // WARNING: On POSIX, this method uses static variables and is not threadsafe
- // until it's been initialized by being called once without a race.
static int NumberOfProcessors();
// Return the number of bytes of physical memory on the current machine.
@@ -46,8 +44,6 @@ class SysInfo {
static std::string OperatingSystemVersion();
// Retrieves detailed numeric values for the OS version.
- // WARNING: On OS X, this method uses static variables and is not threadsafe
- // until it's been initialized by being called once without a race.
// TODO(port): Implement a Linux version of this method and enable the
// corresponding unit test.
static void OperatingSystemVersionNumbers(int32 *major_version,
@@ -68,14 +64,6 @@ class SysInfo {
// Return the smallest amount of memory (in bytes) which the VM system will
// allocate.
static size_t VMAllocationGranularity();
-
-#if defined(OS_MACOSX)
- // Under the OS X Sandbox, our access to the system is limited, this call
- // caches the system info on startup before we turn the Sandbox on.
- // The above functions are all wired up to return the cached value so the rest
- // of the code can call them in the Sandbox without worrying.
- static void CacheSysInfo();
-#endif
};
} // namespace base
diff --git a/base/sys_info_mac.cc b/base/sys_info_mac.cc
index 2943066..caec74d 100644
--- a/base/sys_info_mac.cc
+++ b/base/sys_info_mac.cc
@@ -12,35 +12,21 @@ namespace base {
void SysInfo::OperatingSystemVersionNumbers(int32 *major_version,
int32 *minor_version,
int32 *bugfix_version) {
- static bool is_initialized = false;
- static int32 major_version_cached = 0;
- static int32 minor_version_cached = 0;
- static int32 bugfix_version_cached = 0;
-
- if (!is_initialized) {
- // Gestalt can't be called in the sandbox, so we cache its return value.
- Gestalt(gestaltSystemVersionMajor,
- reinterpret_cast<SInt32*>(&major_version_cached));
- Gestalt(gestaltSystemVersionMinor,
- reinterpret_cast<SInt32*>(&minor_version_cached));
- Gestalt(gestaltSystemVersionBugFix,
- reinterpret_cast<SInt32*>(&bugfix_version_cached));
- is_initialized = true;
- }
+ int32 major_version_cached = 0;
+ int32 minor_version_cached = 0;
+ int32 bugfix_version_cached = 0;
+
+ // Gestalt can't be called in the sandbox, so we cache its return value.
+ Gestalt(gestaltSystemVersionMajor,
+ reinterpret_cast<SInt32*>(&major_version_cached));
+ Gestalt(gestaltSystemVersionMinor,
+ reinterpret_cast<SInt32*>(&minor_version_cached));
+ Gestalt(gestaltSystemVersionBugFix,
+ reinterpret_cast<SInt32*>(&bugfix_version_cached));
*major_version = major_version_cached;
*minor_version = minor_version_cached;
*bugfix_version = bugfix_version_cached;
}
-// 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();
- int32 dummy;
- OperatingSystemVersionNumbers(&dummy, &dummy, &dummy);
-}
-
} // namespace base
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc
index 8a83f3c..388ccba 100644
--- a/base/sys_info_posix.cc
+++ b/base/sys_info_posix.cc
@@ -39,7 +39,7 @@ int SysInfo::NumberOfProcessors() {
#else
// It seems that sysconf returns the number of "logical" processors on both
// mac and linux. So we get the number of "online logical" processors.
- static long res = sysconf(_SC_NPROCESSORS_ONLN);
+ long res = sysconf(_SC_NPROCESSORS_ONLN);
if (res == -1) {
NOTREACHED();
return 1;
diff --git a/chrome/renderer/renderer_main_platform_delegate_mac.mm b/chrome/renderer/renderer_main_platform_delegate_mac.mm
index 9e86044d..b94c6f0 100644
--- a/chrome/renderer/renderer_main_platform_delegate_mac.mm
+++ b/chrome/renderer/renderer_main_platform_delegate_mac.mm
@@ -148,10 +148,6 @@ bool RendererMainPlatformDelegate::EnableSandbox() {
// succeed.
DebugUtil::BeingDebugged();
- // Cache the System info information, since we can't query certain attributes
- // with the Sandbox enabled.
- base::SysInfo::CacheSysInfo();
-
// For the renderer, we give it a custom sandbox to lock down as tight as
// possible, but still be able to draw.