Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Unified Diff: base/sys_info_mac.mm

Issue 1842213002: Mac: Avoid deprecated use of ::Gestalt() in base/sys_info_mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20160329-Mac-DeploymentTarget
Patch Set: comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/sys_info_mac.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_mac.mm
diff --git a/base/sys_info_mac.cc b/base/sys_info_mac.mm
similarity index 66%
rename from base/sys_info_mac.cc
rename to base/sys_info_mac.mm
index ff1ec5c1e69bb8b1cdce2eb08fc1db703c780402..b44bb5bbe29ac186a9392db4889728ed5e09ca4f 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,29 @@ 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)]) {
+ NSOperatingSystemVersion version = [processInfo operatingSystemVersion];
+ *major_version = version.majorVersion;
+ *minor_version = version.minorVersion;
+ *bugfix_version = version.patchVersion;
+ } else {
+ // -[NSProcessInfo operatingSystemVersion] is documented available in 10.10.
+ // It's also available via a private API since 10.9.2. For the remaining
+ // cases in 10.9, rely on ::Gestalt(..). This can be removed once 10.9 is no
Nico 2016/03/31 19:42:19 Maybe replace last sentence with "Since this code
tapted 2016/03/31 20:44:23 Done.
+ // longer supported. Gestalt was deprecated in 10.8, so suppress the
+ // deprecation warning.
+ DCHECK(base::mac::IsOSMavericks());
+#pragma clang diagnostic push
+#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
« no previous file with comments | « base/sys_info_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698