diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-14 19:58:22 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-14 19:58:22 +0000 |
commit | b1e697e81697c8c597470365432c746dbbc5c9c1 (patch) | |
tree | 8e1d62650a4acc5856d28dac889b62294ad86a6d /base/mac | |
parent | 81d8f81db11746c21c409bd1a79a53ed680cacec (diff) | |
download | chromium_src-b1e697e81697c8c597470365432c746dbbc5c9c1.zip chromium_src-b1e697e81697c8c597470365432c746dbbc5c9c1.tar.gz chromium_src-b1e697e81697c8c597470365432c746dbbc5c9c1.tar.bz2 |
[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
Diffstat (limited to 'base/mac')
-rw-r--r-- | base/mac/mac_util.h | 25 | ||||
-rw-r--r-- | base/mac/mac_util.mm | 29 | ||||
-rw-r--r-- | base/mac/mac_util_unittest.mm | 32 |
3 files changed, 82 insertions, 4 deletions
diff --git a/base/mac/mac_util.h b/base/mac/mac_util.h index 4fefe6c..3d50d61 100644 --- a/base/mac/mac_util.h +++ b/base/mac/mac_util.h @@ -138,11 +138,19 @@ BASE_EXPORT bool IsOSSnowLeopardOrLater(); // Lion is Mac OS X 10.7, Darwin 11. BASE_EXPORT bool IsOSLion(); +BASE_EXPORT bool IsOSLionOrEarlier(); 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 // codepaths that are very likely to break on future (unreleased, untested, // unborn) OS releases. +BASE_EXPORT + bool IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement(); +// TODO(rsesek|avi): Remove when allocators gonna allocate. BASE_EXPORT bool IsOSLaterThanLion(); // When the deployment target is set, the code produced cannot run on earlier @@ -170,9 +178,26 @@ inline bool IsOSLionOrLater() { return true; } MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_7 #define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_7 inline bool IsOSLion() { return false; } +inline bool IsOSLionOrEarlier() { return false; } inline bool IsOSLaterThanLion() { 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_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: // for example, "MacPro4,1", "MacBookPro6,1". Returns empty string upon // failure. diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm index 1240906..41d76a2 100644 --- a/base/mac/mac_util.mm +++ b/base/mac/mac_util.mm @@ -554,7 +554,7 @@ int MacOSXMinorVersionInternal() { // immediate death. CHECK(darwin_major_version >= 6); 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(mac_os_x_minor_version); @@ -571,7 +571,8 @@ int MacOSXMinorVersion() { enum { LEOPARD_MINOR_VERSION = 5, SNOW_LEOPARD_MINOR_VERSION = 6, - LION_MINOR_VERSION = 7 + LION_MINOR_VERSION = 7, + MOUNTAIN_LION_MINOR_VERSION = 8, }; } // namespace @@ -612,6 +613,12 @@ bool IsOSLion() { } #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) bool IsOSLionOrLater() { return MacOSXMinorVersion() >= LION_MINOR_VERSION; @@ -624,6 +631,24 @@ bool IsOSLaterThanLion() { } #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 { // ScopedGenericObj functor for IOObjectRelease(). diff --git a/base/mac/mac_util_unittest.mm b/base/mac/mac_util_unittest.mm index 966d8ed..d7f2b3d 100644 --- a/base/mac/mac_util_unittest.mm +++ b/base/mac/mac_util_unittest.mm @@ -158,7 +158,12 @@ TEST_F(MacUtilTest, IsOSEllipsis) { EXPECT_TRUE(IsOSSnowLeopardOrEarlier()); EXPECT_FALSE(IsOSSnowLeopardOrLater()); EXPECT_FALSE(IsOSLion()); + EXPECT_TRUE(IsOSLionOrEarlier()); EXPECT_FALSE(IsOSLionOrLater()); + EXPECT_FALSE(IsOSMountainLion()); + EXPECT_FALSE(IsOSMountainLionOrLater()); + EXPECT_FALSE( + IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement()); EXPECT_FALSE(IsOSLaterThanLion()); } else if (minor == 6) { EXPECT_FALSE(IsOSLeopard()); @@ -167,7 +172,12 @@ TEST_F(MacUtilTest, IsOSEllipsis) { EXPECT_TRUE(IsOSSnowLeopardOrEarlier()); EXPECT_TRUE(IsOSSnowLeopardOrLater()); EXPECT_FALSE(IsOSLion()); + EXPECT_TRUE(IsOSLionOrEarlier()); EXPECT_FALSE(IsOSLionOrLater()); + EXPECT_FALSE(IsOSMountainLion()); + EXPECT_FALSE(IsOSMountainLionOrLater()); + EXPECT_FALSE( + IsOSDangerouslyLaterThanMountainLionForUseByCFAllocatorReplacement()); EXPECT_FALSE(IsOSLaterThanLion()); } else if (minor == 7) { EXPECT_FALSE(IsOSLeopard()); @@ -176,10 +186,28 @@ TEST_F(MacUtilTest, IsOSEllipsis) { EXPECT_FALSE(IsOSSnowLeopardOrEarlier()); EXPECT_TRUE(IsOSSnowLeopardOrLater()); EXPECT_TRUE(IsOSLion()); + EXPECT_TRUE(IsOSLionOrEarlier()); 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 { - // Not five, six, or seven. Ah, ah, ah. + // Not five, six, seven, or eight. Ah, ah, ah. EXPECT_TRUE(false); } } else { |