diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-24 15:40:38 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-24 15:40:38 +0000 |
commit | 4cc015107e2fcc166da1d9d0debfa3e48f30192c (patch) | |
tree | 92866130e7dec74b6b4ed60b143f864ad52147c0 /base/sys_info_mac.cc | |
parent | 3e9f7fc1bbd90e6e439180e9cedcc48dc7ac9924 (diff) | |
download | chromium_src-4cc015107e2fcc166da1d9d0debfa3e48f30192c.zip chromium_src-4cc015107e2fcc166da1d9d0debfa3e48f30192c.tar.gz chromium_src-4cc015107e2fcc166da1d9d0debfa3e48f30192c.tar.bz2 |
Fix for Sandboxed WebKit on OS X:
* Cache Gestalt's value since it opens files.
* Do a little cleanup in sys_info while I'm there and add a unit test.
* Label some methods as not being threadsafe on OSX/POSIX.
Review URL: http://codereview.chromium.org/27088
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/sys_info_mac.cc')
-rw-r--r-- | base/sys_info_mac.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/base/sys_info_mac.cc b/base/sys_info_mac.cc new file mode 100644 index 0000000..cd93ce9 --- /dev/null +++ b/base/sys_info_mac.cc @@ -0,0 +1,46 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/sys_info.h" + +#include <CoreServices/CoreServices.h> + +namespace base { + +// static +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; + } + + *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 |