summaryrefslogtreecommitdiffstats
path: root/base/mac
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-02 07:41:57 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-02 07:41:57 +0000
commitaaf93de4eaf0db4e110f6b47762ab3de9ef3848e (patch)
tree470730b81b6cde5f9351874285c9129280743fdd /base/mac
parenta11c1d7581fc932f0f05d39410502772189dd3c6 (diff)
downloadchromium_src-aaf93de4eaf0db4e110f6b47762ab3de9ef3848e.zip
chromium_src-aaf93de4eaf0db4e110f6b47762ab3de9ef3848e.tar.gz
chromium_src-aaf93de4eaf0db4e110f6b47762ab3de9ef3848e.tar.bz2
Update OS version functions.
BUG=none TEST=covered Review URL: https://codereview.chromium.org/25286002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226421 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/mac')
-rw-r--r--base/mac/mac_util.h29
-rw-r--r--base/mac/mac_util.mm25
-rw-r--r--base/mac/mac_util_unittest.mm28
3 files changed, 64 insertions, 18 deletions
diff --git a/base/mac/mac_util.h b/base/mac/mac_util.h
index 23b57ed..5f82f43 100644
--- a/base/mac/mac_util.h
+++ b/base/mac/mac_util.h
@@ -145,12 +145,22 @@ BASE_EXPORT bool IsOSLionOrLater();
// Mountain Lion is Mac OS X 10.8, Darwin 12.
BASE_EXPORT bool IsOSMountainLion();
+BASE_EXPORT bool IsOSMountainLionOrEarlier();
BASE_EXPORT bool IsOSMountainLionOrLater();
+// Mavericks is Mac OS X 10.9, Darwin 13.
+BASE_EXPORT bool IsOSMavericks();
+BASE_EXPORT bool IsOSMavericksOrLater();
+
// 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, or to log when the OS is newer than any known version.
-BASE_EXPORT bool IsOSLaterThanMountainLion_DontCallThis();
+BASE_EXPORT bool IsOSLaterThanMavericks_DontCallThis();
+
+// Inline functions that are redundant due to version ranges being mutually-
+// exclusive.
+inline bool IsOSLionOrEarlier() { return !IsOSMountainLionOrLater(); }
+inline bool IsOSMountainLionOrEarlier() { return !IsOSMavericksOrLater(); }
// When the deployment target is set, the code produced cannot run on earlier
// OS releases. That enables some of the IsOS* family to be implemented as
@@ -168,7 +178,6 @@ 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; }
#endif
#if defined(MAC_OS_X_VERSION_10_8) && \
@@ -181,9 +190,19 @@ inline bool IsOSMountainLionOrLater() { return true; }
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 IsOSLaterThanMountainLion_DontCallThis() {
- return true;
-}
+#endif
+
+#if defined(MAC_OS_X_VERSION_10_9) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
+#define BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9
+inline bool IsOSMavericksOrLater() { return true; }
+#endif
+
+#if defined(MAC_OS_X_VERSION_10_9) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9
+#define BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9
+inline bool IsOSMavericks() { return false; }
+inline bool IsOSLaterThanMavericks_DontCallThis() { return true; }
#endif
// Retrieve the system's model identifier string from the IOKit registry:
diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm
index 04311ec..dd65eee 100644
--- a/base/mac/mac_util.mm
+++ b/base/mac/mac_util.mm
@@ -610,6 +610,7 @@ enum {
SNOW_LEOPARD_MINOR_VERSION = 6,
LION_MINOR_VERSION = 7,
MOUNTAIN_LION_MINOR_VERSION = 8,
+ MAVERICKS_MINOR_VERSION = 9,
};
} // namespace
@@ -626,12 +627,6 @@ 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;
@@ -650,9 +645,21 @@ bool IsOSMountainLionOrLater() {
}
#endif
-#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_8)
-bool IsOSLaterThanMountainLion_DontCallThis() {
- return MacOSXMinorVersion() > MOUNTAIN_LION_MINOR_VERSION;
+#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9)
+bool IsOSMavericks() {
+ return MacOSXMinorVersion() == MAVERICKS_MINOR_VERSION;
+}
+#endif
+
+#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GE_10_9)
+bool IsOSMavericksOrLater() {
+ return MacOSXMinorVersion() >= MAVERICKS_MINOR_VERSION;
+}
+#endif
+
+#if !defined(BASE_MAC_MAC_UTIL_H_INLINED_GT_10_9)
+bool IsOSLaterThanMavericks_DontCallThis() {
+ return MacOSXMinorVersion() > MAVERICKS_MINOR_VERSION;
}
#endif
diff --git a/base/mac/mac_util_unittest.mm b/base/mac/mac_util_unittest.mm
index d246757..0688b5a 100644
--- a/base/mac/mac_util_unittest.mm
+++ b/base/mac/mac_util_unittest.mm
@@ -161,26 +161,46 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_TRUE(IsOSLionOrEarlier());
EXPECT_FALSE(IsOSLionOrLater());
EXPECT_FALSE(IsOSMountainLion());
+ EXPECT_TRUE(IsOSMountainLionOrEarlier());
EXPECT_FALSE(IsOSMountainLionOrLater());
- EXPECT_FALSE(IsOSLaterThanMountainLion_DontCallThis());
+ EXPECT_FALSE(IsOSMavericks());
+ EXPECT_FALSE(IsOSMavericksOrLater());
+ EXPECT_FALSE(IsOSLaterThanMavericks_DontCallThis());
} else if (minor == 7) {
EXPECT_FALSE(IsOSSnowLeopard());
EXPECT_TRUE(IsOSLion());
EXPECT_TRUE(IsOSLionOrEarlier());
EXPECT_TRUE(IsOSLionOrLater());
EXPECT_FALSE(IsOSMountainLion());
+ EXPECT_TRUE(IsOSMountainLionOrEarlier());
EXPECT_FALSE(IsOSMountainLionOrLater());
- EXPECT_FALSE(IsOSLaterThanMountainLion_DontCallThis());
+ EXPECT_FALSE(IsOSMavericks());
+ EXPECT_FALSE(IsOSMavericksOrLater());
+ EXPECT_FALSE(IsOSLaterThanMavericks_DontCallThis());
} else if (minor == 8) {
EXPECT_FALSE(IsOSSnowLeopard());
EXPECT_FALSE(IsOSLion());
EXPECT_FALSE(IsOSLionOrEarlier());
EXPECT_TRUE(IsOSLionOrLater());
EXPECT_TRUE(IsOSMountainLion());
+ EXPECT_TRUE(IsOSMountainLionOrEarlier());
EXPECT_TRUE(IsOSMountainLionOrLater());
- EXPECT_FALSE(IsOSLaterThanMountainLion_DontCallThis());
+ EXPECT_FALSE(IsOSMavericks());
+ EXPECT_FALSE(IsOSMavericksOrLater());
+ EXPECT_FALSE(IsOSLaterThanMavericks_DontCallThis());
+ } else if (minor == 9) {
+ EXPECT_FALSE(IsOSSnowLeopard());
+ EXPECT_FALSE(IsOSLion());
+ EXPECT_FALSE(IsOSLionOrEarlier());
+ EXPECT_TRUE(IsOSLionOrLater());
+ EXPECT_FALSE(IsOSMountainLion());
+ EXPECT_FALSE(IsOSMountainLionOrEarlier());
+ EXPECT_TRUE(IsOSMountainLionOrLater());
+ EXPECT_TRUE(IsOSMavericks());
+ EXPECT_TRUE(IsOSMavericksOrLater());
+ EXPECT_FALSE(IsOSLaterThanMavericks_DontCallThis());
} else {
- // Not five, six, seven, or eight. Ah, ah, ah.
+ // Not five, six, seven, eight, or nine. Ah, ah, ah.
EXPECT_TRUE(false);
}
} else {