Commit cf18151a authored by David Bokan's avatar David Bokan Committed by Chromium LUCI CQ

Convert BluetoothSocketEventDispatcher to BindOnce

This CL converts the success callback parameters to the:

 - BluetoothApiSocket::Accept
 - BluetoothApiSocket::Receive

In both cases, the callback is passed to an equivalent method of the
BluetoothSocket class which already takes a OnceCallback.

Bug: 1152268
Change-Id: I22bfc954e48fdf2b9a4e9dd15e32b562d117e4c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2594012
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837650}
parent c669ac6b
......@@ -109,7 +109,7 @@ bool BluetoothApiSocket::IsPersistent() const {
void BluetoothApiSocket::Receive(
int count,
const ReceiveCompletionCallback& success_callback,
ReceiveCompletionCallback success_callback,
const ErrorCompletionCallback& error_callback) {
DCHECK_CURRENTLY_ON(kThreadId);
......@@ -119,7 +119,7 @@ void BluetoothApiSocket::Receive(
return;
}
socket_->Receive(count, success_callback,
socket_->Receive(count, std::move(success_callback),
base::BindOnce(&OnSocketReceiveError, error_callback));
}
......@@ -169,9 +169,8 @@ void BluetoothApiSocket::OnSocketSendError(
std::move(error_callback).Run(BluetoothApiSocket::kSystemError, message);
}
void BluetoothApiSocket::Accept(
const AcceptCompletionCallback& success_callback,
const ErrorCompletionCallback& error_callback) {
void BluetoothApiSocket::Accept(AcceptCompletionCallback success_callback,
const ErrorCompletionCallback& error_callback) {
DCHECK_CURRENTLY_ON(kThreadId);
if (!socket_.get() || IsConnected()) {
......@@ -180,7 +179,7 @@ void BluetoothApiSocket::Accept(
return;
}
socket_->Accept(success_callback,
socket_->Accept(std::move(success_callback),
base::BindOnce(&OnSocketAcceptError, error_callback));
}
......
......@@ -30,10 +30,10 @@ class BluetoothApiSocket : public ApiResource {
kDisconnected };
typedef base::OnceCallback<void(int)> SendCompletionCallback;
typedef base::Callback<void(int, scoped_refptr<net::IOBuffer> io_buffer)>
typedef base::OnceCallback<void(int, scoped_refptr<net::IOBuffer> io_buffer)>
ReceiveCompletionCallback;
typedef base::Callback<void(const device::BluetoothDevice* device,
scoped_refptr<device::BluetoothSocket>)>
typedef base::OnceCallback<void(const device::BluetoothDevice* device,
scoped_refptr<device::BluetoothSocket>)>
AcceptCompletionCallback;
typedef base::Callback<void(ErrorReason, const std::string& error_message)>
ErrorCompletionCallback;
......@@ -70,7 +70,7 @@ class BluetoothApiSocket : public ApiResource {
// |Receive| operation is still pending, |error_callback| will be called with
// |kIOPending| error.
virtual void Receive(int count,
const ReceiveCompletionCallback& success_callback,
ReceiveCompletionCallback success_callback,
const ErrorCompletionCallback& error_callback);
// Sends |buffer| to the socket and calls |success_callback| when data has
......@@ -87,7 +87,7 @@ class BluetoothApiSocket : public ApiResource {
// Accepts a client connection from the socket and calls |success_callback|
// when one has connected. If an error occurs, calls |error_callback| with a
// reason and a message.
virtual void Accept(const AcceptCompletionCallback& success_callback,
virtual void Accept(AcceptCompletionCallback success_callback,
const ErrorCompletionCallback& error_callback);
const std::string& device_address() const { return device_address_; }
......
......@@ -183,10 +183,9 @@ void BluetoothSocketEventDispatcher::StartReceive(const SocketParams& params) {
buffer_size = kDefaultBufferSize;
socket->Receive(
buffer_size,
base::Bind(
&BluetoothSocketEventDispatcher::ReceiveCallback, params),
base::Bind(
&BluetoothSocketEventDispatcher::ReceiveErrorCallback, params));
base::BindOnce(&BluetoothSocketEventDispatcher::ReceiveCallback, params),
base::Bind(&BluetoothSocketEventDispatcher::ReceiveErrorCallback,
params));
}
// static
......@@ -268,10 +267,8 @@ void BluetoothSocketEventDispatcher::StartAccept(const SocketParams& params) {
return;
socket->Accept(
base::Bind(
&BluetoothSocketEventDispatcher::AcceptCallback, params),
base::Bind(
&BluetoothSocketEventDispatcher::AcceptErrorCallback, params));
base::BindOnce(&BluetoothSocketEventDispatcher::AcceptCallback, params),
base::Bind(&BluetoothSocketEventDispatcher::AcceptErrorCallback, params));
}
// static
......
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