Commit b1e697e8 authored by rsesek@chromium.org's avatar rsesek@chromium.org

[Mac] Add the OS version check functions for 10.8.

BUG=none
TEST=Careful review by Mark. And a unittest.


Review URL: http://codereview.chromium.org/9706001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126709 0039d316-1c4b-4281-b951-d872f2087c98
parent 81d8f81d
...@@ -138,11 +138,19 @@ BASE_EXPORT bool IsOSSnowLeopardOrLater(); ...@@ -138,11 +138,19 @@ BASE_EXPORT bool IsOSSnowLeopardOrLater();
// Lion is Mac OS X 10.7, Darwin 11. // Lion is Mac OS X 10.7, Darwin 11.
BASE_EXPORT bool IsOSLion(); BASE_EXPORT bool IsOSLion();
BASE_EXPORT bool IsOSLionOrEarlier();
BASE_EXPORT bool IsOSLionOrLater(); BASE_EXPORT bool IsOSLionOrLater();
// Mountain Lion is Mac OS X 10.8, Darwin 12.
BASE_EXPORT bool IsOSMountainLion();
BASE_EXPORT bool IsOSMountainLionOrLater();
// This should be infrequently used. It only makes sense to use this to avoid // This should be infrequently used. It only makes sense to use this to avoid
// codepaths that are very likely to break on future (unreleased, untested, // codepaths that are very likely to break on future (unreleased, untested,
// unborn) OS releases. // unborn) OS releases.
BASE_EXPORT
bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement();
// TODO(rsesek|avi): Remove when allocators gonna allocate.
BASE_EXPORT bool IsOSLaterThanLion(); BASE_EXPORT bool IsOSLaterThanLion();
// When the deployment target is set, the code produced cannot run on earlier // When the deployment target is set, the code produced cannot run on earlier
...@@ -170,9 +178,26 @@ inline bool IsOSLionOrLater() { return true; } ...@@ -170,9 +178,26 @@ inline bool IsOSLionOrLater() { return true; }
MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_7 MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_7
#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7
inline bool IsOSLion() { return false; } inline bool IsOSLion() { return false; }
inline bool IsOSLionOrEarlier() { return false; }
inline bool IsOSLaterThanLion() { return true; } inline bool IsOSLaterThanLion() { return true; }
#endif #endif
#if defined(MAC_OS_X_VERSION_10_8) && \
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
#define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_8
inline bool IsOSMountainLionOrLater() { return true; }
#endif
#if defined(MAC_OS_X_VERSION_10_8) && \
MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_8
#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8
inline bool IsOSMountainLion() { return false; }
inline bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement()
{
return true;
}
#endif
// Retrieve the system's model identifier string from the IOKit registry: // Retrieve the system's model identifier string from the IOKit registry:
// for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon
// failure. // failure.
......
...@@ -554,7 +554,7 @@ int MacOSXMinorVersionInternal() { ...@@ -554,7 +554,7 @@ int MacOSXMinorVersionInternal() {
// immediate death. // immediate death.
CHECK(darwin_major_version >= 6); CHECK(darwin_major_version >= 6);
int mac_os_x_minor_version = darwin_major_version - 4; int mac_os_x_minor_version = darwin_major_version - 4;
DLOG_IF(WARNING, darwin_major_version > 11) << "Assuming Darwin " DLOG_IF(WARNING, darwin_major_version > 12) << "Assuming Darwin "
<< base::IntToString(darwin_major_version) << " is Mac OS X 10." << base::IntToString(darwin_major_version) << " is Mac OS X 10."
<< base::IntToString(mac_os_x_minor_version); << base::IntToString(mac_os_x_minor_version);
...@@ -571,7 +571,8 @@ int MacOSXMinorVersion() { ...@@ -571,7 +571,8 @@ int MacOSXMinorVersion() {
enum { enum {
LEOPARD_MINOR_VERSION = 5, LEOPARD_MINOR_VERSION = 5,
SNOW_LEOPARD_MINOR_VERSION = 6, SNOW_LEOPARD_MINOR_VERSION = 6,
LION_MINOR_VERSION = 7 LION_MINOR_VERSION = 7,
MOUNTAIN_LION_MINOR_VERSION = 8,
}; };
} // namespace } // namespace
...@@ -612,6 +613,12 @@ bool IsOSLion() { ...@@ -612,6 +613,12 @@ bool IsOSLion() {
} }
#endif #endif
#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7)
bool IsOSLionOrEarlier() {
return MacOSXMinorVersion() <= LION_MINOR_VERSION;
}
#endif
#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7) #if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_7)
bool IsOSLionOrLater() { bool IsOSLionOrLater() {
return MacOSXMinorVersion() >= LION_MINOR_VERSION; return MacOSXMinorVersion() >= LION_MINOR_VERSION;
...@@ -624,6 +631,24 @@ bool IsOSLaterThanLion() { ...@@ -624,6 +631,24 @@ bool IsOSLaterThanLion() {
} }
#endif #endif
#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8)
bool IsOSMountainLion() {
return MacOSXMinorVersion() == MOUNTAIN_LION_MINOR_VERSION;
}
#endif
#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_8)
bool IsOSMountainLionOrLater() {
return MacOSXMinorVersion() >= MOUNTAIN_LION_MINOR_VERSION;
}
#endif
#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8)
bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement() {
return MacOSXMinorVersion() > MOUNTAIN_LION_MINOR_VERSION;
}
#endif
namespace { namespace {
// ScopedGenericObj functor for IOObjectRelease(). // ScopedGenericObj functor for IOObjectRelease().
......
...@@ -158,7 +158,12 @@ TEST_F(MacUtilTest, IsOSEllipsis) { ...@@ -158,7 +158,12 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_TRUE(IsOSSnowLeopardOrEarlier()); EXPECT_TRUE(IsOSSnowLeopardOrEarlier());
EXPECT_FALSE(IsOSSnowLeopardOrLater()); EXPECT_FALSE(IsOSSnowLeopardOrLater());
EXPECT_FALSE(IsOSLion()); EXPECT_FALSE(IsOSLion());
EXPECT_TRUE(IsOSLionOrEarlier());
EXPECT_FALSE(IsOSLionOrLater()); EXPECT_FALSE(IsOSLionOrLater());
EXPECT_FALSE(IsOSMountainLion());
EXPECT_FALSE(IsOSMountainLionOrLater());
EXPECT_FALSE(
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
EXPECT_FALSE(IsOSLaterThanLion()); EXPECT_FALSE(IsOSLaterThanLion());
} else if (minor == 6) { } else if (minor == 6) {
EXPECT_FALSE(IsOSLeopard()); EXPECT_FALSE(IsOSLeopard());
...@@ -167,7 +172,12 @@ TEST_F(MacUtilTest, IsOSEllipsis) { ...@@ -167,7 +172,12 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_TRUE(IsOSSnowLeopardOrEarlier()); EXPECT_TRUE(IsOSSnowLeopardOrEarlier());
EXPECT_TRUE(IsOSSnowLeopardOrLater()); EXPECT_TRUE(IsOSSnowLeopardOrLater());
EXPECT_FALSE(IsOSLion()); EXPECT_FALSE(IsOSLion());
EXPECT_TRUE(IsOSLionOrEarlier());
EXPECT_FALSE(IsOSLionOrLater()); EXPECT_FALSE(IsOSLionOrLater());
EXPECT_FALSE(IsOSMountainLion());
EXPECT_FALSE(IsOSMountainLionOrLater());
EXPECT_FALSE(
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
EXPECT_FALSE(IsOSLaterThanLion()); EXPECT_FALSE(IsOSLaterThanLion());
} else if (minor == 7) { } else if (minor == 7) {
EXPECT_FALSE(IsOSLeopard()); EXPECT_FALSE(IsOSLeopard());
...@@ -176,10 +186,28 @@ TEST_F(MacUtilTest, IsOSEllipsis) { ...@@ -176,10 +186,28 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_FALSE(IsOSSnowLeopardOrEarlier()); EXPECT_FALSE(IsOSSnowLeopardOrEarlier());
EXPECT_TRUE(IsOSSnowLeopardOrLater()); EXPECT_TRUE(IsOSSnowLeopardOrLater());
EXPECT_TRUE(IsOSLion()); EXPECT_TRUE(IsOSLion());
EXPECT_TRUE(IsOSLionOrEarlier());
EXPECT_TRUE(IsOSLionOrLater()); EXPECT_TRUE(IsOSLionOrLater());
EXPECT_FALSE(IsOSLaterThanLion()); EXPECT_FALSE(IsOSMountainLion());
EXPECT_FALSE(IsOSMountainLionOrLater());
EXPECT_FALSE(
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
} else if (minor == 8) {
EXPECT_FALSE(IsOSLeopard());
EXPECT_FALSE(IsOSLeopardOrEarlier());
EXPECT_FALSE(IsOSSnowLeopard());
EXPECT_FALSE(IsOSSnowLeopardOrEarlier());
EXPECT_TRUE(IsOSSnowLeopardOrLater());
EXPECT_FALSE(IsOSLion());
EXPECT_FALSE(IsOSLionOrEarlier());
EXPECT_TRUE(IsOSLionOrLater());
EXPECT_TRUE(IsOSMountainLion());
EXPECT_TRUE(IsOSMountainLionOrLater());
EXPECT_FALSE(
IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement());
EXPECT_TRUE(IsOSLaterThanLion());
} else { } else {
// Not five, six, or seven. Ah, ah, ah. // Not five, six, seven, or eight. Ah, ah, ah.
EXPECT_TRUE(false); EXPECT_TRUE(false);
} }
} else { } else {
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -718,6 +718,7 @@ void oom_killer_new() { ...@@ -718,6 +718,7 @@ void oom_killer_new() {
// === Core Foundation CFAllocators === // === Core Foundation CFAllocators ===
bool CanGetContextForCFAllocator() { bool CanGetContextForCFAllocator() {
// TODO(rsesek|avi): See mac_util.h:153 for removing/updating this.
return !base::mac::IsOSLaterThanLion(); return !base::mac::IsOSLaterThanLion();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment