Commit 04cb0791 authored by Ovidio Henriquez's avatar Ovidio Henriquez Committed by Commit Bot

bluetooth_socket_mac.h callbacks to Once

This change converts all of the base::Bind and base::Callback to their
Once counterparts for bluetooth_socket_mac.{h,mm}. This change also
affects any files that interact with this class.

Bug: 1007780
Change-Id: If3c6b2e24ecd3cac18a9a726fa7b5e78d00b05e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1904529Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarMatt Reynolds <mattreynolds@chromium.org>
Commit-Queue: Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717701}
parent e006639c
...@@ -245,7 +245,7 @@ void BluetoothClassicDeviceMac::ConnectToService( ...@@ -245,7 +245,7 @@ void BluetoothClassicDeviceMac::ConnectToService(
const ConnectToServiceCallback& callback, const ConnectToServiceCallback& callback,
const ConnectToServiceErrorCallback& error_callback) { const ConnectToServiceErrorCallback& error_callback) {
scoped_refptr<BluetoothSocketMac> socket = BluetoothSocketMac::CreateSocket(); scoped_refptr<BluetoothSocketMac> socket = BluetoothSocketMac::CreateSocket();
socket->Connect(device_.get(), uuid, base::Bind(callback, socket), socket->Connect(device_.get(), uuid, base::BindOnce(callback, socket),
error_callback); error_callback);
} }
......
...@@ -46,7 +46,7 @@ class BluetoothSocketMac : public BluetoothSocket { ...@@ -46,7 +46,7 @@ class BluetoothSocketMac : public BluetoothSocket {
// called with a message explaining the cause of failure. // called with a message explaining the cause of failure.
void Connect(IOBluetoothDevice* device, void Connect(IOBluetoothDevice* device,
const BluetoothUUID& uuid, const BluetoothUUID& uuid,
const base::Closure& success_callback, base::OnceClosure success_callback,
const ErrorCompletionCallback& error_callback); const ErrorCompletionCallback& error_callback);
// Listens for incoming RFCOMM connections using this socket: Publishes an // Listens for incoming RFCOMM connections using this socket: Publishes an
...@@ -92,11 +92,10 @@ class BluetoothSocketMac : public BluetoothSocket { ...@@ -92,11 +92,10 @@ class BluetoothSocketMac : public BluetoothSocket {
// |status| is the returned status from the SDP query, |device| is the // |status| is the returned status from the SDP query, |device| is the
// IOBluetoothDevice for which the query was made. The remaining // IOBluetoothDevice for which the query was made. The remaining
// parameters are those from |Connect()|. // parameters are those from |Connect()|.
void OnSDPQueryComplete( void OnSDPQueryComplete(IOReturn status,
IOReturn status, IOBluetoothDevice* device,
IOBluetoothDevice* device, base::OnceClosure success_callback,
const base::Closure& success_callback, const ErrorCompletionCallback& error_callback);
const ErrorCompletionCallback& error_callback);
// Called by BluetoothRfcommConnectionListener and // Called by BluetoothRfcommConnectionListener and
// BluetoothL2capConnectionListener. // BluetoothL2capConnectionListener.
...@@ -140,7 +139,7 @@ class BluetoothSocketMac : public BluetoothSocket { ...@@ -140,7 +139,7 @@ class BluetoothSocketMac : public BluetoothSocket {
struct ConnectCallbacks { struct ConnectCallbacks {
ConnectCallbacks(); ConnectCallbacks();
~ConnectCallbacks(); ~ConnectCallbacks();
base::Closure success_callback; base::OnceClosure success_callback;
ErrorCompletionCallback error_callback; ErrorCompletionCallback error_callback;
}; };
......
...@@ -43,7 +43,7 @@ using device::BluetoothSocket; ...@@ -43,7 +43,7 @@ using device::BluetoothSocket;
scoped_refptr<device::BluetoothSocketMac> socket_; scoped_refptr<device::BluetoothSocketMac> socket_;
// Callbacks associated with the request that triggered this SDP query. // Callbacks associated with the request that triggered this SDP query.
base::Closure success_callback_; base::OnceClosure success_callback_;
BluetoothSocket::ErrorCompletionCallback error_callback_; BluetoothSocket::ErrorCompletionCallback error_callback_;
// The device being queried. // The device being queried.
...@@ -52,7 +52,7 @@ using device::BluetoothSocket; ...@@ -52,7 +52,7 @@ using device::BluetoothSocket;
- (id)initWithSocket:(scoped_refptr<device::BluetoothSocketMac>)socket - (id)initWithSocket:(scoped_refptr<device::BluetoothSocketMac>)socket
device:(IOBluetoothDevice*)device device:(IOBluetoothDevice*)device
success_callback:(base::Closure)success_callback success_callback:(base::OnceClosure)success_callback
error_callback:(BluetoothSocket::ErrorCompletionCallback)error_callback; error_callback:(BluetoothSocket::ErrorCompletionCallback)error_callback;
- (void)sdpQueryComplete:(IOBluetoothDevice*)device status:(IOReturn)status; - (void)sdpQueryComplete:(IOBluetoothDevice*)device status:(IOReturn)status;
...@@ -62,12 +62,12 @@ using device::BluetoothSocket; ...@@ -62,12 +62,12 @@ using device::BluetoothSocket;
- (id)initWithSocket:(scoped_refptr<device::BluetoothSocketMac>)socket - (id)initWithSocket:(scoped_refptr<device::BluetoothSocketMac>)socket
device:(IOBluetoothDevice*)device device:(IOBluetoothDevice*)device
success_callback:(base::Closure)success_callback success_callback:(base::OnceClosure)success_callback
error_callback:(BluetoothSocket::ErrorCompletionCallback)error_callback { error_callback:(BluetoothSocket::ErrorCompletionCallback)error_callback {
if ((self = [super init])) { if ((self = [super init])) {
socket_ = socket; socket_ = socket;
device_ = device; device_ = device;
success_callback_ = success_callback; success_callback_ = std::move(success_callback);
error_callback_ = error_callback; error_callback_ = error_callback;
} }
...@@ -76,8 +76,8 @@ using device::BluetoothSocket; ...@@ -76,8 +76,8 @@ using device::BluetoothSocket;
- (void)sdpQueryComplete:(IOBluetoothDevice*)device status:(IOReturn)status { - (void)sdpQueryComplete:(IOBluetoothDevice*)device status:(IOReturn)status {
DCHECK_EQ(device, device_); DCHECK_EQ(device, device_);
socket_->OnSDPQueryComplete( socket_->OnSDPQueryComplete(status, device, std::move(success_callback_),
status, device, success_callback_, error_callback_); error_callback_);
} }
@end @end
...@@ -416,7 +416,7 @@ scoped_refptr<BluetoothSocketMac> BluetoothSocketMac::CreateSocket() { ...@@ -416,7 +416,7 @@ scoped_refptr<BluetoothSocketMac> BluetoothSocketMac::CreateSocket() {
void BluetoothSocketMac::Connect( void BluetoothSocketMac::Connect(
IOBluetoothDevice* device, IOBluetoothDevice* device,
const BluetoothUUID& uuid, const BluetoothUUID& uuid,
const base::Closure& success_callback, base::OnceClosure success_callback,
const ErrorCompletionCallback& error_callback) { const ErrorCompletionCallback& error_callback) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
...@@ -430,7 +430,7 @@ void BluetoothSocketMac::Connect( ...@@ -430,7 +430,7 @@ void BluetoothSocketMac::Connect(
SDPQueryListener* listener = SDPQueryListener* listener =
[[SDPQueryListener alloc] initWithSocket:this [[SDPQueryListener alloc] initWithSocket:this
device:device device:device
success_callback:success_callback success_callback:std::move(success_callback)
error_callback:error_callback]; error_callback:error_callback];
[device performSDPQuery:[listener autorelease] [device performSDPQuery:[listener autorelease]
uuids:@[GetIOBluetoothSDPUUID(uuid_)]]; uuids:@[GetIOBluetoothSDPUUID(uuid_)]];
...@@ -491,10 +491,10 @@ void BluetoothSocketMac::ListenUsingL2cap( ...@@ -491,10 +491,10 @@ void BluetoothSocketMac::ListenUsingL2cap(
} }
void BluetoothSocketMac::OnSDPQueryComplete( void BluetoothSocketMac::OnSDPQueryComplete(
IOReturn status, IOReturn status,
IOBluetoothDevice* device, IOBluetoothDevice* device,
const base::Closure& success_callback, base::OnceClosure success_callback,
const ErrorCompletionCallback& error_callback) { const ErrorCompletionCallback& error_callback) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
DVLOG(1) << BluetoothClassicDeviceMac::GetDeviceAddress(device) << " " DVLOG(1) << BluetoothClassicDeviceMac::GetDeviceAddress(device) << " "
<< uuid_.canonical_value() << ": SDP query complete."; << uuid_.canonical_value() << ": SDP query complete.";
...@@ -549,7 +549,7 @@ void BluetoothSocketMac::OnSDPQueryComplete( ...@@ -549,7 +549,7 @@ void BluetoothSocketMac::OnSDPQueryComplete(
// channel, as opening the channel can synchronously call into // channel, as opening the channel can synchronously call into
// OnChannelOpenComplete(). // OnChannelOpenComplete().
connect_callbacks_.reset(new ConnectCallbacks()); connect_callbacks_.reset(new ConnectCallbacks());
connect_callbacks_->success_callback = success_callback; connect_callbacks_->success_callback = std::move(success_callback);
connect_callbacks_->error_callback = error_callback; connect_callbacks_->error_callback = error_callback;
if (rfcomm_channel_id != kInvalidRfcommChannelId) { if (rfcomm_channel_id != kInvalidRfcommChannelId) {
...@@ -612,7 +612,7 @@ void BluetoothSocketMac::OnChannelOpenComplete( ...@@ -612,7 +612,7 @@ void BluetoothSocketMac::OnChannelOpenComplete(
return; return;
} }
temp->success_callback.Run(); std::move(temp->success_callback).Run();
} }
void BluetoothSocketMac::Close() { void BluetoothSocketMac::Close() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment