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 { ...@@ -109,7 +109,7 @@ bool BluetoothApiSocket::IsPersistent() const {
void BluetoothApiSocket::Receive( void BluetoothApiSocket::Receive(
int count, int count,
const ReceiveCompletionCallback& success_callback, ReceiveCompletionCallback success_callback,
const ErrorCompletionCallback& error_callback) { const ErrorCompletionCallback& error_callback) {
DCHECK_CURRENTLY_ON(kThreadId); DCHECK_CURRENTLY_ON(kThreadId);
...@@ -119,7 +119,7 @@ void BluetoothApiSocket::Receive( ...@@ -119,7 +119,7 @@ void BluetoothApiSocket::Receive(
return; return;
} }
socket_->Receive(count, success_callback, socket_->Receive(count, std::move(success_callback),
base::BindOnce(&OnSocketReceiveError, error_callback)); base::BindOnce(&OnSocketReceiveError, error_callback));
} }
...@@ -169,8 +169,7 @@ void BluetoothApiSocket::OnSocketSendError( ...@@ -169,8 +169,7 @@ void BluetoothApiSocket::OnSocketSendError(
std::move(error_callback).Run(BluetoothApiSocket::kSystemError, message); std::move(error_callback).Run(BluetoothApiSocket::kSystemError, message);
} }
void BluetoothApiSocket::Accept( void BluetoothApiSocket::Accept(AcceptCompletionCallback success_callback,
const AcceptCompletionCallback& success_callback,
const ErrorCompletionCallback& error_callback) { const ErrorCompletionCallback& error_callback) {
DCHECK_CURRENTLY_ON(kThreadId); DCHECK_CURRENTLY_ON(kThreadId);
...@@ -180,7 +179,7 @@ void BluetoothApiSocket::Accept( ...@@ -180,7 +179,7 @@ void BluetoothApiSocket::Accept(
return; return;
} }
socket_->Accept(success_callback, socket_->Accept(std::move(success_callback),
base::BindOnce(&OnSocketAcceptError, error_callback)); base::BindOnce(&OnSocketAcceptError, error_callback));
} }
......
...@@ -30,9 +30,9 @@ class BluetoothApiSocket : public ApiResource { ...@@ -30,9 +30,9 @@ class BluetoothApiSocket : public ApiResource {
kDisconnected }; kDisconnected };
typedef base::OnceCallback<void(int)> SendCompletionCallback; 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; ReceiveCompletionCallback;
typedef base::Callback<void(const device::BluetoothDevice* device, typedef base::OnceCallback<void(const device::BluetoothDevice* device,
scoped_refptr<device::BluetoothSocket>)> scoped_refptr<device::BluetoothSocket>)>
AcceptCompletionCallback; AcceptCompletionCallback;
typedef base::Callback<void(ErrorReason, const std::string& error_message)> typedef base::Callback<void(ErrorReason, const std::string& error_message)>
...@@ -70,7 +70,7 @@ class BluetoothApiSocket : public ApiResource { ...@@ -70,7 +70,7 @@ class BluetoothApiSocket : public ApiResource {
// |Receive| operation is still pending, |error_callback| will be called with // |Receive| operation is still pending, |error_callback| will be called with
// |kIOPending| error. // |kIOPending| error.
virtual void Receive(int count, virtual void Receive(int count,
const ReceiveCompletionCallback& success_callback, ReceiveCompletionCallback success_callback,
const ErrorCompletionCallback& error_callback); const ErrorCompletionCallback& error_callback);
// Sends |buffer| to the socket and calls |success_callback| when data has // Sends |buffer| to the socket and calls |success_callback| when data has
...@@ -87,7 +87,7 @@ class BluetoothApiSocket : public ApiResource { ...@@ -87,7 +87,7 @@ class BluetoothApiSocket : public ApiResource {
// Accepts a client connection from the socket and calls |success_callback| // Accepts a client connection from the socket and calls |success_callback|
// when one has connected. If an error occurs, calls |error_callback| with a // when one has connected. If an error occurs, calls |error_callback| with a
// reason and a message. // reason and a message.
virtual void Accept(const AcceptCompletionCallback& success_callback, virtual void Accept(AcceptCompletionCallback success_callback,
const ErrorCompletionCallback& error_callback); const ErrorCompletionCallback& error_callback);
const std::string& device_address() const { return device_address_; } const std::string& device_address() const { return device_address_; }
......
...@@ -183,10 +183,9 @@ void BluetoothSocketEventDispatcher::StartReceive(const SocketParams& params) { ...@@ -183,10 +183,9 @@ void BluetoothSocketEventDispatcher::StartReceive(const SocketParams& params) {
buffer_size = kDefaultBufferSize; buffer_size = kDefaultBufferSize;
socket->Receive( socket->Receive(
buffer_size, buffer_size,
base::Bind( base::BindOnce(&BluetoothSocketEventDispatcher::ReceiveCallback, params),
&BluetoothSocketEventDispatcher::ReceiveCallback, params), base::Bind(&BluetoothSocketEventDispatcher::ReceiveErrorCallback,
base::Bind( params));
&BluetoothSocketEventDispatcher::ReceiveErrorCallback, params));
} }
// static // static
...@@ -268,10 +267,8 @@ void BluetoothSocketEventDispatcher::StartAccept(const SocketParams& params) { ...@@ -268,10 +267,8 @@ void BluetoothSocketEventDispatcher::StartAccept(const SocketParams& params) {
return; return;
socket->Accept( socket->Accept(
base::Bind( base::BindOnce(&BluetoothSocketEventDispatcher::AcceptCallback, params),
&BluetoothSocketEventDispatcher::AcceptCallback, params), base::Bind(&BluetoothSocketEventDispatcher::AcceptErrorCallback, params));
base::Bind(
&BluetoothSocketEventDispatcher::AcceptErrorCallback, params));
} }
// static // 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