Chromium Code Reviews| Index: base/sys_info_mac.mm |
| diff --git a/base/sys_info_mac.cc b/base/sys_info_mac.mm |
| similarity index 72% |
| rename from base/sys_info_mac.cc |
| rename to base/sys_info_mac.mm |
| index ff1ec5c1e69bb8b1cdce2eb08fc1db703c780402..08d7aaf3094266b95249083af40b3da33a9ea775 100644 |
| --- a/base/sys_info_mac.cc |
| +++ b/base/sys_info_mac.mm |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| @@ -6,6 +6,7 @@ |
| #include <ApplicationServices/ApplicationServices.h> |
| #include <CoreServices/CoreServices.h> |
| +#import <Foundation/Foundation.h> |
| #include <mach/mach_host.h> |
| #include <mach/mach_init.h> |
| #include <stddef.h> |
| @@ -14,7 +15,9 @@ |
| #include <sys/types.h> |
| #include "base/logging.h" |
| +#include "base/mac/mac_util.h" |
| #include "base/mac/scoped_mach_port.h" |
| +#import "base/mac/sdk_forward_declarations.h" |
| #include "base/macros.h" |
| #include "base/strings/stringprintf.h" |
| @@ -36,12 +39,24 @@ std::string SysInfo::OperatingSystemVersion() { |
| void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version, |
| int32_t* minor_version, |
| int32_t* bugfix_version) { |
| - Gestalt(gestaltSystemVersionMajor, |
| - reinterpret_cast<SInt32*>(major_version)); |
| - Gestalt(gestaltSystemVersionMinor, |
| - reinterpret_cast<SInt32*>(minor_version)); |
| - Gestalt(gestaltSystemVersionBugFix, |
| - reinterpret_cast<SInt32*>(bugfix_version)); |
| + NSProcessInfo* processInfo = [NSProcessInfo processInfo]; |
| + if ([processInfo respondsToSelector:@selector(operatingSystemVersion)]) { |
|
Nico
2016/03/31 13:59:16
Didn't someone say yesterday that this silently wo
|
| + NSOperatingSystemVersion version = [processInfo operatingSystemVersion]; |
| + *major_version = version.majorVersion; |
| + *minor_version = version.minorVersion; |
| + *bugfix_version = version.patchVersion; |
| + } else { |
| + DCHECK(base::mac::IsOSMavericks()); |
| +#pragma clang diagnostic push |
|
Nico
2016/03/31 14:07:41
Cool, can you add a comment here explaining why it
tapted
2016/03/31 18:07:40
Done. Added:
// -[NSProcessInfo operatingSyst
|
| +#pragma clang diagnostic ignored "-Wdeprecated-declarations" |
| + Gestalt(gestaltSystemVersionMajor, |
| + reinterpret_cast<SInt32*>(major_version)); |
| + Gestalt(gestaltSystemVersionMinor, |
| + reinterpret_cast<SInt32*>(minor_version)); |
| + Gestalt(gestaltSystemVersionBugFix, |
| + reinterpret_cast<SInt32*>(bugfix_version)); |
| +#pragma clang diagnostic pop |
| + } |
| } |
| // static |