OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/sys_info.h" |
| 6 |
| 7 #include "CoreServices/CoreServices.h" |
| 8 |
| 9 namespace base { |
| 10 |
| 11 // static |
| 12 void SysInfo::OperatingSystemVersionNumbers(int32 *major_version, |
| 13 int32 *minor_version, |
| 14 int32 *bugfix_version) { |
| 15 static bool is_initialized = false; |
| 16 static int32 major_version_cached = 0; |
| 17 static int32 minor_version_cached = 0; |
| 18 static int32 bugfix_version_cached = 0; |
| 19 |
| 20 if (!is_initialized) { |
| 21 // Gestalt can't be called in the sandbox, so we cache its return value. |
| 22 Gestalt(gestaltSystemVersionMajor, |
| 23 reinterpret_cast<SInt32*>(&major_version_cached)); |
| 24 Gestalt(gestaltSystemVersionMinor, |
| 25 reinterpret_cast<SInt32*>(&minor_version_cached)); |
| 26 Gestalt(gestaltSystemVersionBugFix, |
| 27 reinterpret_cast<SInt32*>(&bugfix_version_cached)); |
| 28 is_initialized = true; |
| 29 } |
| 30 |
| 31 *major_version = major_version_cached; |
| 32 *minor_version = minor_version_cached; |
| 33 *bugfix_version = bugfix_version_cached; |
| 34 } |
| 35 |
| 36 // static |
| 37 void SysInfo::CacheSysInfo() { |
| 38 // Due to startup time concerns [premature optimization?] we only cache values |
| 39 // from functions we know to be called in the renderer & fail when the sandbox |
| 40 // is enabled. |
| 41 NumberOfProcessors(); |
| 42 int32 dummy; |
| 43 OperatingSystemVersionNumbers(&dummy, &dummy, &dummy); |
| 44 } |
| 45 |
| 46 } // namespace base |
OLD | NEW |