From 0203ed716229301ebcd111f799ecf4367f5b437e Mon Sep 17 00:00:00 2001 From: "jeremy@chromium.org" Date: Thu, 2 Jul 2009 13:59:08 +0000 Subject: 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 --- base/sys_info.h | 12 -------- base/sys_info_mac.cc | 36 +++++++--------------- base/sys_info_posix.cc | 2 +- .../renderer_main_platform_delegate_mac.mm | 4 --- 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(&major_version_cached)); - Gestalt(gestaltSystemVersionMinor, - reinterpret_cast(&minor_version_cached)); - Gestalt(gestaltSystemVersionBugFix, - reinterpret_cast(&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(&major_version_cached)); + Gestalt(gestaltSystemVersionMinor, + reinterpret_cast(&minor_version_cached)); + Gestalt(gestaltSystemVersionBugFix, + reinterpret_cast(&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. -- cgit v1.1