michael@0: // Copyright (c) 2009 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #include "base/sys_info.h" michael@0: michael@0: #include michael@0: michael@0: namespace base { michael@0: michael@0: // static michael@0: void SysInfo::OperatingSystemVersionNumbers(int32_t *major_version, michael@0: int32_t *minor_version, michael@0: int32_t *bugfix_version) { michael@0: static bool is_initialized = false; michael@0: static int32_t major_version_cached = 0; michael@0: static int32_t minor_version_cached = 0; michael@0: static int32_t bugfix_version_cached = 0; michael@0: michael@0: if (!is_initialized) { michael@0: // Gestalt can't be called in the sandbox, so we cache its return value. michael@0: Gestalt(gestaltSystemVersionMajor, michael@0: reinterpret_cast(&major_version_cached)); michael@0: Gestalt(gestaltSystemVersionMinor, michael@0: reinterpret_cast(&minor_version_cached)); michael@0: Gestalt(gestaltSystemVersionBugFix, michael@0: reinterpret_cast(&bugfix_version_cached)); michael@0: is_initialized = true; michael@0: } michael@0: michael@0: *major_version = major_version_cached; michael@0: *minor_version = minor_version_cached; michael@0: *bugfix_version = bugfix_version_cached; michael@0: } michael@0: michael@0: // static michael@0: void SysInfo::CacheSysInfo() { michael@0: // Due to startup time concerns [premature optimization?] we only cache values michael@0: // from functions we know to be called in the renderer & fail when the sandbox michael@0: // is enabled. michael@0: NumberOfProcessors(); michael@0: int32_t dummy; michael@0: OperatingSystemVersionNumbers(&dummy, &dummy, &dummy); michael@0: } michael@0: michael@0: } // namespace base