Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/sys_info.h" | 5 #include "base/sys_info.h" |
| 6 | 6 |
| 7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
| 8 | 8 |
| 9 namespace base { | 9 namespace base { |
| 10 | 10 |
| 11 // static | 11 // static |
| 12 void SysInfo::OperatingSystemVersionNumbers(int32 *major_version, | 12 void SysInfo::OperatingSystemVersionNumbers(int32 *major_version, |
| 13 int32 *minor_version, | 13 int32 *minor_version, |
| 14 int32 *bugfix_version) { | 14 int32 *bugfix_version) { |
| 15 static bool is_initialized = false; | 15 int32 major_version_cached = 0; |
|
Mark Mentovai
2009/07/02 14:58:06
These shouldn't be called whatever_cached anymore.
| |
| 16 static int32 major_version_cached = 0; | 16 int32 minor_version_cached = 0; |
| 17 static int32 minor_version_cached = 0; | 17 int32 bugfix_version_cached = 0; |
| 18 static int32 bugfix_version_cached = 0; | |
| 19 | 18 |
| 20 if (!is_initialized) { | 19 // Gestalt can't be called in the sandbox, so we cache its return value. |
| 21 // Gestalt can't be called in the sandbox, so we cache its return value. | 20 Gestalt(gestaltSystemVersionMajor, |
| 22 Gestalt(gestaltSystemVersionMajor, | 21 reinterpret_cast<SInt32*>(&major_version_cached)); |
| 23 reinterpret_cast<SInt32*>(&major_version_cached)); | 22 Gestalt(gestaltSystemVersionMinor, |
| 24 Gestalt(gestaltSystemVersionMinor, | 23 reinterpret_cast<SInt32*>(&minor_version_cached)); |
| 25 reinterpret_cast<SInt32*>(&minor_version_cached)); | 24 Gestalt(gestaltSystemVersionBugFix, |
| 26 Gestalt(gestaltSystemVersionBugFix, | 25 reinterpret_cast<SInt32*>(&bugfix_version_cached)); |
| 27 reinterpret_cast<SInt32*>(&bugfix_version_cached)); | |
| 28 is_initialized = true; | |
| 29 } | |
| 30 | 26 |
| 31 *major_version = major_version_cached; | 27 *major_version = major_version_cached; |
| 32 *minor_version = minor_version_cached; | 28 *minor_version = minor_version_cached; |
| 33 *bugfix_version = bugfix_version_cached; | 29 *bugfix_version = bugfix_version_cached; |
| 34 } | 30 } |
| 35 | 31 |
| 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 | 32 } // namespace base |
| OLD | NEW |