ipc/chromium/src/base/sys_info_mac.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/base/sys_info_mac.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,46 @@
     1.4 +// Copyright (c) 2009 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#include "base/sys_info.h"
     1.9 +
    1.10 +#include <CoreServices/CoreServices.h>
    1.11 +
    1.12 +namespace base {
    1.13 +
    1.14 +// static
    1.15 +void SysInfo::OperatingSystemVersionNumbers(int32_t *major_version,
    1.16 +                                            int32_t *minor_version,
    1.17 +                                            int32_t *bugfix_version) {
    1.18 +  static bool is_initialized = false;
    1.19 +  static int32_t major_version_cached = 0;
    1.20 +  static int32_t minor_version_cached = 0;
    1.21 +  static int32_t bugfix_version_cached = 0;
    1.22 +
    1.23 +  if (!is_initialized) {
    1.24 +    // Gestalt can't be called in the sandbox, so we cache its return value.
    1.25 +    Gestalt(gestaltSystemVersionMajor,
    1.26 +        reinterpret_cast<SInt32*>(&major_version_cached));
    1.27 +    Gestalt(gestaltSystemVersionMinor,
    1.28 +        reinterpret_cast<SInt32*>(&minor_version_cached));
    1.29 +    Gestalt(gestaltSystemVersionBugFix,
    1.30 +        reinterpret_cast<SInt32*>(&bugfix_version_cached));
    1.31 +    is_initialized = true;
    1.32 +  }
    1.33 +
    1.34 +  *major_version = major_version_cached;
    1.35 +  *minor_version = minor_version_cached;
    1.36 +  *bugfix_version = bugfix_version_cached;
    1.37 +}
    1.38 +
    1.39 +// static
    1.40 +void SysInfo::CacheSysInfo() {
    1.41 +  // Due to startup time concerns [premature optimization?] we only cache values
    1.42 +  // from functions we know to be called in the renderer & fail when the sandbox
    1.43 +  // is enabled.
    1.44 +  NumberOfProcessors();
    1.45 +  int32_t dummy;
    1.46 +  OperatingSystemVersionNumbers(&dummy, &dummy, &dummy);
    1.47 +}
    1.48 +
    1.49 +}  // namespace base

mercurial