ipc/chromium/src/base/sys_info_mac.cc

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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.
     5 #include "base/sys_info.h"
     7 #include <CoreServices/CoreServices.h>
     9 namespace base {
    11 // static
    12 void SysInfo::OperatingSystemVersionNumbers(int32_t *major_version,
    13                                             int32_t *minor_version,
    14                                             int32_t *bugfix_version) {
    15   static bool is_initialized = false;
    16   static int32_t major_version_cached = 0;
    17   static int32_t minor_version_cached = 0;
    18   static int32_t bugfix_version_cached = 0;
    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   }
    31   *major_version = major_version_cached;
    32   *minor_version = minor_version_cached;
    33   *bugfix_version = bugfix_version_cached;
    34 }
    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_t dummy;
    43   OperatingSystemVersionNumbers(&dummy, &dummy, &dummy);
    44 }
    46 }  // namespace base

mercurial