Convert /device/bluetooth to use ARC
See https://chromium.googlesource.com/chromium/src/+/main/docs/mac/arc.md
for information about this conversion.
Bug: 1280317
Change-Id: Iab28dde06fa8e9792d435aaa1b5ca06f1fce66d1
Include-Ci-Only-Tests: true
Cq-Include-Trybots: luci.chromium.try:ios-blink-dbg-fyi
Cq-Include-Trybots: luci.chrome.try:mac-chrome
Validate-Test-Flakiness: skip
Low-Coverage-Reason: Doing core refactoring across all of Chromium; I do not own this code
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4606137
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1157126}
diff --git a/device/BUILD.gn b/device/BUILD.gn
index 59de793..bfe0aa3 100644
--- a/device/BUILD.gn
+++ b/device/BUILD.gn
@@ -18,34 +18,6 @@
is_linux_without_udev = (is_linux || is_chromeos) && !use_udev
-if (is_mac) {
- # TODO(https://crbug.com/1280317): Merge back into device_unittests once all
- # .mm files are ARCed.
- source_set("device_unittests_arc") {
- testonly = true
- sources = [
- "fido/mac/authenticator_unittest.mm",
- "fido/mac/browsing_data_deletion_unittest.mm",
- "fido/mac/credential_store_unittest.mm",
- "fido/mac/get_assertion_operation_unittest_mac.mm",
- "fido/mac/icloud_keychain_unittest.mm",
- "fido/mac/make_credential_operation_unittest_mac.mm",
- ]
- configs += [ "//build/config/compiler:enable_arc" ]
- deps = [
- "//base/test:test_support",
- "//device/base:base",
- "//device/fido",
- "//device/fido:icloud_keychain_test_support",
- "//device/fido:mocks",
- "//device/fido:test_support",
- "//services/data_decoder/public/cpp:test_support",
- ]
-
- data_deps = [ "fido/strings:fido_test_strings" ]
- }
-}
-
test("device_unittests") {
sources = [
"base/synchronization/one_writer_seqlock_unittest.cc",
@@ -107,6 +79,7 @@
"bluetooth/test/mock_bluetooth_central_manager_mac.h",
"bluetooth/test/mock_bluetooth_central_manager_mac.mm",
]
+ configs += [ "//build/config/compiler:enable_arc" ]
}
if (is_mac) {
@@ -170,10 +143,6 @@
"//url",
]
- if (is_mac) {
- deps += [ ":device_unittests_arc" ]
- }
-
data_deps = [
"bluetooth/strings:bluetooth_test_strings",
"//testing/buildbot/filters:device_unittests_filters",
@@ -239,11 +208,16 @@
if (is_mac) {
sources += [
- # TODO(https://crbug.com/1280317): Put the fido/mac/*.mm files from
- # device_unittests_arc back here.
+ "fido/mac/authenticator_unittest.mm",
+ "fido/mac/browsing_data_deletion_unittest.mm",
"fido/mac/credential_metadata_unittest.cc",
+ "fido/mac/credential_store_unittest.mm",
+ "fido/mac/get_assertion_operation_unittest_mac.mm",
+ "fido/mac/icloud_keychain_unittest.mm",
+ "fido/mac/make_credential_operation_unittest_mac.mm",
"fido/mac/util_unittest.cc",
]
+ deps += [ "//device/fido:icloud_keychain_test_support" ]
}
if (is_win) {
diff --git a/device/bluetooth/BUILD.gn b/device/bluetooth/BUILD.gn
index 642afd7..d075d1f 100644
--- a/device/bluetooth/BUILD.gn
+++ b/device/bluetooth/BUILD.gn
@@ -240,6 +240,7 @@
"IOKit.framework",
"Foundation.framework",
]
+ configs += [ "//build/config/compiler:enable_arc" ]
}
if (is_mac) {
diff --git a/device/bluetooth/bluetooth_adapter_ios.mm b/device/bluetooth/bluetooth_adapter_ios.mm
index 630da30..93d411b 100644
--- a/device/bluetooth/bluetooth_adapter_ios.mm
+++ b/device/bluetooth/bluetooth_adapter_ios.mm
@@ -4,6 +4,10 @@
#include "device/bluetooth/bluetooth_adapter_ios.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
// static
diff --git a/device/bluetooth/bluetooth_adapter_mac.h b/device/bluetooth/bluetooth_adapter_mac.h
index fb4fe2e..4f5d698 100644
--- a/device/bluetooth/bluetooth_adapter_mac.h
+++ b/device/bluetooth/bluetooth_adapter_mac.h
@@ -10,7 +10,6 @@
#include <memory>
#include <string>
-#include "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/task/single_thread_task_runner.h"
@@ -97,7 +96,7 @@
void InitForTest(
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) override;
BluetoothLowEnergyAdapterApple::GetDevicePairedStatusCallback
- GetDevicePariedStatus() const override;
+ GetDevicePairedStatus() const override;
// Queries the state of the IOBluetoothHostController.
HostControllerState GetHostControllerState();
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
index 2c5387fb..79bf091 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -37,6 +37,10 @@
#include "device/bluetooth/bluetooth_socket_mac.h"
#include "device/bluetooth/public/cpp/bluetooth_address.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
extern "C" {
// Undocumented IOBluetooth Preference API [1]. Used by `blueutil` [2] and
// `Karabiner` [3] to programmatically control the Bluetooth state. Calling the
@@ -273,7 +277,7 @@
}
BluetoothLowEnergyAdapterApple::GetDevicePairedStatusCallback
-BluetoothAdapterMac::GetDevicePariedStatus() const {
+BluetoothAdapterMac::GetDevicePairedStatus() const {
return device_paired_status_callback_;
}
diff --git a/device/bluetooth/bluetooth_adapter_mac_unittest.mm b/device/bluetooth/bluetooth_adapter_mac_unittest.mm
index a070614..8a98591 100644
--- a/device/bluetooth/bluetooth_adapter_mac_unittest.mm
+++ b/device/bluetooth/bluetooth_adapter_mac_unittest.mm
@@ -14,6 +14,10 @@
#import "device/bluetooth/test/test_bluetooth_adapter_observer.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
class BluetoothAdapterMacTest : public testing::Test {
diff --git a/device/bluetooth/bluetooth_advertisement_mac.h b/device/bluetooth/bluetooth_advertisement_mac.h
index f803eee..f32691e 100644
--- a/device/bluetooth/bluetooth_advertisement_mac.h
+++ b/device/bluetooth/bluetooth_advertisement_mac.h
@@ -5,10 +5,9 @@
#ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_MAC_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_ADVERTISEMENT_MAC_H_
-#include "base/memory/raw_ptr.h"
-
#import <CoreBluetooth/CoreBluetooth.h>
+#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "dbus/object_path.h"
#include "device/bluetooth/bluetooth_adapter.h"
diff --git a/device/bluetooth/bluetooth_advertisement_mac.mm b/device/bluetooth/bluetooth_advertisement_mac.mm
index 0014beef..64667c8b 100644
--- a/device/bluetooth/bluetooth_advertisement_mac.mm
+++ b/device/bluetooth/bluetooth_advertisement_mac.mm
@@ -8,6 +8,10 @@
#import "base/task/single_thread_task_runner.h"
#include "device/bluetooth/bluetooth_adapter_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
BluetoothAdvertisementMac::BluetoothAdvertisementMac(
diff --git a/device/bluetooth/bluetooth_channel_mac.h b/device/bluetooth/bluetooth_channel_mac.h
index 9c70f1db..d4ea3783d 100644
--- a/device/bluetooth/bluetooth_channel_mac.h
+++ b/device/bluetooth/bluetooth_channel_mac.h
@@ -5,13 +5,17 @@
#ifndef DEVICE_BLUETOOTH_BLUETOOTH_CHANNEL_MAC_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_CHANNEL_MAC_H_
-#include "base/memory/raw_ptr.h"
-
#import <IOKit/IOReturn.h>
#include <stdint.h>
#include <string>
+#include "base/memory/raw_ptr.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
@class IOBluetoothDevice;
namespace device {
diff --git a/device/bluetooth/bluetooth_channel_mac.mm b/device/bluetooth/bluetooth_channel_mac.mm
index 38aa279..69a02d2 100644
--- a/device/bluetooth/bluetooth_channel_mac.mm
+++ b/device/bluetooth/bluetooth_channel_mac.mm
@@ -9,12 +9,15 @@
#include "base/check.h"
#include "device/bluetooth/bluetooth_classic_device_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
BluetoothChannelMac::BluetoothChannelMac() : socket_(nullptr) {}
-BluetoothChannelMac::~BluetoothChannelMac() {
-}
+BluetoothChannelMac::~BluetoothChannelMac() = default;
void BluetoothChannelMac::SetSocket(BluetoothSocketMac* socket) {
DCHECK(!socket_);
diff --git a/device/bluetooth/bluetooth_classic_device_mac.h b/device/bluetooth/bluetooth_classic_device_mac.h
index c98d869..7b1ea92 100644
--- a/device/bluetooth/bluetooth_classic_device_mac.h
+++ b/device/bluetooth/bluetooth_classic_device_mac.h
@@ -10,11 +10,14 @@
#include <string>
-#include "base/mac/scoped_nsobject.h"
#include "base/time/time.h"
#include "device/bluetooth/bluetooth_device_mac.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
@class IOBluetoothDevice;
namespace device {
@@ -98,7 +101,7 @@
int GetHostTransmitPower(
BluetoothHCITransmitPowerLevelType power_level_type) const;
- base::scoped_nsobject<IOBluetoothDevice> device_;
+ IOBluetoothDevice* __strong device_;
};
} // namespace device
diff --git a/device/bluetooth/bluetooth_classic_device_mac.mm b/device/bluetooth/bluetooth_classic_device_mac.mm
index c1b5ed7..6cee3fc6 100644
--- a/device/bluetooth/bluetooth_classic_device_mac.mm
+++ b/device/bluetooth/bluetooth_classic_device_mac.mm
@@ -18,6 +18,10 @@
#include "device/bluetooth/public/cpp/bluetooth_address.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
// Undocumented API for accessing the Bluetooth transmit power level.
// Similar to the API defined here [ http://goo.gl/20Q5vE ].
@interface IOBluetoothHostController (UndocumentedAPI)
@@ -65,12 +69,11 @@
BluetoothClassicDeviceMac::BluetoothClassicDeviceMac(
BluetoothAdapterMac* adapter,
IOBluetoothDevice* device)
- : BluetoothDeviceMac(adapter), device_([device retain]) {
+ : BluetoothDeviceMac(adapter), device_(device) {
UpdateTimestamp();
}
-BluetoothClassicDeviceMac::~BluetoothClassicDeviceMac() {
-}
+BluetoothClassicDeviceMac::~BluetoothClassicDeviceMac() = default;
uint32_t BluetoothClassicDeviceMac::GetBluetoothClass() const {
return [device_ classOfDevice];
@@ -258,8 +261,7 @@
ConnectToServiceCallback callback,
ConnectToServiceErrorCallback error_callback) {
scoped_refptr<BluetoothSocketMac> socket = BluetoothSocketMac::CreateSocket();
- socket->Connect(device_.get(), uuid,
- base::BindOnce(std::move(callback), socket),
+ socket->Connect(device_, uuid, base::BindOnce(std::move(callback), socket),
std::move(error_callback));
}
diff --git a/device/bluetooth/bluetooth_device_mac.h b/device/bluetooth/bluetooth_device_mac.h
index fd56644..5213f55 100644
--- a/device/bluetooth/bluetooth_device_mac.h
+++ b/device/bluetooth/bluetooth_device_mac.h
@@ -8,6 +8,10 @@
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_gatt_service.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
@class NSError;
namespace device {
@@ -33,7 +37,7 @@
virtual bool IsLowEnergyDevice() = 0;
protected:
- BluetoothDeviceMac(BluetoothAdapter* adapter);
+ explicit BluetoothDeviceMac(BluetoothAdapter* adapter);
};
} // namespace device
diff --git a/device/bluetooth/bluetooth_device_mac.mm b/device/bluetooth/bluetooth_device_mac.mm
index 3f45b4d..68a537e 100644
--- a/device/bluetooth/bluetooth_device_mac.mm
+++ b/device/bluetooth/bluetooth_device_mac.mm
@@ -8,6 +8,10 @@
#include "device/bluetooth/bluetooth_adapter.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
static NSString* const kConnectErrorDomain = @"ConnectErrorCode";
static NSString* const kGattErrorDomain = @"GattErrorCode";
@@ -16,8 +20,7 @@
BluetoothDeviceMac::BluetoothDeviceMac(BluetoothAdapter* adapter)
: BluetoothDevice(adapter) {}
-BluetoothDeviceMac::~BluetoothDeviceMac() {
-}
+BluetoothDeviceMac::~BluetoothDeviceMac() = default;
NSError* BluetoothDeviceMac::GetNSErrorFromConnectErrorCode(
BluetoothDevice::ConnectErrorCode error_code) {
diff --git a/device/bluetooth/bluetooth_discovery_manager_mac.h b/device/bluetooth/bluetooth_discovery_manager_mac.h
index 637b7e5..aee2b75 100644
--- a/device/bluetooth/bluetooth_discovery_manager_mac.h
+++ b/device/bluetooth/bluetooth_discovery_manager_mac.h
@@ -30,7 +30,7 @@
virtual void ClassicDiscoveryStopped(bool unexpected) = 0;
protected:
- virtual ~Observer() {}
+ virtual ~Observer() = default;
};
BluetoothDiscoveryManagerMac(const BluetoothDiscoveryManagerMac&) = delete;
diff --git a/device/bluetooth/bluetooth_discovery_manager_mac.mm b/device/bluetooth/bluetooth_discovery_manager_mac.mm
index a8e6e0e2..6d8e7f6 100644
--- a/device/bluetooth/bluetooth_discovery_manager_mac.mm
+++ b/device/bluetooth/bluetooth_discovery_manager_mac.mm
@@ -4,14 +4,15 @@
#include "device/bluetooth/bluetooth_discovery_manager_mac.h"
-#include "base/memory/raw_ptr.h"
-
-#import <IOBluetooth/objc/IOBluetoothDevice.h>
-#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
+#import <IOBluetooth/IOBluetooth.h>
#include "base/check_op.h"
#include "base/logging.h"
-#include "base/mac/scoped_nsobject.h"
+#include "base/memory/raw_ptr.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
namespace device {
@@ -40,8 +41,6 @@
public:
explicit BluetoothDiscoveryManagerMacClassic(Observer* observer)
: BluetoothDiscoveryManagerMac(observer),
- should_do_discovery_(false),
- inquiry_running_(false),
inquiry_delegate_(
[[BluetoothDeviceInquiryDelegate alloc] initWithManager:this]),
inquiry_([[IOBluetoothDeviceInquiry alloc]
@@ -52,7 +51,7 @@
BluetoothDiscoveryManagerMacClassic& operator=(
const BluetoothDiscoveryManagerMacClassic&) = delete;
- ~BluetoothDiscoveryManagerMacClassic() override {}
+ ~BluetoothDiscoveryManagerMacClassic() override = default;
// BluetoothDiscoveryManagerMac override.
bool IsDiscovering() const override { return should_do_discovery_; }
@@ -178,14 +177,14 @@
private:
// The requested discovery state.
- bool should_do_discovery_;
+ bool should_do_discovery_ = false;
// The current inquiry state.
- bool inquiry_running_;
+ bool inquiry_running_ = false;
// Objective-C objects for running and tracking device inquiry.
- base::scoped_nsobject<BluetoothDeviceInquiryDelegate> inquiry_delegate_;
- base::scoped_nsobject<IOBluetoothDeviceInquiry> inquiry_;
+ BluetoothDeviceInquiryDelegate* __strong inquiry_delegate_;
+ IOBluetoothDeviceInquiry* __strong inquiry_;
};
BluetoothDiscoveryManagerMac::BluetoothDiscoveryManagerMac(
@@ -193,8 +192,7 @@
DCHECK(observer);
}
-BluetoothDiscoveryManagerMac::~BluetoothDiscoveryManagerMac() {
-}
+BluetoothDiscoveryManagerMac::~BluetoothDiscoveryManagerMac() = default;
// static
BluetoothDiscoveryManagerMac* BluetoothDiscoveryManagerMac::CreateClassic(
diff --git a/device/bluetooth/bluetooth_l2cap_channel_mac.h b/device/bluetooth/bluetooth_l2cap_channel_mac.h
index 7111da7c..3e09dd74 100644
--- a/device/bluetooth/bluetooth_l2cap_channel_mac.h
+++ b/device/bluetooth/bluetooth_l2cap_channel_mac.h
@@ -12,9 +12,12 @@
#include <memory>
-#include "base/mac/scoped_nsobject.h"
#include "device/bluetooth/bluetooth_channel_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
@class BluetoothL2capChannelDelegate;
namespace device {
@@ -23,7 +26,6 @@
public:
// Creates a new L2CAP channel wrapper with the given |socket| and native
// |channel|.
- // NOTE: The |channel| is expected to already be retained.
BluetoothL2capChannelMac(BluetoothSocketMac* socket,
IOBluetoothL2CAPChannel* channel);
@@ -60,10 +62,10 @@
private:
// The wrapped native L2CAP channel.
- base::scoped_nsobject<IOBluetoothL2CAPChannel> channel_;
+ IOBluetoothL2CAPChannel* __strong channel_;
// The delegate for the native channel.
- base::scoped_nsobject<BluetoothL2capChannelDelegate> delegate_;
+ BluetoothL2capChannelDelegate* __strong delegate_;
};
} // namespace device
diff --git a/device/bluetooth/bluetooth_l2cap_channel_mac.mm b/device/bluetooth/bluetooth_l2cap_channel_mac.mm
index ed9a1d3..1a343a2 100644
--- a/device/bluetooth/bluetooth_l2cap_channel_mac.mm
+++ b/device/bluetooth/bluetooth_l2cap_channel_mac.mm
@@ -11,6 +11,10 @@
#include "device/bluetooth/bluetooth_classic_device_mac.h"
#include "device/bluetooth/bluetooth_socket_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
// A simple delegate class for an open L2CAP channel that forwards methods to
// its wrapped |channel_|.
@interface BluetoothL2capChannelDelegate
@@ -78,19 +82,15 @@
IOReturn* status) {
DCHECK(socket);
std::unique_ptr<BluetoothL2capChannelMac> channel(
- new BluetoothL2capChannelMac(socket, nil));
+ new BluetoothL2capChannelMac(socket, /*channel=*/nil));
- // Retain the delegate, because IOBluetoothDevice's
- // |-openL2CAPChannelAsync:withPSM:delegate:| assumes that it can take
- // ownership of the delegate without calling |-retain| on it...
DCHECK(channel->delegate_);
- [channel->delegate_ retain];
IOBluetoothL2CAPChannel* l2cap_channel;
*status = [device openL2CAPChannelAsync:&l2cap_channel
withPSM:psm
delegate:channel->delegate_];
if (*status == kIOReturnSuccess)
- channel->channel_.reset([l2cap_channel retain]);
+ channel->channel_ = l2cap_channel;
else
channel.reset();
@@ -105,8 +105,7 @@
// Now that the socket is set, it's safe to associate a delegate, which can
// call back to the socket.
DCHECK(!delegate_);
- delegate_.reset(
- [[BluetoothL2capChannelDelegate alloc] initWithChannel:this]);
+ delegate_ = [[BluetoothL2capChannelDelegate alloc] initWithChannel:this];
[channel_ setDelegate:delegate_];
}
diff --git a/device/bluetooth/bluetooth_low_energy_adapter_apple.h b/device/bluetooth/bluetooth_low_energy_adapter_apple.h
index 9709d1b1..daaeab83 100644
--- a/device/bluetooth/bluetooth_low_energy_adapter_apple.h
+++ b/device/bluetooth/bluetooth_low_energy_adapter_apple.h
@@ -11,7 +11,6 @@
#include <unordered_map>
#include <vector>
-#include "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_refptr.h"
#include "base/task/single_thread_task_runner.h"
#include "device/bluetooth/bluetooth_adapter.h"
@@ -22,6 +21,10 @@
#include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
@class CBUUID;
@class BluetoothLowEnergyCentralManagerDelegate;
@@ -111,7 +114,7 @@
virtual void LazyInitialize();
virtual void InitForTest(
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
- virtual GetDevicePairedStatusCallback GetDevicePariedStatus() const;
+ virtual GetDevicePairedStatusCallback GetDevicePairedStatus() const;
virtual base::WeakPtr<BluetoothLowEnergyAdapterApple>
GetLowEnergyWeakPtr() = 0;
@@ -200,13 +203,13 @@
low_energy_advertisement_manager_;
// Underlying CoreBluetooth CBCentralManager and its delegate.
- base::scoped_nsobject<CBCentralManager> low_energy_central_manager_;
- base::scoped_nsobject<BluetoothLowEnergyCentralManagerDelegate>
+ CBCentralManager* __strong low_energy_central_manager_;
+ BluetoothLowEnergyCentralManagerDelegate* __strong
low_energy_central_manager_delegate_;
// Underlying CoreBluetooth CBPeripheralManager and its delegate.
- base::scoped_nsobject<CBPeripheralManager> low_energy_peripheral_manager_;
- base::scoped_nsobject<BluetoothLowEnergyPeripheralManagerDelegate>
+ CBPeripheralManager* __strong low_energy_peripheral_manager_;
+ BluetoothLowEnergyPeripheralManagerDelegate* __strong
low_energy_peripheral_manager_delegate_;
// Watches system file /Library/Preferences/com.apple.Bluetooth.plist to
diff --git a/device/bluetooth/bluetooth_low_energy_adapter_apple.mm b/device/bluetooth/bluetooth_low_energy_adapter_apple.mm
index 391e619..40c6232 100644
--- a/device/bluetooth/bluetooth_low_energy_adapter_apple.mm
+++ b/device/bluetooth/bluetooth_low_energy_adapter_apple.mm
@@ -37,6 +37,10 @@
#include "device/bluetooth/bluetooth_low_energy_peripheral_manager_delegate.h"
#include "device/bluetooth/public/cpp/bluetooth_address.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
// static
@@ -84,7 +88,7 @@
// Set low_energy_central_manager_ to nil so no devices will try to use it
// while being destroyed after this method. |devices_| is owned by
// BluetoothAdapter.
- low_energy_central_manager_.reset();
+ low_energy_central_manager_ = nil;
}
std::string BluetoothLowEnergyAdapterApple::GetAddress() const {
@@ -217,14 +221,14 @@
return;
}
- low_energy_central_manager_.reset([[CBCentralManager alloc]
+ low_energy_central_manager_ = [[CBCentralManager alloc]
initWithDelegate:low_energy_central_manager_delegate_
- queue:dispatch_get_main_queue()]);
+ queue:dispatch_get_main_queue()];
low_energy_discovery_manager_->SetCentralManager(low_energy_central_manager_);
- low_energy_peripheral_manager_.reset([[CBPeripheralManager alloc]
+ low_energy_peripheral_manager_ = [[CBPeripheralManager alloc]
initWithDelegate:low_energy_peripheral_manager_delegate_
- queue:dispatch_get_main_queue()]);
+ queue:dispatch_get_main_queue()];
lazy_initialized_ = true;
@@ -269,8 +273,7 @@
void BluetoothLowEnergyAdapterApple::SetCentralManagerForTesting(
CBCentralManager* central_manager) {
central_manager.delegate = low_energy_central_manager_delegate_;
- low_energy_central_manager_.reset(central_manager,
- base::scoped_policy::RETAIN);
+ low_energy_central_manager_ = central_manager;
low_energy_discovery_manager_->SetCentralManager(low_energy_central_manager_);
}
@@ -350,7 +353,7 @@
}
BluetoothLowEnergyAdapterApple::GetDevicePairedStatusCallback
-BluetoothLowEnergyAdapterApple::GetDevicePariedStatus() const {
+BluetoothLowEnergyAdapterApple::GetDevicePairedStatus() const {
return base::NullCallbackAs<bool(const std::string&)>();
}
@@ -614,8 +617,8 @@
return false;
}
- if (GetDevicePariedStatus()) {
- return GetDevicePariedStatus().Run(it->second);
+ if (GetDevicePairedStatus()) {
+ return GetDevicePairedStatus().Run(it->second);
}
return true;
}
diff --git a/device/bluetooth/bluetooth_low_energy_adapter_apple_unittest.mm b/device/bluetooth/bluetooth_low_energy_adapter_apple_unittest.mm
index 6277c5a..2747142 100644
--- a/device/bluetooth/bluetooth_low_energy_adapter_apple_unittest.mm
+++ b/device/bluetooth/bluetooth_low_energy_adapter_apple_unittest.mm
@@ -16,7 +16,6 @@
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
-#import "base/task/sequenced_task_runner.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
@@ -39,6 +38,10 @@
#include "device/bluetooth/bluetooth_adapter_mac.h"
#endif
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace {
const char kTestPropertyListFileName[] = "test_property_list_file.plist";
@@ -48,7 +51,7 @@
const char kTestHashAddress[] = "D1:6F:E3:22:FD:5B";
const int kTestRssi = 0;
-NSDictionary* CreateTestPropertyListData() {
+NSDictionary* TestPropertyListData() {
return @{
@"CoreBluetoothCache" : @{
@"00000000-1111-2222-3333-444444444444" : @{
@@ -97,7 +100,7 @@
void ReadBluetoothPropertyListFile() override {
low_energy_device_list_updated_callback().Run(
- ParseBluetoothDevicePropertyListData(CreateTestPropertyListData()));
+ ParseBluetoothDevicePropertyListData(TestPropertyListData()));
}
base::WeakPtrFactory<FakeBluetoothLowEnergyDeviceWatcherMac>
@@ -156,17 +159,16 @@
}
CBPeripheral* CreateMockPeripheral(const char* identifier) {
- base::scoped_nsobject<MockCBPeripheral> mock_peripheral(
- [[MockCBPeripheral alloc] initWithUTF8StringIdentifier:identifier]);
- return [[mock_peripheral peripheral] retain];
+ MockCBPeripheral* mock_peripheral =
+ [[MockCBPeripheral alloc] initWithUTF8StringIdentifier:identifier];
+ return [mock_peripheral peripheral];
}
NSDictionary* AdvertisementData() {
- NSDictionary* advertisement_data = @{
+ return @{
CBAdvertisementDataIsConnectable : @YES,
CBAdvertisementDataServiceDataKey : @{},
};
- return [advertisement_data retain];
}
std::string GetHashAddress(CBPeripheral* peripheral) {
@@ -178,14 +180,14 @@
bool DevicePresent(CBPeripheral* peripheral) {
BluetoothDevice* device = adapter_low_energy_->GetDevice(
BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral));
- return (device != NULL);
+ return device;
}
bool SetMockCentralManager(CBManagerState desired_state) {
- mock_central_manager_.reset([[MockCentralManager alloc] init]);
- [mock_central_manager_ setState:desired_state];
+ mock_central_manager_ = [[MockCentralManager alloc] init];
+ mock_central_manager_.state = desired_state;
CBCentralManager* centralManager =
- static_cast<CBCentralManager*>(mock_central_manager_.get());
+ static_cast<CBCentralManager*>(mock_central_manager_);
adapter_low_energy_->SetCentralManagerForTesting(centralManager);
return true;
}
@@ -223,7 +225,7 @@
std::vector<std::unique_ptr<BluetoothDiscoverySession>> active_sessions_;
// Owned by |adapter_low_energy_|.
- base::scoped_nsobject<MockCentralManager> mock_central_manager_;
+ MockCentralManager* __strong mock_central_manager_;
int callback_count_;
int error_callback_count_;
@@ -353,8 +355,7 @@
if (!SetMockCentralManager(CBManagerStatePoweredOn)) {
return;
}
- base::scoped_nsobject<CBPeripheral> mock_peripheral(
- CreateMockPeripheral(kTestNSUUID));
+ CBPeripheral* mock_peripheral = CreateMockPeripheral(kTestNSUUID);
if (!mock_peripheral) {
return;
}
@@ -365,12 +366,11 @@
if (!SetMockCentralManager(CBManagerStatePoweredOn)) {
return;
}
- base::scoped_nsobject<CBPeripheral> mock_peripheral(
- CreateMockPeripheral(kTestNSUUID));
+ CBPeripheral* mock_peripheral = CreateMockPeripheral(kTestNSUUID);
if (!mock_peripheral) {
return;
}
- base::scoped_nsobject<NSDictionary> advertisement_data(AdvertisementData());
+ NSDictionary* advertisement_data = AdvertisementData();
EXPECT_EQ(0, NumDevices());
EXPECT_FALSE(DevicePresent(mock_peripheral));
@@ -430,27 +430,22 @@
ASSERT_TRUE(SetMockCentralManager(CBManagerStatePoweredOn));
- base::scoped_nsobject<CBPeripheral> mock_peripheral_one(
- CreateMockPeripheral(kTestNSUUID));
+ CBPeripheral* mock_peripheral_one = CreateMockPeripheral(kTestNSUUID);
ASSERT_TRUE(mock_peripheral_one);
- LowEnergyDeviceUpdated(
- mock_peripheral_one,
- base::scoped_nsobject<NSDictionary>(AdvertisementData()), kTestRssi);
+ LowEnergyDeviceUpdated(mock_peripheral_one, AdvertisementData(), kTestRssi);
- base::scoped_nsobject<CBPeripheral> mock_peripheral_two(
- CreateMockPeripheral(kTestAddedDeviceNSUUID));
+ CBPeripheral* mock_peripheral_two =
+ CreateMockPeripheral(kTestAddedDeviceNSUUID);
ASSERT_TRUE(mock_peripheral_two);
- LowEnergyDeviceUpdated(
- mock_peripheral_two,
- base::scoped_nsobject<NSDictionary>(AdvertisementData()), kTestRssi);
+ LowEnergyDeviceUpdated(mock_peripheral_two, AdvertisementData(), kTestRssi);
observer_.Reset();
// BluetoothAdapterMac only notifies observers of changed devices detected by
// BluetoothLowEnergyDeviceWatcherMac if the device has been already known to
- // the system(i.e. the changed device is in BluetoothAdatper::devices_). As
- // so, add mock devices prior to setting BluetoothLowenergyDeviceWatcherMac.
+ // the system(i.e. the changed device is in BluetoothAdapter::devices_). As
+ // so, add mock devices prior to setting BluetoothLowEnergyDeviceWatcherMac.
SetFakeLowEnergyDeviceWatcher();
EXPECT_EQ(1, observer_.device_changed_count());
@@ -481,15 +476,12 @@
return;
}
- base::scoped_nsobject<CBPeripheral> mock_peripheral(
- CreateMockPeripheral(kTestNSUUID));
+ CBPeripheral* mock_peripheral = CreateMockPeripheral(kTestNSUUID);
if (!mock_peripheral) {
return;
}
- LowEnergyDeviceUpdated(
- mock_peripheral, base::scoped_nsobject<NSDictionary>(AdvertisementData()),
- kTestRssi);
+ LowEnergyDeviceUpdated(mock_peripheral, AdvertisementData(), kTestRssi);
observer_.Reset();
SetFakeLowEnergyDeviceWatcher();
diff --git a/device/bluetooth/bluetooth_low_energy_advertisement_manager_mac.mm b/device/bluetooth/bluetooth_low_energy_advertisement_manager_mac.mm
index 12807b2..c80ad50 100644
--- a/device/bluetooth/bluetooth_low_energy_advertisement_manager_mac.mm
+++ b/device/bluetooth/bluetooth_low_energy_advertisement_manager_mac.mm
@@ -6,19 +6,22 @@
#include "base/functional/bind.h"
#include "base/logging.h"
-#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
#import "base/task/single_thread_task_runner.h"
#include "device/bluetooth/bluetooth_advertisement.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
BluetoothLowEnergyAdvertisementManagerMac::
- BluetoothLowEnergyAdvertisementManagerMac() {}
+ BluetoothLowEnergyAdvertisementManagerMac() = default;
BluetoothLowEnergyAdvertisementManagerMac::
- ~BluetoothLowEnergyAdvertisementManagerMac() {}
+ ~BluetoothLowEnergyAdvertisementManagerMac() = default;
void BluetoothLowEnergyAdvertisementManagerMac::Init(
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
@@ -87,9 +90,8 @@
}
void BluetoothLowEnergyAdvertisementManagerMac::StartAdvertising() {
- base::scoped_nsobject<NSMutableArray> service_uuid_array(
- [[NSMutableArray alloc]
- initWithCapacity:active_advertisement_->service_uuids().size()]);
+ NSMutableArray* service_uuid_array = [[NSMutableArray alloc]
+ initWithCapacity:active_advertisement_->service_uuids().size()];
for (const std::string& service_uuid :
active_advertisement_->service_uuids()) {
NSString* uuid_string = base::SysUTF8ToNSString(service_uuid);
diff --git a/device/bluetooth/bluetooth_low_energy_advertisement_manager_mac_unittest.mm b/device/bluetooth/bluetooth_low_energy_advertisement_manager_mac_unittest.mm
index aff5b2c..8e74e31 100644
--- a/device/bluetooth/bluetooth_low_energy_advertisement_manager_mac_unittest.mm
+++ b/device/bluetooth/bluetooth_low_energy_advertisement_manager_mac_unittest.mm
@@ -16,6 +16,10 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/ocmock/OCMock/OCMock.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace {
const char kTestUUID[] = "00000000-1111-2222-3333-444444444444";
} // namespace
@@ -100,8 +104,8 @@
protected:
scoped_refptr<base::TestSimpleTaskRunner> ui_task_runner_;
BluetoothLowEnergyAdvertisementManagerMac advertisement_manager_;
- CBPeripheralManager* peripheral_manager_;
- id peripheral_manager_mock_;
+ CBPeripheralManager* __strong peripheral_manager_;
+ id __strong peripheral_manager_mock_;
CBManagerState peripheral_manager_state_;
scoped_refptr<BluetoothAdvertisement> advertisement_;
diff --git a/device/bluetooth/bluetooth_low_energy_central_manager_delegate.mm b/device/bluetooth/bluetooth_low_energy_central_manager_delegate.mm
index ce8e20a2..d37d3a7 100644
--- a/device/bluetooth/bluetooth_low_energy_central_manager_delegate.mm
+++ b/device/bluetooth/bluetooth_low_energy_central_manager_delegate.mm
@@ -11,6 +11,10 @@
#include "device/bluetooth/bluetooth_low_energy_adapter_apple.h"
#include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
// This class exists to bridge between the Objective-C CBCentralManagerDelegate
@@ -23,7 +27,7 @@
BluetoothLowEnergyAdapterApple* adapter)
: discovery_manager_(discovery_manager), adapter_(adapter) {}
- ~BluetoothLowEnergyCentralManagerBridge() {}
+ ~BluetoothLowEnergyCentralManagerBridge() = default;
void DiscoveredPeripheral(CBPeripheral* peripheral,
NSDictionary* advertisementData,
diff --git a/device/bluetooth/bluetooth_low_energy_device_mac.h b/device/bluetooth/bluetooth_low_energy_device_mac.h
index 17a8664..aeb41e5 100644
--- a/device/bluetooth/bluetooth_low_energy_device_mac.h
+++ b/device/bluetooth/bluetooth_low_energy_device_mac.h
@@ -10,7 +10,6 @@
#include <set>
-#include "base/mac/scoped_nsobject.h"
#include "build/build_config.h"
#include "crypto/sha2.h"
#include "device/bluetooth/bluetooth_device_mac.h"
@@ -20,6 +19,10 @@
#import <IOBluetooth/IOBluetooth.h>
#endif
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
@class BluetoothLowEnergyPeripheralDelegate;
namespace device {
@@ -89,7 +92,7 @@
protected:
// BluetoothDevice override.
void CreateGattConnectionImpl(
- absl::optional<BluetoothUUID> serivce_uuid) override;
+ absl::optional<BluetoothUUID> service_uuid) override;
void DisconnectGatt() override;
// Methods used by BluetoothLowEnergyPeripheralBridge.
@@ -154,11 +157,10 @@
void DidDisconnectPeripheral(NSError* error);
// CoreBluetooth data structure.
- base::scoped_nsobject<CBPeripheral> peripheral_;
+ CBPeripheral* __strong peripheral_;
// Objective-C delegate for the CBPeripheral.
- base::scoped_nsobject<BluetoothLowEnergyPeripheralDelegate>
- peripheral_delegate_;
+ BluetoothLowEnergyPeripheralDelegate* __strong peripheral_delegate_;
// Whether the device is connected.
bool connected_;
diff --git a/device/bluetooth/bluetooth_low_energy_device_mac.mm b/device/bluetooth/bluetooth_low_energy_device_mac.mm
index ca9d3bdc..b2409874 100644
--- a/device/bluetooth/bluetooth_low_energy_device_mac.mm
+++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm
@@ -22,18 +22,22 @@
#include "device/bluetooth/bluetooth_remote_gatt_service_mac.h"
#include "device/bluetooth/public/cpp/bluetooth_address.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
BluetoothLowEnergyDeviceMac::BluetoothLowEnergyDeviceMac(
BluetoothAdapter* adapter,
CBPeripheral* peripheral)
: BluetoothDeviceMac(adapter),
- peripheral_(peripheral, base::scoped_policy::RETAIN),
+ peripheral_(peripheral),
connected_(false),
discovery_pending_count_(0) {
DCHECK(peripheral_);
- peripheral_delegate_.reset([[BluetoothLowEnergyPeripheralDelegate alloc]
- initWithBluetoothLowEnergyDeviceMac:this]);
+ peripheral_delegate_ = [[BluetoothLowEnergyPeripheralDelegate alloc]
+ initWithBluetoothLowEnergyDeviceMac:this];
[peripheral_ setDelegate:peripheral_delegate_];
identifier_ = GetPeripheralIdentifier(peripheral);
hash_address_ = GetPeripheralHashAddress(peripheral);
@@ -255,8 +259,8 @@
}
}
if (discovery_pending_count_ == 0) {
- for (auto it = gatt_services_.begin(); it != gatt_services_.end(); ++it) {
- BluetoothRemoteGattService* gatt_service = it->second.get();
+ for (auto& it : gatt_services_) {
+ BluetoothRemoteGattService* gatt_service = it.second.get();
BluetoothRemoteGattServiceMac* gatt_service_mac =
static_cast<BluetoothRemoteGattServiceMac*>(gatt_service);
gatt_service_mac->DiscoverCharacteristics();
@@ -472,8 +476,8 @@
BluetoothRemoteGattServiceMac*
BluetoothLowEnergyDeviceMac::GetBluetoothRemoteGattServiceMac(
CBService* cb_service) const {
- for (auto it = gatt_services_.begin(); it != gatt_services_.end(); ++it) {
- BluetoothRemoteGattService* gatt_service = it->second.get();
+ for (const auto& it : gatt_services_) {
+ BluetoothRemoteGattService* gatt_service = it.second.get();
BluetoothRemoteGattServiceMac* gatt_service_mac =
static_cast<BluetoothRemoteGattServiceMac*>(gatt_service);
if (gatt_service_mac->GetService() == cb_service)
diff --git a/device/bluetooth/bluetooth_low_energy_device_watcher_mac.mm b/device/bluetooth/bluetooth_low_energy_device_watcher_mac.mm
index 7104a83..2130f9f5 100644
--- a/device/bluetooth/bluetooth_low_energy_device_watcher_mac.mm
+++ b/device/bluetooth/bluetooth_low_energy_device_watcher_mac.mm
@@ -14,6 +14,10 @@
#include "base/task/task_traits.h"
#include "device/bluetooth/bluetooth_adapter_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
namespace {
diff --git a/device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h b/device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h
index 2578643..0f844af 100644
--- a/device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h
+++ b/device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h
@@ -5,11 +5,9 @@
#ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DISCOVERY_MANAGER_MAC_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DISCOVERY_MANAGER_MAC_H_
-#include "base/memory/raw_ptr.h"
-
#import <CoreBluetooth/CoreBluetooth.h>
-#include "base/mac/scoped_nsobject.h"
+#include "base/memory/raw_ptr.h"
#include "build/build_config.h"
#include "device/bluetooth/bluetooth_device.h"
@@ -31,7 +29,7 @@
int rssi) = 0;
protected:
- virtual ~Observer() {}
+ virtual ~Observer() = default;
};
BluetoothLowEnergyDiscoveryManagerMac(
diff --git a/device/bluetooth/bluetooth_low_energy_discovery_manager_mac.mm b/device/bluetooth/bluetooth_low_energy_discovery_manager_mac.mm
index 41858a1c..c7f8aa4cf 100644
--- a/device/bluetooth/bluetooth_low_energy_discovery_manager_mac.mm
+++ b/device/bluetooth/bluetooth_low_energy_discovery_manager_mac.mm
@@ -12,11 +12,14 @@
#include "device/bluetooth/bluetooth_adapter_mac.h"
#include "device/bluetooth/bluetooth_low_energy_device_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
BluetoothLowEnergyDiscoveryManagerMac::
- ~BluetoothLowEnergyDiscoveryManagerMac() {
-}
+ ~BluetoothLowEnergyDiscoveryManagerMac() = default;
bool BluetoothLowEnergyDiscoveryManagerMac::IsDiscovering() const {
return discovering_;
diff --git a/device/bluetooth/bluetooth_low_energy_peripheral_delegate.h b/device/bluetooth/bluetooth_low_energy_peripheral_delegate.h
index 623a787..156c8a3 100644
--- a/device/bluetooth/bluetooth_low_energy_peripheral_delegate.h
+++ b/device/bluetooth/bluetooth_low_energy_peripheral_delegate.h
@@ -15,6 +15,10 @@
#import <IOBluetooth/IOBluetooth.h>
#endif
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
class BluetoothLowEnergyDeviceMac;
diff --git a/device/bluetooth/bluetooth_low_energy_peripheral_delegate.mm b/device/bluetooth/bluetooth_low_energy_peripheral_delegate.mm
index 36ecb3e..a484b6d 100644
--- a/device/bluetooth/bluetooth_low_energy_peripheral_delegate.mm
+++ b/device/bluetooth/bluetooth_low_energy_peripheral_delegate.mm
@@ -10,6 +10,10 @@
#include "device/bluetooth/bluetooth_adapter_mac.h"
#include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
// This class exists to bridge between the Objective-C CBPeripheralDelegate
@@ -20,7 +24,7 @@
BluetoothLowEnergyPeripheralBridge(BluetoothLowEnergyDeviceMac* device_mac)
: device_mac_(device_mac) {}
- ~BluetoothLowEnergyPeripheralBridge() {}
+ ~BluetoothLowEnergyPeripheralBridge() = default;
void DidModifyServices(NSArray* invalidatedServices) {
device_mac_->DidModifyServices(invalidatedServices);
diff --git a/device/bluetooth/bluetooth_low_energy_peripheral_manager_delegate.h b/device/bluetooth/bluetooth_low_energy_peripheral_manager_delegate.h
index 9d3deee..4cbc330 100644
--- a/device/bluetooth/bluetooth_low_energy_peripheral_manager_delegate.h
+++ b/device/bluetooth/bluetooth_low_energy_peripheral_manager_delegate.h
@@ -13,6 +13,10 @@
#import <IOBluetooth/IOBluetooth.h>
#endif
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
class BluetoothLowEnergyAdapterApple;
class BluetoothLowEnergyAdvertisementManagerMac;
diff --git a/device/bluetooth/bluetooth_low_energy_peripheral_manager_delegate.mm b/device/bluetooth/bluetooth_low_energy_peripheral_manager_delegate.mm
index 311c2ee..454961f6 100644
--- a/device/bluetooth/bluetooth_low_energy_peripheral_manager_delegate.mm
+++ b/device/bluetooth/bluetooth_low_energy_peripheral_manager_delegate.mm
@@ -9,6 +9,10 @@
#include "base/memory/raw_ptr.h"
#include "device/bluetooth/bluetooth_low_energy_adapter_apple.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
// This class exists to bridge between the Objective-C
@@ -21,7 +25,7 @@
BluetoothLowEnergyAdapterApple* adapter)
: advertisement_manager_(advertisement_manager), adapter_(adapter) {}
- ~BluetoothLowEnergyPeripheralManagerBridge() {}
+ ~BluetoothLowEnergyPeripheralManagerBridge() = default;
void UpdatedState() {
advertisement_manager_->OnPeripheralManagerStateChanged();
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h b/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h
index 9c87ce9e..2cc980f 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h
@@ -5,17 +5,21 @@
#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_
-#include "base/memory/raw_ptr.h"
#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
#import <CoreBluetooth/CoreBluetooth.h>
+
#include <string>
#include <utility>
#include <vector>
-#include "base/mac/scoped_nsobject.h"
+#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
class BluetoothLowEnergyAdapterApple;
@@ -122,7 +126,7 @@
// gatt_service_ owns instances of this class.
raw_ptr<BluetoothRemoteGattServiceMac> gatt_service_;
// A characteristic from CBPeripheral.services.characteristics.
- base::scoped_nsobject<CBCharacteristic> cb_characteristic_;
+ CBCharacteristic* __strong cb_characteristic_;
// Characteristic identifier.
std::string identifier_;
// Service UUID.
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm b/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
index d185828..3da63a2 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
@@ -16,6 +16,10 @@
#include "device/bluetooth/bluetooth_remote_gatt_descriptor_mac.h"
#include "device/bluetooth/bluetooth_remote_gatt_service_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
namespace {
@@ -74,13 +78,13 @@
: is_discovery_complete_(false),
discovery_pending_count_(0),
gatt_service_(gatt_service),
- cb_characteristic_(cb_characteristic, base::scoped_policy::RETAIN),
+ cb_characteristic_(cb_characteristic),
weak_ptr_factory_(this) {
uuid_ = BluetoothLowEnergyAdapterApple::BluetoothUUIDWithCBUUID(
[cb_characteristic_ UUID]);
identifier_ = base::SysNSStringToUTF8(
[NSString stringWithFormat:@"%s-%p", uuid_.canonical_value().c_str(),
- cb_characteristic_.get()]);
+ cb_characteristic_]);
}
BluetoothRemoteGattCharacteristicMac::~BluetoothRemoteGattCharacteristicMac() {
@@ -171,8 +175,8 @@
DVLOG(1) << *this << ": Write characteristic.";
write_characteristic_value_callbacks_ =
std::make_pair(std::move(callback), std::move(error_callback));
- base::scoped_nsobject<NSData> nsdata_value(
- [[NSData alloc] initWithBytes:value.data() length:value.size()]);
+ NSData* nsdata_value = [[NSData alloc] initWithBytes:value.data()
+ length:value.size()];
CBCharacteristicWriteType cb_write_type;
switch (write_type) {
@@ -218,8 +222,8 @@
DVLOG(1) << *this << ": Write characteristic.";
write_characteristic_value_callbacks_ =
std::make_pair(std::move(callback), std::move(error_callback));
- base::scoped_nsobject<NSData> nsdata_value(
- [[NSData alloc] initWithBytes:value.data() length:value.size()]);
+ NSData* nsdata_value = [[NSData alloc] initWithBytes:value.data()
+ length:value.size()];
CBCharacteristicWriteType write_type = GetCBWriteType();
[GetCBPeripheral() writeValue:nsdata_value
forCharacteristic:cb_characteristic_
diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_mac.h b/device/bluetooth/bluetooth_remote_gatt_descriptor_mac.h
index 8be9824..215d4f6 100644
--- a/device/bluetooth/bluetooth_remote_gatt_descriptor_mac.h
+++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_mac.h
@@ -5,18 +5,15 @@
#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_MAC_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_MAC_H_
-#include "base/memory/raw_ptr.h"
#include "device/bluetooth/bluetooth_remote_gatt_descriptor.h"
+#import <CoreBluetooth/CoreBluetooth.h>
+
#include <vector>
-#include "base/mac/scoped_nsobject.h"
+#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
-#if defined(__OBJC__)
-#import <CoreBluetooth/CoreBluetooth.h>
-#endif // defined(__OBJC__)
-
namespace device {
class BluetoothRemoteGattCharacteristicMac;
@@ -66,7 +63,7 @@
// gatt_characteristic_ owns instances of this class.
raw_ptr<BluetoothRemoteGattCharacteristicMac> gatt_characteristic_;
// Descriptor from CoreBluetooth.
- base::scoped_nsobject<CBDescriptor> cb_descriptor_;
+ CBDescriptor* __strong cb_descriptor_;
// Descriptor identifier.
std::string identifier_;
// Descriptor UUID.
diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_mac.mm b/device/bluetooth/bluetooth_remote_gatt_descriptor_mac.mm
index 408b331..0a1456a 100644
--- a/device/bluetooth/bluetooth_remote_gatt_descriptor_mac.mm
+++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_mac.mm
@@ -12,6 +12,10 @@
#include "device/bluetooth/bluetooth_low_energy_adapter_apple.h"
#import "device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
using base::mac::ObjCCast;
namespace device {
@@ -46,13 +50,12 @@
BluetoothRemoteGattDescriptorMac::BluetoothRemoteGattDescriptorMac(
BluetoothRemoteGattCharacteristicMac* characteristic,
CBDescriptor* descriptor)
- : gatt_characteristic_(characteristic),
- cb_descriptor_(descriptor, base::scoped_policy::RETAIN) {
+ : gatt_characteristic_(characteristic), cb_descriptor_(descriptor) {
uuid_ = BluetoothLowEnergyAdapterApple::BluetoothUUIDWithCBUUID(
[cb_descriptor_ UUID]);
identifier_ = base::SysNSStringToUTF8(
[NSString stringWithFormat:@"%s-%p", uuid_.canonical_value().c_str(),
- cb_descriptor_.get()]);
+ cb_descriptor_]);
}
std::string BluetoothRemoteGattDescriptorMac::GetIdentifier() const {
@@ -125,8 +128,8 @@
DVLOG(1) << *this << ": Write value.";
write_value_callbacks_ =
std::make_pair(std::move(callback), std::move(error_callback));
- base::scoped_nsobject<NSData> nsdata_value(
- [[NSData alloc] initWithBytes:value.data() length:value.size()]);
+ NSData* nsdata_value = [[NSData alloc] initWithBytes:value.data()
+ length:value.size()];
[GetCBPeripheral() writeValue:nsdata_value forDescriptor:GetCBDescriptor()];
}
diff --git a/device/bluetooth/bluetooth_remote_gatt_service_mac.h b/device/bluetooth/bluetooth_remote_gatt_service_mac.h
index 795d3a48..2f68cef 100644
--- a/device/bluetooth/bluetooth_remote_gatt_service_mac.h
+++ b/device/bluetooth/bluetooth_remote_gatt_service_mac.h
@@ -10,10 +10,13 @@
#include <string>
#include <vector>
-#include "base/mac/scoped_nsobject.h"
#include "base/memory/raw_ptr.h"
#include "device/bluetooth/bluetooth_remote_gatt_service.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
@class CBCharacteristic;
@class CBDescriptor;
@class CBPeripheral;
@@ -81,7 +84,7 @@
// bluetooth_device_mac_ owns instances of this class.
raw_ptr<BluetoothLowEnergyDeviceMac> bluetooth_device_mac_;
// A service from CBPeripheral.services.
- base::scoped_nsobject<CBService> service_;
+ CBService* __strong service_;
bool is_primary_;
// Service identifier.
std::string identifier_;
diff --git a/device/bluetooth/bluetooth_remote_gatt_service_mac.mm b/device/bluetooth/bluetooth_remote_gatt_service_mac.mm
index 83eb4a8..1ab4cc00 100644
--- a/device/bluetooth/bluetooth_remote_gatt_service_mac.mm
+++ b/device/bluetooth/bluetooth_remote_gatt_service_mac.mm
@@ -16,6 +16,10 @@
#include "device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace device {
BluetoothRemoteGattServiceMac::BluetoothRemoteGattServiceMac(
@@ -23,14 +27,13 @@
CBService* service,
bool is_primary)
: bluetooth_device_mac_(bluetooth_device_mac),
- service_(service, base::scoped_policy::RETAIN),
+ service_(service),
is_primary_(is_primary),
discovery_pending_count_(0) {
uuid_ =
BluetoothLowEnergyAdapterApple::BluetoothUUIDWithCBUUID([service_ UUID]);
- identifier_ = base::SysNSStringToUTF8(
- [NSString stringWithFormat:@"%s-%p", uuid_.canonical_value().c_str(),
- service_.get()]);
+ identifier_ = base::SysNSStringToUTF8([NSString
+ stringWithFormat:@"%s-%p", uuid_.canonical_value().c_str(), service_]);
}
BluetoothRemoteGattServiceMac::~BluetoothRemoteGattServiceMac() {}
diff --git a/device/bluetooth/bluetooth_rfcomm_channel_mac.h b/device/bluetooth/bluetooth_rfcomm_channel_mac.h
index 0190cbf..8e2c9ce 100644
--- a/device/bluetooth/bluetooth_rfcomm_channel_mac.h
+++ b/device/bluetooth/bluetooth_rfcomm_channel_mac.h
@@ -12,9 +12,12 @@
#include <memory>
-#include "base/mac/scoped_nsobject.h"
#include "device/bluetooth/bluetooth_channel_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
@class BluetoothRfcommChannelDelegate;
namespace device {
@@ -23,7 +26,6 @@
public:
// Creates a new RFCOMM channel wrapper with the given |socket| and native
// |channel|.
- // NOTE: The |channel| is expected to already be retained.
BluetoothRfcommChannelMac(BluetoothSocketMac* socket,
IOBluetoothRFCOMMChannel* channel);
@@ -61,10 +63,10 @@
private:
// The wrapped native RFCOMM channel.
- base::scoped_nsobject<IOBluetoothRFCOMMChannel> channel_;
+ IOBluetoothRFCOMMChannel* __strong channel_;
// The delegate for the native channel.
- base::scoped_nsobject<BluetoothRfcommChannelDelegate> delegate_;
+ BluetoothRfcommChannelDelegate* __strong delegate_;
};
} // namespace device
diff --git a/device/bluetooth/bluetooth_rfcomm_channel_mac.mm b/device/bluetooth/bluetooth_rfcomm_channel_mac.mm
index cacbbd146..fa681516 100644
--- a/device/bluetooth/bluetooth_rfcomm_channel_mac.mm
+++ b/device/bluetooth/bluetooth_rfcomm_channel_mac.mm
@@ -11,6 +11,10 @@
#include "device/bluetooth/bluetooth_classic_device_mac.h"
#include "device/bluetooth/bluetooth_socket_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
// A simple delegate class for an open RFCOMM channel that forwards methods to
// its wrapped |channel_|.
@interface BluetoothRfcommChannelDelegate
@@ -78,21 +82,15 @@
IOReturn* status) {
DCHECK(socket);
std::unique_ptr<BluetoothRfcommChannelMac> channel(
- new BluetoothRfcommChannelMac(socket, nil));
+ new BluetoothRfcommChannelMac(socket, /*channel=*/nil));
- // Retain the delegate, because IOBluetoothDevice's
- // |-openRFCOMMChannelAsync:withChannelID:delegate:| assumes that it can take
- // ownership of the delegate without calling |-retain| on it...
DCHECK(channel->delegate_);
- [channel->delegate_ retain];
IOBluetoothRFCOMMChannel* rfcomm_channel;
*status = [device openRFCOMMChannelAsync:&rfcomm_channel
withChannelID:channel_id
delegate:channel->delegate_];
if (*status == kIOReturnSuccess) {
- // Note: No need to retain the |rfcomm_channel| -- the returned channel is
- // already retained.
- channel->channel_.reset(rfcomm_channel);
+ channel->channel_ = rfcomm_channel;
} else {
channel.reset();
}
@@ -108,8 +106,7 @@
// Now that the socket is set, it's safe to associate a delegate, which can
// call back to the socket.
DCHECK(!delegate_);
- delegate_.reset(
- [[BluetoothRfcommChannelDelegate alloc] initWithChannel:this]);
+ delegate_ = [[BluetoothRfcommChannelDelegate alloc] initWithChannel:this];
[channel_ setDelegate:delegate_];
}
diff --git a/device/bluetooth/bluetooth_socket_mac.h b/device/bluetooth/bluetooth_socket_mac.h
index f891d85..efdaa95 100644
--- a/device/bluetooth/bluetooth_socket_mac.h
+++ b/device/bluetooth/bluetooth_socket_mac.h
@@ -13,13 +13,16 @@
#include <string>
#include "base/containers/queue.h"
-#include "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_refptr.h"
#include "base/threading/thread_checker.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_socket.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
@class BluetoothRfcommConnectionListener;
@class BluetoothL2capConnectionListener;
@@ -33,7 +36,7 @@
class BluetoothAdapterMac;
class BluetoothChannelMac;
-// Implements the BluetoothSocket class for the Mac OS X platform.
+// Implements the BluetoothSocket class for the macOS platform.
class BluetoothSocketMac : public BluetoothSocket {
public:
static scoped_refptr<BluetoothSocketMac> CreateSocket();
@@ -125,9 +128,9 @@
int buffer_size;
SendCompletionCallback success_callback;
ErrorCompletionCallback error_callback;
- IOReturn status;
- int active_async_writes;
- bool error_signaled;
+ IOReturn status = kIOReturnSuccess;
+ int active_async_writes = 0;
+ bool error_signaled = false;
};
struct ReceiveCallbacks {
@@ -167,14 +170,12 @@
// Simple helpers that register for OS notifications and forward them to
// |this| profile.
- base::scoped_nsobject<BluetoothRfcommConnectionListener>
- rfcomm_connection_listener_;
- base::scoped_nsobject<BluetoothL2capConnectionListener>
- l2cap_connection_listener_;
+ BluetoothRfcommConnectionListener* __strong rfcomm_connection_listener_;
+ BluetoothL2capConnectionListener* __strong l2cap_connection_listener_;
// The service record registered in the system SDP server, used to
// eventually unregister the service.
- base::scoped_nsobject<IOBluetoothSDPServiceRecord> service_record_;
+ IOBluetoothSDPServiceRecord* __strong service_record_;
// The channel used to issue commands.
std::unique_ptr<BluetoothChannelMac> channel_;
diff --git a/device/bluetooth/bluetooth_socket_mac.mm b/device/bluetooth/bluetooth_socket_mac.mm
index 229593c..58957ba 100644
--- a/device/bluetooth/bluetooth_socket_mac.mm
+++ b/device/bluetooth/bluetooth_socket_mac.mm
@@ -4,8 +4,6 @@
#include "device/bluetooth/bluetooth_socket_mac.h"
-#include "base/memory/raw_ptr.h"
-
#import <IOBluetooth/IOBluetooth.h>
#include <stdint.h>
@@ -20,6 +18,7 @@
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/mac/scoped_cftyperef.h"
+#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
@@ -35,6 +34,10 @@
#include "net/base/net_errors.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
using device::BluetoothSocket;
// A simple helper class that forwards SDP query completed notifications to its
@@ -49,7 +52,7 @@
BluetoothSocket::ErrorCompletionCallback _error_callback;
// The device being queried.
- IOBluetoothDevice* _device; // weak
+ IOBluetoothDevice* __weak _device;
}
- (instancetype)initWithSocket:(scoped_refptr<device::BluetoothSocketMac>)socket
@@ -84,7 +87,6 @@
// target is specified.
std::move(_error_callback).Run("No target");
}
- [super dealloc];
}
- (void)sdpQueryComplete:(IOBluetoothDevice*)device status:(IOReturn)status {
@@ -104,7 +106,7 @@
// The OS mechanism used to subscribe to and unsubscribe from RFCOMM channel
// creation notifications.
- IOBluetoothUserNotification* _rfcommNewChannelNotification; // weak
+ IOBluetoothUserNotification* __weak _rfcommNewChannelNotification;
}
- (instancetype)initWithSocket:(device::BluetoothSocketMac*)socket
@@ -137,7 +139,6 @@
- (void)dealloc {
[_rfcommNewChannelNotification unregister];
- [super dealloc];
}
- (void)rfcommChannelOpened:(IOBluetoothUserNotification*)notification
@@ -152,7 +153,8 @@
}
_socket->OnChannelOpened(std::unique_ptr<device::BluetoothChannelMac>(
- new device::BluetoothRfcommChannelMac(NULL, [rfcommChannel retain])));
+ new device::BluetoothRfcommChannelMac(/*socket=*/nullptr,
+ rfcommChannel)));
}
@end
@@ -166,7 +168,7 @@
// The OS mechanism used to subscribe to and unsubscribe from L2CAP channel
// creation notifications.
- IOBluetoothUserNotification* _l2capNewChannelNotification; // weak
+ IOBluetoothUserNotification* __weak _l2capNewChannelNotification;
}
- (instancetype)initWithSocket:(device::BluetoothSocketMac*)socket
@@ -199,7 +201,6 @@
- (void)dealloc {
[_l2capNewChannelNotification unregister];
- [super dealloc];
}
- (void)l2capChannelOpened:(IOBluetoothUserNotification*)notification
@@ -214,7 +215,7 @@
}
_socket->OnChannelOpened(std::unique_ptr<device::BluetoothChannelMac>(
- new device::BluetoothL2capChannelMac(NULL, [l2capChannel retain])));
+ new device::BluetoothL2capChannelMac(/*socket=*/nullptr, l2capChannel)));
}
@end
@@ -274,7 +275,7 @@
}
const int kUUIDsKey = kBluetoothSDPAttributeIdentifierServiceClassIDList;
- NSArray* uuids = @[GetIOBluetoothSDPUUID(uuid)];
+ NSArray* uuids = @[ GetIOBluetoothSDPUUID(uuid) ];
service_definition[IntToNSString(kUUIDsKey)] = uuids;
const int kProtocolDefinitionsKey =
@@ -442,8 +443,7 @@
device:device
success_callback:std::move(success_callback)
error_callback:std::move(error_callback)];
- [device performSDPQuery:[listener autorelease]
- uuids:@[GetIOBluetoothSDPUUID(uuid_)]];
+ [device performSDPQuery:listener uuids:@[ GetIOBluetoothSDPUUID(uuid_) ]];
}
void BluetoothSocketMac::ListenUsingRfcomm(
@@ -459,17 +459,16 @@
DVLOG(1) << uuid_.canonical_value() << ": Registering RFCOMM service.";
BluetoothRFCOMMChannelID registered_channel_id;
- service_record_.reset(
- RegisterRfcommService(uuid, options, ®istered_channel_id));
- if (!service_record_.get()) {
+ service_record_ =
+ RegisterRfcommService(uuid, options, ®istered_channel_id);
+ if (!service_record_) {
std::move(error_callback).Run(kInvalidOrUsedChannel);
return;
}
- rfcomm_connection_listener_.reset(
- [[BluetoothRfcommConnectionListener alloc]
- initWithSocket:this
- channelID:registered_channel_id]);
+ rfcomm_connection_listener_ = [[BluetoothRfcommConnectionListener alloc]
+ initWithSocket:this
+ channelID:registered_channel_id];
std::move(success_callback).Run();
}
@@ -487,15 +486,15 @@
DVLOG(1) << uuid_.canonical_value() << ": Registering L2CAP service.";
BluetoothL2CAPPSM registered_psm;
- service_record_.reset(RegisterL2capService(uuid, options, ®istered_psm));
- if (!service_record_.get()) {
+ service_record_ = RegisterL2capService(uuid, options, ®istered_psm);
+ if (!service_record_) {
std::move(error_callback).Run(kInvalidOrUsedPsm);
return;
}
- l2cap_connection_listener_.reset(
+ l2cap_connection_listener_ =
[[BluetoothL2capConnectionListener alloc] initWithSocket:this
- psm:registered_psm]);
+ psm:registered_psm];
std::move(success_callback).Run();
}
@@ -631,10 +630,11 @@
void BluetoothSocketMac::Disconnect(base::OnceClosure callback) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (channel_)
+ if (channel_) {
ReleaseChannel();
- else if (service_record_.get())
+ } else if (service_record_) {
ReleaseListener();
+ }
std::move(callback).Run();
}
@@ -856,24 +856,23 @@
DVLOG(1) << uuid_.canonical_value() << ": Accept complete.";
}
-BluetoothSocketMac::AcceptRequest::AcceptRequest() {}
+BluetoothSocketMac::AcceptRequest::AcceptRequest() = default;
-BluetoothSocketMac::AcceptRequest::~AcceptRequest() {}
+BluetoothSocketMac::AcceptRequest::~AcceptRequest() = default;
-BluetoothSocketMac::SendRequest::SendRequest()
- : status(kIOReturnSuccess), active_async_writes(0), error_signaled(false) {}
+BluetoothSocketMac::SendRequest::SendRequest() = default;
-BluetoothSocketMac::SendRequest::~SendRequest() {}
+BluetoothSocketMac::SendRequest::~SendRequest() = default;
-BluetoothSocketMac::ReceiveCallbacks::ReceiveCallbacks() {}
+BluetoothSocketMac::ReceiveCallbacks::ReceiveCallbacks() = default;
-BluetoothSocketMac::ReceiveCallbacks::~ReceiveCallbacks() {}
+BluetoothSocketMac::ReceiveCallbacks::~ReceiveCallbacks() = default;
-BluetoothSocketMac::ConnectCallbacks::ConnectCallbacks() {}
+BluetoothSocketMac::ConnectCallbacks::ConnectCallbacks() = default;
-BluetoothSocketMac::ConnectCallbacks::~ConnectCallbacks() {}
+BluetoothSocketMac::ConnectCallbacks::~ConnectCallbacks() = default;
-BluetoothSocketMac::BluetoothSocketMac() {}
+BluetoothSocketMac::BluetoothSocketMac() = default;
BluetoothSocketMac::~BluetoothSocketMac() {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -895,12 +894,12 @@
void BluetoothSocketMac::ReleaseListener() {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(service_record_.get());
+ DCHECK(service_record_);
[service_record_ removeServiceRecord];
- service_record_.reset();
- rfcomm_connection_listener_.reset();
- l2cap_connection_listener_.reset();
+ service_record_ = nil;
+ rfcomm_connection_listener_ = nil;
+ l2cap_connection_listener_ = nil;
// Destroying the listener above prevents the callback delegate from being
// called so it is now safe to release all callback state.
diff --git a/device/bluetooth/test/bluetooth_test_mac.h b/device/bluetooth/test/bluetooth_test_mac.h
index 9501888..1bd44293 100644
--- a/device/bluetooth/test/bluetooth_test_mac.h
+++ b/device/bluetooth/test/bluetooth_test_mac.h
@@ -15,10 +15,6 @@
@class MockCBDescriptor;
@class MockCBCharacteristic;
@class MockCBPeripheral;
-#else // __OBJC__
-class MockCBDescriptor;
-class MockCBCharacteristic;
-class MockCBPeripheral;
#endif // __OBJC__
namespace device {
@@ -181,6 +177,8 @@
protected:
class ScopedMockCentralManager;
+#if __OBJC__
+
// Returns MockCBPeripheral from BluetoothDevice.
MockCBPeripheral* GetMockCBPeripheral(BluetoothDevice* device) const;
// Returns MockCBPeripheral from BluetoothRemoteGattService.
@@ -199,6 +197,8 @@
MockCBDescriptor* GetCBMockDescriptor(
BluetoothRemoteGattDescriptor* descriptor) const;
+#endif // __OBJC__
+
// Utility function for finding CBUUIDs with relatively nice SHA256 hashes.
std::string FindCBUUIDForHashTarget();
@@ -211,7 +211,7 @@
};
// Defines common test fixture name. Use TEST_F(BluetoothTest, YourTestName).
-typedef BluetoothTestMac BluetoothTest;
+using BluetoothTest = BluetoothTestMac;
} // namespace device
diff --git a/device/bluetooth/test/bluetooth_test_mac.mm b/device/bluetooth/test/bluetooth_test_mac.mm
index 1b53d72..62f23d0 100644
--- a/device/bluetooth/test/bluetooth_test_mac.mm
+++ b/device/bluetooth/test/bluetooth_test_mac.mm
@@ -16,6 +16,7 @@
#include "build/build_config.h"
#import "device/bluetooth/bluetooth_device_mac.h"
#include "device/bluetooth/bluetooth_low_energy_adapter_apple.h"
+#include "device/bluetooth/bluetooth_low_energy_central_manager_delegate.h"
#import "device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h"
#import "device/bluetooth/bluetooth_remote_gatt_descriptor_mac.h"
#import "device/bluetooth/bluetooth_remote_gatt_service_mac.h"
@@ -32,8 +33,11 @@
#import "device/bluetooth/bluetooth_adapter_mac.h"
#endif
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
using base::mac::ObjCCast;
-using base::scoped_nsobject;
namespace device {
@@ -41,7 +45,7 @@
class BluetoothTestMac::ScopedMockCentralManager {
public:
explicit ScopedMockCentralManager(MockCentralManager* mock_central_manager) {
- mock_central_manager_.reset(mock_central_manager);
+ mock_central_manager_ = mock_central_manager;
}
ScopedMockCentralManager(const ScopedMockCentralManager&) = delete;
@@ -51,21 +55,20 @@
MockCentralManager* get() { return mock_central_manager_; }
private:
- scoped_nsobject<MockCentralManager> mock_central_manager_;
+ MockCentralManager* __strong mock_central_manager_;
};
namespace {
-scoped_nsobject<NSDictionary> CreateAdvertisementData(
- NSString* name,
- NSArray* uuids,
- NSDictionary* service_data,
- NSData* manufacturer_data,
- NSNumber* tx_power) {
- NSMutableDictionary* advertisement_data(
+NSDictionary* AdvertisementData(NSString* name,
+ NSArray* uuids,
+ NSDictionary* service_data,
+ NSData* manufacturer_data,
+ NSNumber* tx_power) {
+ NSMutableDictionary* advertisement_data =
[NSMutableDictionary dictionaryWithDictionary:@{
CBAdvertisementDataIsConnectable : @YES
- }]);
+ }];
if (name) {
advertisement_data[CBAdvertisementDataLocalNameKey] = name;
@@ -88,8 +91,7 @@
advertisement_data[CBAdvertisementDataTxPowerLevelKey] = tx_power;
}
- return scoped_nsobject<NSDictionary>(advertisement_data,
- base::scoped_policy::RETAIN);
+ return advertisement_data;
}
} // namespace
@@ -103,9 +105,9 @@
// Fake error domain for testing error metrics
static NSString* const kDisconnectErrorDomain = @"FakeDisconnectErrorDomain";
-BluetoothTestMac::BluetoothTestMac() : BluetoothTestBase() {}
+BluetoothTestMac::BluetoothTestMac() = default;
-BluetoothTestMac::~BluetoothTestMac() {}
+BluetoothTestMac::~BluetoothTestMac() = default;
void BluetoothTestMac::SetUp() {}
@@ -281,15 +283,15 @@
manufacturer_data = nil;
tx_power = nil;
}
- scoped_nsobject<MockCBPeripheral> mock_peripheral([[MockCBPeripheral alloc]
- initWithUTF8StringIdentifier:identifier
- name:name]);
+ MockCBPeripheral* mock_peripheral =
+ [[MockCBPeripheral alloc] initWithUTF8StringIdentifier:identifier
+ name:name];
[mock_peripheral setBluetoothTestMac:this];
[central_manager_delegate
centralManager:central_manager
didDiscoverPeripheral:[mock_peripheral peripheral]
- advertisementData:CreateAdvertisementData(name, uuids, service_data,
- manufacturer_data, tx_power)
+ advertisementData:AdvertisementData(name, uuids, service_data,
+ manufacturer_data, tx_power)
RSSI:rssi];
return observer.last_device();
}
@@ -307,7 +309,7 @@
ConnectedDeviceType device_ordinal) {
const char* identifier = nullptr;
NSString* name = nil;
- scoped_nsobject<NSMutableSet> cbUUIDs([[NSMutableSet alloc] init]);
+ NSMutableSet* cbUUIDs = [[NSMutableSet alloc] init];
switch (device_ordinal) {
case ConnectedDeviceType::GENERIC_DEVICE:
name = @(kTestDeviceName);
@@ -324,9 +326,9 @@
DCHECK(name);
DCHECK(identifier);
DCHECK([cbUUIDs count] > 0);
- scoped_nsobject<MockCBPeripheral> mock_peripheral([[MockCBPeripheral alloc]
- initWithUTF8StringIdentifier:identifier
- name:name]);
+ MockCBPeripheral* mock_peripheral =
+ [[MockCBPeripheral alloc] initWithUTF8StringIdentifier:identifier
+ name:name];
[mock_peripheral setBluetoothTestMac:this];
[mock_central_manager_->get()
setConnectedMockPeripheral:[mock_peripheral peripheral]
@@ -419,8 +421,8 @@
const std::vector<uint8_t>& value) {
MockCBCharacteristic* characteristic_mock =
GetCBMockCharacteristic(characteristic);
- scoped_nsobject<NSData> data(
- [[NSData alloc] initWithBytes:value.data() length:value.size()]);
+ NSData* data = [[NSData alloc] initWithBytes:value.data()
+ length:value.size()];
[characteristic_mock simulateReadWithValue:data error:nil];
}
@@ -500,8 +502,8 @@
const std::vector<uint8_t>& value) {
MockCBCharacteristic* characteristic_mock =
GetCBMockCharacteristic(characteristic);
- scoped_nsobject<NSData> data(
- [[NSData alloc] initWithBytes:value.data() length:value.size()]);
+ NSData* data = [[NSData alloc] initWithBytes:value.data()
+ length:value.size()];
[characteristic_mock simulateGattCharacteristicChangedWithValue:data];
}
@@ -633,8 +635,8 @@
void BluetoothTestMac::SimulateGattDescriptorReadNSDataMac(
BluetoothRemoteGattDescriptor* descriptor,
const std::vector<uint8_t>& value) {
- scoped_nsobject<NSData> data(
- [[NSData alloc] initWithBytes:value.data() length:value.size()]);
+ NSData* data = [[NSData alloc] initWithBytes:value.data()
+ length:value.size()];
[GetCBMockDescriptor(descriptor) simulateReadWithValue:data error:nil];
}
@@ -689,7 +691,7 @@
void BluetoothTest::AddServicesToDeviceMac(
BluetoothDevice* device,
const std::vector<std::string>& uuids) {
- scoped_nsobject<NSMutableArray> services([[NSMutableArray alloc] init]);
+ NSMutableArray* services = [[NSMutableArray alloc] init];
for (auto uuid : uuids) {
CBUUID* cb_service_uuid = [CBUUID UUIDWithString:@(uuid.c_str())];
[services addObject:cb_service_uuid];
diff --git a/device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm b/device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm
index 65e9a89..f7c9857f 100644
--- a/device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm
+++ b/device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.mm
@@ -5,12 +5,14 @@
#include "device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h"
#include "base/mac/foundation_util.h"
-#include "base/mac/scoped_nsobject.h"
#include "device/bluetooth/bluetooth_gatt_characteristic.h"
#include "device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.h"
using base::mac::ObjCCast;
-using base::scoped_nsobject;
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
namespace device {
@@ -92,10 +94,10 @@
@interface MockCBCharacteristic () {
// Owner of this instance.
CBService* _service;
- scoped_nsobject<CBUUID> _UUID;
+ CBUUID* __strong _UUID;
CBCharacteristicProperties _cb_properties;
- scoped_nsobject<NSMutableArray> _descriptors;
- scoped_nsobject<NSObject> _value;
+ NSMutableArray* __strong _descriptors;
+ NSObject* __strong _value;
BOOL _notifying;
}
@end
@@ -108,11 +110,11 @@
self = [super init];
if (self) {
_service = service;
- _UUID.reset([uuid retain]);
+ _UUID = uuid;
_cb_properties =
device::GattCharacteristicPropertyToCBCharacteristicProperty(
properties);
- _descriptors.reset([[NSMutableArray alloc] init]);
+ _descriptors = [[NSMutableArray alloc] init];
}
return self;
}
@@ -134,7 +136,7 @@
}
- (void)simulateReadWithValue:(id)value error:(NSError*)error {
- _value.reset([value copy]);
+ _value = [value copy];
CBPeripheral* peripheral = _service.peripheral;
[peripheral.delegate peripheral:peripheral
didUpdateValueForCharacteristic:self.characteristic
@@ -181,7 +183,7 @@
}
- (void)simulateGattCharacteristicChangedWithValue:(NSData*)value {
- _value.reset([value copy]);
+ _value = [value copy];
CBPeripheral* peripheral = _service.peripheral;
[peripheral.delegate peripheral:peripheral
didUpdateValueForCharacteristic:self.characteristic
@@ -189,9 +191,9 @@
}
- (void)addDescriptorWithUUID:(CBUUID*)uuid {
- scoped_nsobject<MockCBDescriptor> descriptor_mock([[MockCBDescriptor alloc]
- initWithCharacteristic:self.characteristic
- CBUUID:uuid]);
+ MockCBDescriptor* descriptor_mock =
+ [[MockCBDescriptor alloc] initWithCharacteristic:self.characteristic
+ CBUUID:uuid];
[_descriptors addObject:descriptor_mock];
}
diff --git a/device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.mm b/device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.mm
index b17ebb9..2f6ef81 100644
--- a/device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.mm
+++ b/device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.mm
@@ -5,17 +5,19 @@
#include "device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.h"
#include "base/mac/foundation_util.h"
-#include "base/mac/scoped_nsobject.h"
#include "device/bluetooth/bluetooth_gatt_characteristic.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
using base::mac::ObjCCast;
-using base::scoped_nsobject;
@interface MockCBDescriptor () {
// Owner of this instance.
CBCharacteristic* _characteristic;
- scoped_nsobject<CBUUID> _UUID;
- scoped_nsobject<NSData> _value;
+ CBUUID* __strong _UUID;
+ NSData* __strong _value;
}
@end
@@ -26,7 +28,7 @@
self = [super init];
if (self) {
_characteristic = characteristic;
- _UUID.reset([uuid retain]);
+ _UUID = uuid;
}
return self;
}
@@ -64,7 +66,7 @@
}
- (void)simulateReadWithValue:(id)value error:(NSError*)error {
- _value.reset([value copy]);
+ _value = [value copy];
CBPeripheral* peripheral = _characteristic.service.peripheral;
[peripheral.delegate peripheral:peripheral
didUpdateValueForDescriptor:self.descriptor
diff --git a/device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h b/device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h
index 90525fc..e581127 100644
--- a/device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h
+++ b/device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h
@@ -20,11 +20,11 @@
@interface MockCBPeripheral : NSObject
@property(nonatomic, readonly) CBPeripheralState state;
-@property(nonatomic, readonly) NSUUID* identifier;
+@property(nonatomic, strong, readonly) NSUUID* identifier;
@property(nonatomic, readonly) NSString* name;
-@property(nonatomic, assign) id<CBPeripheralDelegate> delegate;
+@property(nonatomic, weak) id<CBPeripheralDelegate> delegate;
@property(nonatomic, readonly) CBPeripheral* peripheral;
-@property(retain, readonly) NSArray* services;
+@property(strong, readonly) NSArray* services;
@property(nonatomic, assign) device::BluetoothTestMac* bluetoothTestMac;
- (instancetype)init NS_UNAVAILABLE;
diff --git a/device/bluetooth/test/mock_bluetooth_cbperipheral_mac.mm b/device/bluetooth/test/mock_bluetooth_cbperipheral_mac.mm
index 617fd95..b4a25285 100644
--- a/device/bluetooth/test/mock_bluetooth_cbperipheral_mac.mm
+++ b/device/bluetooth/test/mock_bluetooth_cbperipheral_mac.mm
@@ -5,26 +5,24 @@
#include "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h"
#include "base/mac/foundation_util.h"
-#include "base/mac/scoped_nsobject.h"
#include "device/bluetooth/test/bluetooth_test_mac.h"
#include "device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h"
#include "device/bluetooth/test/mock_bluetooth_cbdescriptor_mac.h"
#include "device/bluetooth/test/mock_bluetooth_cbservice_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
using base::mac::ObjCCast;
-using base::scoped_nsobject;
-@interface MockCBPeripheral () {
- scoped_nsobject<NSUUID> _identifier;
- scoped_nsobject<NSString> _name;
- id<CBPeripheralDelegate> _delegate;
- scoped_nsobject<NSMutableArray> _services;
+@implementation MockCBPeripheral {
+ NSUUID* __strong _identifier;
+ NSString* __strong _name;
+ id<CBPeripheralDelegate> __weak _delegate;
+ NSMutableArray* __strong _services;
}
-@end
-
-@implementation MockCBPeripheral
-
@synthesize state = _state;
@synthesize delegate = _delegate;
@synthesize bluetoothTestMac = _bluetoothTestMac;
@@ -40,18 +38,15 @@
- (instancetype)initWithUTF8StringIdentifier:(const char*)utf8Identifier
name:(NSString*)name {
- scoped_nsobject<NSUUID> identifier(
- [[NSUUID alloc] initWithUUIDString:@(utf8Identifier)]);
+ NSUUID* identifier = [[NSUUID alloc] initWithUUIDString:@(utf8Identifier)];
return [self initWithIdentifier:identifier name:name];
}
- (instancetype)initWithIdentifier:(NSUUID*)identifier name:(NSString*)name {
self = [super init];
if (self) {
- _identifier.reset([identifier retain]);
- if (name) {
- _name.reset([name retain]);
- }
+ _identifier = identifier;
+ _name = name;
_state = CBPeripheralStateDisconnected;
}
return self;
@@ -76,7 +71,7 @@
- (void)setState:(CBPeripheralState)state {
_state = state;
if (_state == CBPeripheralStateDisconnected) {
- _services.reset();
+ _services = nil;
}
}
@@ -128,13 +123,13 @@
- (void)addServices:(NSArray*)services {
if (!_services) {
- _services.reset([[NSMutableArray alloc] init]);
+ _services = [[NSMutableArray alloc] init];
}
for (CBUUID* uuid in services) {
- base::scoped_nsobject<MockCBService> service([[MockCBService alloc]
- initWithPeripheral:self.peripheral
- CBUUID:uuid
- primary:YES]);
+ MockCBService* service =
+ [[MockCBService alloc] initWithPeripheral:self.peripheral
+ CBUUID:uuid
+ primary:YES];
[_services addObject:[service service]];
}
}
@@ -144,11 +139,9 @@
}
- (void)removeService:(CBService*)service {
- base::scoped_nsobject<CBService> serviceToRemove(service,
- base::scoped_policy::RETAIN);
- DCHECK(serviceToRemove);
- [_services removeObject:serviceToRemove];
- [self didModifyServices:@[ serviceToRemove ]];
+ DCHECK(service);
+ [_services removeObject:service];
+ [self didModifyServices:@[ service ]];
}
- (void)mockDidDiscoverServices {
@@ -189,7 +182,7 @@
// -[CBPeripheral discoverCharacteristics:forService:] for each services,
// so -[<CBPeripheralDelegate peripheral:didDiscoverCharacteristicsForService:
// error:] needs to be called for all services.
- for (CBService* service in _services.get()) {
+ for (CBService* service in _services) {
[self mockDidDiscoverCharacteristicsForService:service];
for (CBCharacteristic* characteristic in service.characteristics) {
// After discovering services, BluetoothLowEnergyDeviceMac is expected to
diff --git a/device/bluetooth/test/mock_bluetooth_cbservice_mac.h b/device/bluetooth/test/mock_bluetooth_cbservice_mac.h
index 6a087de..3c4ab2a9 100644
--- a/device/bluetooth/test/mock_bluetooth_cbservice_mac.h
+++ b/device/bluetooth/test/mock_bluetooth_cbservice_mac.h
@@ -23,8 +23,8 @@
primary:(BOOL)isPrimary;
// Creates and adds a mock characteristic.
-- (void)addCharacteristicWithUUID:(CBUUID*)cb_uuid properties:(int)properties;
-- (void)removeCharacteristicMock:(MockCBCharacteristic*)characteristic_mock;
+- (void)addCharacteristicWithUUID:(CBUUID*)uuid properties:(int)properties;
+- (void)removeCharacteristicMock:(MockCBCharacteristic*)characteristicMock;
@end
diff --git a/device/bluetooth/test/mock_bluetooth_cbservice_mac.mm b/device/bluetooth/test/mock_bluetooth_cbservice_mac.mm
index fe41b91d..0ebc6178 100644
--- a/device/bluetooth/test/mock_bluetooth_cbservice_mac.mm
+++ b/device/bluetooth/test/mock_bluetooth_cbservice_mac.mm
@@ -5,19 +5,21 @@
#include "device/bluetooth/test/mock_bluetooth_cbservice_mac.h"
#include "base/mac/foundation_util.h"
-#include "base/mac/scoped_nsobject.h"
#include "device/bluetooth/test/bluetooth_test.h"
#include "device/bluetooth/test/mock_bluetooth_cbcharacteristic_mac.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
using base::mac::ObjCCast;
-using base::scoped_nsobject;
@interface MockCBService () {
// Owner of this instance.
- CBPeripheral* _peripheral;
- scoped_nsobject<CBUUID> _UUID;
+ CBPeripheral* __weak _peripheral;
+ CBUUID* __strong _UUID;
BOOL _primary;
- scoped_nsobject<NSMutableArray> _characteristics;
+ NSMutableArray* __strong _characteristics;
}
@end
@@ -31,10 +33,10 @@
primary:(BOOL)isPrimary {
self = [super init];
if (self) {
- _UUID.reset([uuid retain]);
+ _UUID = uuid;
_primary = isPrimary;
_peripheral = peripheral;
- _characteristics.reset([[NSMutableArray alloc] init]);
+ _characteristics = [[NSMutableArray alloc] init];
}
return self;
}
@@ -64,15 +66,15 @@
}
- (void)addCharacteristicWithUUID:(CBUUID*)cb_uuid properties:(int)properties {
- scoped_nsobject<MockCBCharacteristic> characteristic_mock(
+ MockCBCharacteristic* characteristicMock =
[[MockCBCharacteristic alloc] initWithService:self.service
CBUUID:cb_uuid
- properties:properties]);
- [_characteristics addObject:characteristic_mock];
+ properties:properties];
+ [_characteristics addObject:characteristicMock];
}
-- (void)removeCharacteristicMock:(MockCBCharacteristic*)characteristic_mock {
- [_characteristics removeObject:characteristic_mock];
+- (void)removeCharacteristicMock:(MockCBCharacteristic*)characteristicMock {
+ [_characteristics removeObject:characteristicMock];
}
- (CBService*)service {
diff --git a/device/bluetooth/test/mock_bluetooth_central_manager_mac.h b/device/bluetooth/test/mock_bluetooth_central_manager_mac.h
index 61702b0..8b0ad4f2 100644
--- a/device/bluetooth/test/mock_bluetooth_central_manager_mac.h
+++ b/device/bluetooth/test/mock_bluetooth_central_manager_mac.h
@@ -20,7 +20,7 @@
@property(nonatomic, assign) NSInteger scanForPeripheralsCallCount;
@property(nonatomic, assign) NSInteger stopScanCallCount;
-@property(nonatomic, assign) id<CBCentralManagerDelegate> delegate;
+@property(nonatomic, weak) id<CBCentralManagerDelegate> delegate;
@property(nonatomic, assign) CBManagerState state;
@property(nonatomic, assign) device::BluetoothTestMac* bluetoothTestMac;
@property(nonatomic, readonly) NSArray* retrieveConnectedPeripheralServiceUUIDs;
diff --git a/device/bluetooth/test/mock_bluetooth_central_manager_mac.mm b/device/bluetooth/test/mock_bluetooth_central_manager_mac.mm
index 416d62a..4c4ccd225 100644
--- a/device/bluetooth/test/mock_bluetooth_central_manager_mac.mm
+++ b/device/bluetooth/test/mock_bluetooth_central_manager_mac.mm
@@ -5,15 +5,16 @@
#import "device/bluetooth/test/mock_bluetooth_central_manager_mac.h"
#import "base/mac/foundation_util.h"
-#import "base/mac/scoped_nsobject.h"
#import "device/bluetooth/test/bluetooth_test_mac.h"
#import "device/bluetooth/test/mock_bluetooth_cbperipheral_mac.h"
-using base::scoped_nsobject;
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
@implementation MockCentralManager {
- scoped_nsobject<NSMutableDictionary> _connectedMockPeripheralPerServiceUUID;
- scoped_nsobject<NSMutableArray> _retrieveConnectedPeripheralServiceUUIDs;
+ NSMutableDictionary* __strong _connectedMockPeripheralPerServiceUUID;
+ NSMutableArray* __strong _retrieveConnectedPeripheralServiceUUIDs;
}
@synthesize scanForPeripheralsCallCount = _scanForPeripheralsCallCount;
@@ -25,10 +26,8 @@
- (instancetype)init {
self = [super init];
if (self) {
- _connectedMockPeripheralPerServiceUUID.reset(
- [[NSMutableDictionary alloc] init]);
- _retrieveConnectedPeripheralServiceUUIDs.reset(
- [[NSMutableArray alloc] init]);
+ _connectedMockPeripheralPerServiceUUID = [[NSMutableDictionary alloc] init];
+ _retrieveConnectedPeripheralServiceUUIDs = [[NSMutableArray alloc] init];
}
return self;
}
@@ -78,7 +77,7 @@
}
- (NSArray*)retrieveConnectedPeripheralServiceUUIDs {
- return [[_retrieveConnectedPeripheralServiceUUIDs copy] autorelease];
+ return _retrieveConnectedPeripheralServiceUUIDs;
}
- (NSArray*)retrieveConnectedPeripheralsWithServices:(NSArray*)services {