Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Unified Diff: base/sys_info_mac.cc

Issue 27088: Additional fix for Sandboxed WebKit on OS X. (Closed)
Patch Set: Fixes Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/sys_info_mac.cc
diff --git a/base/sys_info_mac.cc b/base/sys_info_mac.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6774871ece949d9ac611fb656fb08a5bd56e328c
--- /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
« base/sys_info.h ('K') | « base/sys_info.h ('k') | base/sys_info_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698