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(
const ConnectToServiceCallback& callback,
const ConnectToServiceErrorCallback& error_callback) {
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);
}
......
......@@ -46,7 +46,7 @@ class BluetoothSocketMac : public BluetoothSocket {
// called with a message explaining the cause of failure.
void Connect(IOBluetoothDevice* device,
const BluetoothUUID& uuid,
const base::Closure& success_callback,
base::OnceClosure success_callback,
const ErrorCompletionCallback& error_callback);
// Listens for incoming RFCOMM connections using this socket: Publishes an
......@@ -92,11 +92,10 @@ class BluetoothSocketMac : public BluetoothSocket {
// |status| is the returned status from the SDP query, |device| is the
// IOBluetoothDevice for which the query was made. The remaining
// parameters are those from |Connect()|.
void OnSDPQueryComplete(
IOReturn status,
IOBluetoothDevice* device,
const base::Closure& success_callback,
const ErrorCompletionCallback& error_callback);
void OnSDPQueryComplete(IOReturn status,
IOBluetoothDevice* device,
base::OnceClosure success_callback,
const ErrorCompletionCallback& error_callback);
// Called by BluetoothRfcommConnectionListener and
// BluetoothL2capConnectionListener.
......@@ -140,7 +139,7 @@ class BluetoothSocketMac : public BluetoothSocket {
struct ConnectCallbacks {
ConnectCallbacks();
~ConnectCallbacks();
base::Closure success_callback;
base::OnceClosure success_callback;
ErrorCompletionCallback error_callback;
};
......
......@@ -43,7 +43,7 @@ using device::BluetoothSocket;
scoped_refptr<device::BluetoothSocketMac> socket_;
// Callbacks associated with the request that triggered this SDP query.
base::Closure success_callback_;
base::OnceClosure success_callback_;
BluetoothSocket::ErrorCompletionCallback error_callback_;
// The device being queried.
......@@ -52,7 +52,7 @@ using device::BluetoothSocket;
- (id)initWithSocket:(scoped_refptr<device::BluetoothSocketMac>)socket
device:(IOBluetoothDevice*)device
success_callback:(base::Closure)success_callback
success_callback:(base::OnceClosure)success_callback
error_callback:(BluetoothSocket::ErrorCompletionCallback)error_callback;
- (void)sdpQueryComplete:(IOBluetoothDevice*)device status:(IOReturn)status;
......@@ -62,12 +62,12 @@ using device::BluetoothSocket;
- (id)initWithSocket:(scoped_refptr<device::BluetoothSocketMac>)socket
device:(IOBluetoothDevice*)device
success_callback:(base::Closure)success_callback
success_callback:(base::OnceClosure)success_callback
error_callback:(BluetoothSocket::ErrorCompletionCallback)error_callback {
if ((self = [super init])) {
socket_ = socket;
device_ = device;
success_callback_ = success_callback;
success_callback_ = std::move(success_callback);
error_callback_ = error_callback;
}
......@@ -76,8 +76,8 @@ using device::BluetoothSocket;
- (void)sdpQueryComplete:(IOBluetoothDevice*)device status:(IOReturn)status {
DCHECK_EQ(device, device_);
socket_->OnSDPQueryComplete(
status, device, success_callback_, error_callback_);
socket_->OnSDPQueryComplete(status, device, std::move(success_callback_),
error_callback_);
}
@end
......@@ -416,7 +416,7 @@ scoped_refptr<BluetoothSocketMac> BluetoothSocketMac::CreateSocket() {
void BluetoothSocketMac::Connect(
IOBluetoothDevice* device,
const BluetoothUUID& uuid,
const base::Closure& success_callback,
base::OnceClosure success_callback,
const ErrorCompletionCallback& error_callback) {
DCHECK(thread_checker_.CalledOnValidThread());
......@@ -430,7 +430,7 @@ void BluetoothSocketMac::Connect(
SDPQueryListener* listener =
[[SDPQueryListener alloc] initWithSocket:this
device:device
success_callback:success_callback
success_callback:std::move(success_callback)
error_callback:error_callback];
[device performSDPQuery:[listener autorelease]
uuids:@[GetIOBluetoothSDPUUID(uuid_)]];
......@@ -491,10 +491,10 @@ void BluetoothSocketMac::ListenUsingL2cap(
}
void BluetoothSocketMac::OnSDPQueryComplete(
IOReturn status,
IOBluetoothDevice* device,
const base::Closure& success_callback,
const ErrorCompletionCallback& error_callback) {
IOReturn status,
IOBluetoothDevice* device,
base::OnceClosure success_callback,
const ErrorCompletionCallback& error_callback) {
DCHECK(thread_checker_.CalledOnValidThread());
DVLOG(1) << BluetoothClassicDeviceMac::GetDeviceAddress(device) << " "
<< uuid_.canonical_value() << ": SDP query complete.";
......@@ -549,7 +549,7 @@ void BluetoothSocketMac::OnSDPQueryComplete(
// channel, as opening the channel can synchronously call into
// OnChannelOpenComplete().
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;
if (rfcomm_channel_id != kInvalidRfcommChannelId) {
......@@ -612,7 +612,7 @@ void BluetoothSocketMac::OnChannelOpenComplete(
return;
}
temp->success_callback.Run();
std::move(temp->success_callback).Run();
}
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