0

mac: Remove IsOSMavericksOrLater()

BUG=579255
R=erikchen@chromium.org,thakis@chromium.org
TBR=brettw@chromium.org

Review-Url: https://codereview.chromium.org/2137453003
Cr-Commit-Position: refs/heads/master@{#404534}
This commit is contained in:
mark
2016-07-08 16:41:23 -07:00
committed by Commit bot
parent bf462ea0de
commit dd7e82fd75
10 changed files with 10 additions and 158 deletions

@ -115,7 +115,6 @@ BASE_EXPORT bool RemoveQuarantineAttribute(const FilePath& file_path);
// Mavericks is OS X 10.9, Darwin 13.
BASE_EXPORT bool IsOSMavericks();
BASE_EXPORT bool IsOSMavericksOrLater();
// Yosemite is OS X 10.10, Darwin 14.
BASE_EXPORT bool IsOSYosemite();
@ -146,12 +145,6 @@ inline bool IsOSElCapitanOrEarlier() { return !IsOSSierraOrLater(); }
// constant-value inline functions. The MAC_OS_X_VERSION_MIN_REQUIRED macro
// contains the value of the deployment target.
#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

@ -470,12 +470,6 @@ bool IsOSMavericks() {
}
#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_10)
bool IsOSYosemite() {
return MacOSXMinorVersion() == YOSEMITE_MINOR_VERSION;

@ -147,7 +147,6 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
if (major == 10) {
if (minor == 9) {
EXPECT_TRUE(IsOSMavericks());
EXPECT_TRUE(IsOSMavericksOrLater());
EXPECT_FALSE(IsOSYosemite());
EXPECT_TRUE(IsOSYosemiteOrEarlier());
EXPECT_FALSE(IsOSYosemiteOrLater());
@ -159,7 +158,6 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_FALSE(IsOSLaterThanSierra_DontCallThis());
} else if (minor == 10) {
EXPECT_FALSE(IsOSMavericks());
EXPECT_TRUE(IsOSMavericksOrLater());
EXPECT_TRUE(IsOSYosemite());
EXPECT_TRUE(IsOSYosemiteOrEarlier());
EXPECT_TRUE(IsOSYosemiteOrLater());
@ -171,7 +169,6 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_FALSE(IsOSLaterThanSierra_DontCallThis());
} else if (minor == 11) {
EXPECT_FALSE(IsOSMavericks());
EXPECT_TRUE(IsOSMavericksOrLater());
EXPECT_FALSE(IsOSYosemite());
EXPECT_FALSE(IsOSYosemiteOrEarlier());
EXPECT_TRUE(IsOSYosemiteOrLater());
@ -183,7 +180,6 @@ TEST_F(MacUtilTest, IsOSEllipsis) {
EXPECT_FALSE(IsOSLaterThanSierra_DontCallThis());
} else if (minor == 12) {
EXPECT_FALSE(IsOSMavericks());
EXPECT_TRUE(IsOSMavericksOrLater());
EXPECT_FALSE(IsOSYosemite());
EXPECT_FALSE(IsOSYosemiteOrEarlier());
EXPECT_TRUE(IsOSYosemiteOrLater());

@ -26,7 +26,6 @@
#endif
#if defined(OS_MACOSX)
#include <malloc/malloc.h>
#include "base/mac/mac_util.h"
#include "base/process/memory_unittest_mac.h"
#endif
#if defined(OS_LINUX)
@ -409,13 +408,6 @@ class OutOfMemoryHandledTest : public OutOfMemoryTest {
// under sanitizer tools.
#if !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
TEST_F(OutOfMemoryHandledTest, UncheckedMalloc) {
#if defined(OS_MACOSX) && ARCH_CPU_32_BITS
// The Mavericks malloc library changed in a way which breaks the tricks used
// to implement EnableTerminationOnOutOfMemory() with UncheckedMalloc() under
// 32-bit. The 64-bit malloc library works as desired without tricks.
if (base::mac::IsOSMavericksOrLater())
return;
#endif
EXPECT_TRUE(base::UncheckedMalloc(kSafeMallocSize, &value_));
EXPECT_TRUE(value_ != NULL);
free(value_);
@ -425,13 +417,6 @@ TEST_F(OutOfMemoryHandledTest, UncheckedMalloc) {
}
TEST_F(OutOfMemoryHandledTest, UncheckedCalloc) {
#if defined(OS_MACOSX) && ARCH_CPU_32_BITS
// The Mavericks malloc library changed in a way which breaks the tricks used
// to implement EnableTerminationOnOutOfMemory() with UncheckedCalloc() under
// 32-bit. The 64-bit malloc library works as desired without tricks.
if (base::mac::IsOSMavericksOrLater())
return;
#endif
EXPECT_TRUE(base::UncheckedCalloc(1, kSafeMallocSize, &value_));
EXPECT_TRUE(value_ != NULL);
const char* bytes = static_cast<const char*>(value_);

@ -60,7 +60,6 @@
#if defined(OS_MACOSX)
#include <mach/vm_param.h>
#include <malloc/malloc.h>
#include "base/mac/mac_util.h"
#endif
#if defined(OS_ANDROID)
#include "third_party/lss/linux_syscall_support.h"
@ -572,10 +571,6 @@ int change_fdguard_np(int fd,
// <http://crbug.com/338157>. This function allows querying whether the file
// descriptor is guarded before attempting to close it.
bool CanGuardFd(int fd) {
// The syscall is first provided in 10.9/Mavericks.
if (!base::mac::IsOSMavericksOrLater())
return true;
// Saves the original flags to reset later.
int original_fdflags = 0;

@ -4,17 +4,13 @@
#include "chrome/browser/platform_util.h"
#include <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
#include <CoreServices/CoreServices.h>
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/mac/mac_logging.h"
#import "base/mac/mac_util.h"
#include "base/mac/scoped_aedesc.h"
#import "base/mac/sdk_forward_declarations.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/browser/platform_util_internal.h"
@ -41,104 +37,17 @@ void OpenFileOnMainThread(const base::FilePath& full_path) {
// properly handle Finder activation for quarantined files
// (http://crbug.com/32921) and unassociated file types
// (http://crbug.com/50263).
if (base::mac::IsOSMavericksOrLater()) {
NSURL* url = [NSURL fileURLWithPath:path_string];
if (!url)
return;
const NSWorkspaceLaunchOptions launch_options =
NSWorkspaceLaunchAsync | NSWorkspaceLaunchWithErrorPresentation;
[[NSWorkspace sharedWorkspace] openURLs:@[ url ]
withAppBundleIdentifier:nil
options:launch_options
additionalEventParamDescriptor:nil
launchIdentifiers:NULL];
NSURL* url = [NSURL fileURLWithPath:path_string];
if (!url)
return;
}
// On older OSes, both LaunchServices and NSWorkspace will fail silently for
// the two cases described above. On those platforms, use an AppleEvent to
// instruct the Finder to open the file.
// Create the target of this AppleEvent, the Finder.
base::mac::ScopedAEDesc<AEAddressDesc> address;
const OSType finderCreatorCode = 'MACS';
OSErr status = AECreateDesc(typeApplSignature, // type
&finderCreatorCode, // data
sizeof(finderCreatorCode), // dataSize
address.OutPointer()); // result
if (status != noErr) {
OSSTATUS_LOG(WARNING, status) << "Could not create OpenFile() AE target";
return;
}
// Build the AppleEvent data structure that instructs Finder to open files.
base::mac::ScopedAEDesc<AppleEvent> theEvent;
status = AECreateAppleEvent(kCoreEventClass, // theAEEventClass
kAEOpenDocuments, // theAEEventID
address, // target
kAutoGenerateReturnID, // returnID
kAnyTransactionID, // transactionID
theEvent.OutPointer()); // result
if (status != noErr) {
OSSTATUS_LOG(WARNING, status) << "Could not create OpenFile() AE event";
return;
}
// Create the list of files (only ever one) to open.
base::mac::ScopedAEDesc<AEDescList> fileList;
status = AECreateList(NULL, // factoringPtr
0, // factoredSize
false, // isRecord
fileList.OutPointer()); // resultList
if (status != noErr) {
OSSTATUS_LOG(WARNING, status) << "Could not create OpenFile() AE file list";
return;
}
// Add the single path to the file list. C-style cast to avoid both a
// static_cast and a const_cast to get across the toll-free bridge.
CFURLRef pathURLRef = (CFURLRef)[NSURL fileURLWithPath:path_string];
FSRef pathRef;
if (CFURLGetFSRef(pathURLRef, &pathRef)) {
status = AEPutPtr(fileList.OutPointer(), // theAEDescList
0, // index
typeFSRef, // typeCode
&pathRef, // dataPtr
sizeof(pathRef)); // dataSize
if (status != noErr) {
OSSTATUS_LOG(WARNING, status)
<< "Could not add file path to AE list in OpenFile()";
return;
}
} else {
LOG(WARNING) << "Could not get FSRef for path URL in OpenFile()";
return;
}
// Attach the file list to the AppleEvent.
status = AEPutParamDesc(theEvent.OutPointer(), // theAppleEvent
keyDirectObject, // theAEKeyword
fileList); // theAEDesc
if (status != noErr) {
OSSTATUS_LOG(WARNING, status)
<< "Could not put the AE file list the path in OpenFile()";
return;
}
// Send the actual event. Do not care about the reply.
base::mac::ScopedAEDesc<AppleEvent> reply;
status = AESend(theEvent, // theAppleEvent
reply.OutPointer(), // reply
kAENoReply + kAEAlwaysInteract, // sendMode
kAENormalPriority, // sendPriority
kAEDefaultTimeout, // timeOutInTicks
NULL, // idleProc
NULL); // filterProc
if (status != noErr) {
OSSTATUS_LOG(WARNING, status)
<< "Could not send AE to Finder in OpenFile()";
}
const NSWorkspaceLaunchOptions launch_options =
NSWorkspaceLaunchAsync | NSWorkspaceLaunchWithErrorPresentation;
[[NSWorkspace sharedWorkspace] openURLs:@[ url ]
withAppBundleIdentifier:nil
options:launch_options
additionalEventParamDescriptor:nil
launchIdentifiers:NULL];
}
namespace internal {

@ -6,8 +6,6 @@
#import <Cocoa/Cocoa.h>
#include "base/mac/mac_util.h"
namespace content {
void InitializeMac() {
@ -27,7 +25,7 @@ void InitializeMac() {
// in the window server, which is the default when not not using the
// 10.9 SDK.
// TODO: Remove this when we build with the 10.9 SDK.
@"NSWindowHostsLayersInWindowServer": @(base::mac::IsOSMavericksOrLater())
@"NSWindowHostsLayersInWindowServer": @YES
}];
}

@ -660,7 +660,6 @@ void WebContentsViewMac::CloseTab() {
}
- (void)windowChangedOcclusionState:(NSNotification*)notification {
DCHECK(base::mac::IsOSMavericksOrLater());
NSWindow* window = [notification object];
WebContentsImpl* webContents = [self webContents];
if (window && webContents && !webContents->IsBeingDestroyed()) {

@ -6,7 +6,6 @@
#include <memory>
#include "base/mac/mac_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "media/base/mac/coremedia_glue.h"
#include "media/base/mac/corevideo_glue.h"
@ -106,11 +105,6 @@ VTVideoEncodeAccelerator::GetSupportedProfiles() {
DLOG(ERROR) << "Failed creating VideoToolbox glue.";
return profiles;
}
if (!base::mac::IsOSMavericksOrLater()) {
DLOG(ERROR) << "VideoToolbox hardware encoder is supported on Mac OS 10.9 "
"and later.";
return profiles;
}
const bool rv = CreateCompressionSession(
video_toolbox::DictionaryWithKeysAndValues(nullptr, nullptr, 0),
gfx::Size(kDefaultResolutionWidth, kDefaultResolutionHeight), true);
@ -158,11 +152,6 @@ bool VTVideoEncodeAccelerator::Initialize(VideoPixelFormat format,
DLOG(ERROR) << "Failed creating VideoToolbox glue.";
return false;
}
if (!base::mac::IsOSMavericksOrLater()) {
DLOG(ERROR) << "VideoToolbox hardware encoder is supported on Mac OS 10.9 "
"and later.";
return false;
}
client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
client_ = client_ptr_factory_->GetWeakPtr();

@ -5,7 +5,6 @@
#include "ui/base/cocoa/remote_layer_api.h"
#include "base/command_line.h"
#include "base/mac/mac_util.h"
#include "ui/base/ui_base_switches.h"
#include <objc/runtime.h>
@ -13,10 +12,6 @@
namespace ui {
bool RemoteLayerAPISupported() {
// This API only works on Mac OS 10.9 and later.
if (!base::mac::IsOSMavericksOrLater())
return false;
static bool disabled_at_command_line =
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableRemoteCoreAnimation);
@ -54,4 +49,3 @@ bool RemoteLayerAPISupported() {
}
} // namespace