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