Commit f5d7fa32 authored by danakj's avatar danakj Committed by Commit Bot

Convert Callbacks to OnceCallbacks for BluetookAgentServiceProvider.

This will allow us to convert more Callbacks in the bluetooth component
over to OnceCallbacks, which will let us convert Callbacks in content
eventually.

R=reillyg@chromium.org

Bug: 953861
Change-Id: I21555216157c1d56249c6ec93c910ce19a68f8a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1572368Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652222}
parent cd9b5ac2
...@@ -774,18 +774,18 @@ void BluetoothAdapterBlueZ::Released() { ...@@ -774,18 +774,18 @@ void BluetoothAdapterBlueZ::Released() {
} }
void BluetoothAdapterBlueZ::RequestPinCode(const dbus::ObjectPath& device_path, void BluetoothAdapterBlueZ::RequestPinCode(const dbus::ObjectPath& device_path,
const PinCodeCallback& callback) { PinCodeCallback callback) {
DCHECK(IsPresent()); DCHECK(IsPresent());
DCHECK(agent_.get()); DCHECK(agent_.get());
BLUETOOTH_LOG(EVENT) << device_path.value() << ": RequestPinCode"; BLUETOOTH_LOG(EVENT) << device_path.value() << ": RequestPinCode";
BluetoothPairingBlueZ* pairing = GetPairing(device_path); BluetoothPairingBlueZ* pairing = GetPairing(device_path);
if (!pairing) { if (!pairing) {
callback.Run(REJECTED, ""); std::move(callback).Run(REJECTED, "");
return; return;
} }
pairing->RequestPinCode(callback); pairing->RequestPinCode(std::move(callback));
} }
void BluetoothAdapterBlueZ::DisplayPinCode(const dbus::ObjectPath& device_path, void BluetoothAdapterBlueZ::DisplayPinCode(const dbus::ObjectPath& device_path,
...@@ -803,18 +803,18 @@ void BluetoothAdapterBlueZ::DisplayPinCode(const dbus::ObjectPath& device_path, ...@@ -803,18 +803,18 @@ void BluetoothAdapterBlueZ::DisplayPinCode(const dbus::ObjectPath& device_path,
} }
void BluetoothAdapterBlueZ::RequestPasskey(const dbus::ObjectPath& device_path, void BluetoothAdapterBlueZ::RequestPasskey(const dbus::ObjectPath& device_path,
const PasskeyCallback& callback) { PasskeyCallback callback) {
DCHECK(IsPresent()); DCHECK(IsPresent());
DCHECK(agent_.get()); DCHECK(agent_.get());
BLUETOOTH_LOG(EVENT) << device_path.value() << ": RequestPasskey"; BLUETOOTH_LOG(EVENT) << device_path.value() << ": RequestPasskey";
BluetoothPairingBlueZ* pairing = GetPairing(device_path); BluetoothPairingBlueZ* pairing = GetPairing(device_path);
if (!pairing) { if (!pairing) {
callback.Run(REJECTED, 0); std::move(callback).Run(REJECTED, 0);
return; return;
} }
pairing->RequestPasskey(callback); pairing->RequestPasskey(std::move(callback));
} }
void BluetoothAdapterBlueZ::DisplayPasskey(const dbus::ObjectPath& device_path, void BluetoothAdapterBlueZ::DisplayPasskey(const dbus::ObjectPath& device_path,
...@@ -838,7 +838,7 @@ void BluetoothAdapterBlueZ::DisplayPasskey(const dbus::ObjectPath& device_path, ...@@ -838,7 +838,7 @@ void BluetoothAdapterBlueZ::DisplayPasskey(const dbus::ObjectPath& device_path,
void BluetoothAdapterBlueZ::RequestConfirmation( void BluetoothAdapterBlueZ::RequestConfirmation(
const dbus::ObjectPath& device_path, const dbus::ObjectPath& device_path,
uint32_t passkey, uint32_t passkey,
const ConfirmationCallback& callback) { ConfirmationCallback callback) {
DCHECK(IsPresent()); DCHECK(IsPresent());
DCHECK(agent_.get()); DCHECK(agent_.get());
BLUETOOTH_LOG(EVENT) << device_path.value() BLUETOOTH_LOG(EVENT) << device_path.value()
...@@ -846,40 +846,40 @@ void BluetoothAdapterBlueZ::RequestConfirmation( ...@@ -846,40 +846,40 @@ void BluetoothAdapterBlueZ::RequestConfirmation(
BluetoothPairingBlueZ* pairing = GetPairing(device_path); BluetoothPairingBlueZ* pairing = GetPairing(device_path);
if (!pairing) { if (!pairing) {
callback.Run(REJECTED); std::move(callback).Run(REJECTED);
return; return;
} }
pairing->RequestConfirmation(passkey, callback); pairing->RequestConfirmation(passkey, std::move(callback));
} }
void BluetoothAdapterBlueZ::RequestAuthorization( void BluetoothAdapterBlueZ::RequestAuthorization(
const dbus::ObjectPath& device_path, const dbus::ObjectPath& device_path,
const ConfirmationCallback& callback) { ConfirmationCallback callback) {
DCHECK(IsPresent()); DCHECK(IsPresent());
DCHECK(agent_.get()); DCHECK(agent_.get());
BLUETOOTH_LOG(EVENT) << device_path.value() << ": RequestAuthorization"; BLUETOOTH_LOG(EVENT) << device_path.value() << ": RequestAuthorization";
BluetoothPairingBlueZ* pairing = GetPairing(device_path); BluetoothPairingBlueZ* pairing = GetPairing(device_path);
if (!pairing) { if (!pairing) {
callback.Run(REJECTED); std::move(callback).Run(REJECTED);
return; return;
} }
pairing->RequestAuthorization(callback); pairing->RequestAuthorization(std::move(callback));
} }
void BluetoothAdapterBlueZ::AuthorizeService( void BluetoothAdapterBlueZ::AuthorizeService(
const dbus::ObjectPath& device_path, const dbus::ObjectPath& device_path,
const std::string& uuid, const std::string& uuid,
const ConfirmationCallback& callback) { ConfirmationCallback callback) {
DCHECK(IsPresent()); DCHECK(IsPresent());
DCHECK(agent_.get()); DCHECK(agent_.get());
BLUETOOTH_LOG(EVENT) << device_path.value() << ": AuthorizeService: " << uuid; BLUETOOTH_LOG(EVENT) << device_path.value() << ": AuthorizeService: " << uuid;
BluetoothDeviceBlueZ* device_bluez = GetDeviceWithPath(device_path); BluetoothDeviceBlueZ* device_bluez = GetDeviceWithPath(device_path);
if (!device_bluez) { if (!device_bluez) {
callback.Run(CANCELLED); std::move(callback).Run(CANCELLED);
return; return;
} }
...@@ -888,7 +888,7 @@ void BluetoothAdapterBlueZ::AuthorizeService( ...@@ -888,7 +888,7 @@ void BluetoothAdapterBlueZ::AuthorizeService(
// our "Set('Trusted', true)" method call is still pending in the Bluetooth // our "Set('Trusted', true)" method call is still pending in the Bluetooth
// daemon because it's busy handling the incoming connection. // daemon because it's busy handling the incoming connection.
if (device_bluez->IsPaired()) { if (device_bluez->IsPaired()) {
callback.Run(SUCCESS); std::move(callback).Run(SUCCESS);
return; return;
} }
...@@ -896,7 +896,7 @@ void BluetoothAdapterBlueZ::AuthorizeService( ...@@ -896,7 +896,7 @@ void BluetoothAdapterBlueZ::AuthorizeService(
// whether this is acceptable long-term. // whether this is acceptable long-term.
BLUETOOTH_LOG(ERROR) << "Rejecting service connection from unpaired device " BLUETOOTH_LOG(ERROR) << "Rejecting service connection from unpaired device "
<< device_bluez->GetAddress() << " for UUID " << uuid; << device_bluez->GetAddress() << " for UUID " << uuid;
callback.Run(REJECTED); std::move(callback).Run(REJECTED);
} }
void BluetoothAdapterBlueZ::Cancel() { void BluetoothAdapterBlueZ::Cancel() {
......
...@@ -287,22 +287,22 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ ...@@ -287,22 +287,22 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ
// bluez::BluetoothAgentServiceProvider::Delegate override. // bluez::BluetoothAgentServiceProvider::Delegate override.
void Released() override; void Released() override;
void RequestPinCode(const dbus::ObjectPath& device_path, void RequestPinCode(const dbus::ObjectPath& device_path,
const PinCodeCallback& callback) override; PinCodeCallback callback) override;
void DisplayPinCode(const dbus::ObjectPath& device_path, void DisplayPinCode(const dbus::ObjectPath& device_path,
const std::string& pincode) override; const std::string& pincode) override;
void RequestPasskey(const dbus::ObjectPath& device_path, void RequestPasskey(const dbus::ObjectPath& device_path,
const PasskeyCallback& callback) override; PasskeyCallback callback) override;
void DisplayPasskey(const dbus::ObjectPath& device_path, void DisplayPasskey(const dbus::ObjectPath& device_path,
uint32_t passkey, uint32_t passkey,
uint16_t entered) override; uint16_t entered) override;
void RequestConfirmation(const dbus::ObjectPath& device_path, void RequestConfirmation(const dbus::ObjectPath& device_path,
uint32_t passkey, uint32_t passkey,
const ConfirmationCallback& callback) override; ConfirmationCallback callback) override;
void RequestAuthorization(const dbus::ObjectPath& device_path, void RequestAuthorization(const dbus::ObjectPath& device_path,
const ConfirmationCallback& callback) override; ConfirmationCallback callback) override;
void AuthorizeService(const dbus::ObjectPath& device_path, void AuthorizeService(const dbus::ObjectPath& device_path,
const std::string& uuid, const std::string& uuid,
const ConfirmationCallback& callback) override; ConfirmationCallback callback) override;
void Cancel() override; void Cancel() override;
// Called by dbus:: on completion of the D-Bus method call to register the // Called by dbus:: on completion of the D-Bus method call to register the
......
...@@ -53,32 +53,31 @@ BluetoothPairingBlueZ::~BluetoothPairingBlueZ() { ...@@ -53,32 +53,31 @@ BluetoothPairingBlueZ::~BluetoothPairingBlueZ() {
} }
if (!pincode_callback_.is_null()) { if (!pincode_callback_.is_null()) {
pincode_callback_.Run( std::move(pincode_callback_)
bluez::BluetoothAgentServiceProvider::Delegate::CANCELLED, ""); .Run(bluez::BluetoothAgentServiceProvider::Delegate::CANCELLED, "");
} }
if (!passkey_callback_.is_null()) { if (!passkey_callback_.is_null()) {
passkey_callback_.Run( std::move(passkey_callback_)
bluez::BluetoothAgentServiceProvider::Delegate::CANCELLED, 0); .Run(bluez::BluetoothAgentServiceProvider::Delegate::CANCELLED, 0);
} }
if (!confirmation_callback_.is_null()) { if (!confirmation_callback_.is_null()) {
confirmation_callback_.Run( std::move(confirmation_callback_)
bluez::BluetoothAgentServiceProvider::Delegate::CANCELLED); .Run(bluez::BluetoothAgentServiceProvider::Delegate::CANCELLED);
} }
pairing_delegate_ = NULL; pairing_delegate_ = NULL;
} }
void BluetoothPairingBlueZ::RequestPinCode( void BluetoothPairingBlueZ::RequestPinCode(
const bluez::BluetoothAgentServiceProvider::Delegate::PinCodeCallback& bluez::BluetoothAgentServiceProvider::Delegate::PinCodeCallback callback) {
callback) {
UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod",
UMA_PAIRING_METHOD_REQUEST_PINCODE, UMA_PAIRING_METHOD_REQUEST_PINCODE,
UMA_PAIRING_METHOD_COUNT); UMA_PAIRING_METHOD_COUNT);
ResetCallbacks(); ResetCallbacks();
pincode_callback_ = callback; pincode_callback_ = std::move(callback);
pairing_delegate_used_ = true; pairing_delegate_used_ = true;
pairing_delegate_->RequestPinCode(device_); pairing_delegate_->RequestPinCode(device_);
} }
...@@ -91,9 +90,8 @@ void BluetoothPairingBlueZ::SetPinCode(const std::string& pincode) { ...@@ -91,9 +90,8 @@ void BluetoothPairingBlueZ::SetPinCode(const std::string& pincode) {
if (pincode_callback_.is_null()) if (pincode_callback_.is_null())
return; return;
pincode_callback_.Run(bluez::BluetoothAgentServiceProvider::Delegate::SUCCESS, std::move(pincode_callback_)
pincode); .Run(bluez::BluetoothAgentServiceProvider::Delegate::SUCCESS, pincode);
pincode_callback_.Reset();
// If this is not an outgoing connection to the device, clean up the pairing // If this is not an outgoing connection to the device, clean up the pairing
// context since the pairing is done. The outgoing connection case is cleaned // context since the pairing is done. The outgoing connection case is cleaned
...@@ -119,14 +117,13 @@ void BluetoothPairingBlueZ::DisplayPinCode(const std::string& pincode) { ...@@ -119,14 +117,13 @@ void BluetoothPairingBlueZ::DisplayPinCode(const std::string& pincode) {
} }
void BluetoothPairingBlueZ::RequestPasskey( void BluetoothPairingBlueZ::RequestPasskey(
const bluez::BluetoothAgentServiceProvider::Delegate::PasskeyCallback& bluez::BluetoothAgentServiceProvider::Delegate::PasskeyCallback callback) {
callback) {
UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod",
UMA_PAIRING_METHOD_REQUEST_PASSKEY, UMA_PAIRING_METHOD_REQUEST_PASSKEY,
UMA_PAIRING_METHOD_COUNT); UMA_PAIRING_METHOD_COUNT);
ResetCallbacks(); ResetCallbacks();
passkey_callback_ = callback; passkey_callback_ = std::move(callback);
pairing_delegate_used_ = true; pairing_delegate_used_ = true;
pairing_delegate_->RequestPasskey(device_); pairing_delegate_->RequestPasskey(device_);
} }
...@@ -139,9 +136,8 @@ void BluetoothPairingBlueZ::SetPasskey(uint32_t passkey) { ...@@ -139,9 +136,8 @@ void BluetoothPairingBlueZ::SetPasskey(uint32_t passkey) {
if (passkey_callback_.is_null()) if (passkey_callback_.is_null())
return; return;
passkey_callback_.Run(bluez::BluetoothAgentServiceProvider::Delegate::SUCCESS, std::move(passkey_callback_)
passkey); .Run(bluez::BluetoothAgentServiceProvider::Delegate::SUCCESS, passkey);
passkey_callback_.Reset();
// If this is not an outgoing connection to the device, clean up the pairing // If this is not an outgoing connection to the device, clean up the pairing
// context since the pairing is done. The outgoing connection case is cleaned // context since the pairing is done. The outgoing connection case is cleaned
...@@ -173,26 +169,26 @@ void BluetoothPairingBlueZ::KeysEntered(uint16_t entered) { ...@@ -173,26 +169,26 @@ void BluetoothPairingBlueZ::KeysEntered(uint16_t entered) {
void BluetoothPairingBlueZ::RequestConfirmation( void BluetoothPairingBlueZ::RequestConfirmation(
uint32_t passkey, uint32_t passkey,
const bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback& bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback
callback) { callback) {
UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod",
UMA_PAIRING_METHOD_CONFIRM_PASSKEY, UMA_PAIRING_METHOD_CONFIRM_PASSKEY,
UMA_PAIRING_METHOD_COUNT); UMA_PAIRING_METHOD_COUNT);
ResetCallbacks(); ResetCallbacks();
confirmation_callback_ = callback; confirmation_callback_ = std::move(callback);
pairing_delegate_used_ = true; pairing_delegate_used_ = true;
pairing_delegate_->ConfirmPasskey(device_, passkey); pairing_delegate_->ConfirmPasskey(device_, passkey);
} }
void BluetoothPairingBlueZ::RequestAuthorization( void BluetoothPairingBlueZ::RequestAuthorization(
const bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback& bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback
callback) { callback) {
UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_PAIRING_METHOD_NONE, UMA_HISTOGRAM_ENUMERATION("Bluetooth.PairingMethod", UMA_PAIRING_METHOD_NONE,
UMA_PAIRING_METHOD_COUNT); UMA_PAIRING_METHOD_COUNT);
ResetCallbacks(); ResetCallbacks();
confirmation_callback_ = callback; confirmation_callback_ = std::move(callback);
pairing_delegate_used_ = true; pairing_delegate_used_ = true;
pairing_delegate_->AuthorizePairing(device_); pairing_delegate_->AuthorizePairing(device_);
} }
...@@ -205,9 +201,8 @@ void BluetoothPairingBlueZ::ConfirmPairing() { ...@@ -205,9 +201,8 @@ void BluetoothPairingBlueZ::ConfirmPairing() {
if (confirmation_callback_.is_null()) if (confirmation_callback_.is_null())
return; return;
confirmation_callback_.Run( std::move(confirmation_callback_)
bluez::BluetoothAgentServiceProvider::Delegate::SUCCESS); .Run(bluez::BluetoothAgentServiceProvider::Delegate::SUCCESS);
confirmation_callback_.Reset();
// If this is not an outgoing connection to the device, clean up the pairing // If this is not an outgoing connection to the device, clean up the pairing
// context since the pairing is done. The outgoing connection case is cleaned // context since the pairing is done. The outgoing connection case is cleaned
...@@ -243,20 +238,17 @@ bool BluetoothPairingBlueZ::RunPairingCallbacks( ...@@ -243,20 +238,17 @@ bool BluetoothPairingBlueZ::RunPairingCallbacks(
bool callback_run = false; bool callback_run = false;
if (!pincode_callback_.is_null()) { if (!pincode_callback_.is_null()) {
pincode_callback_.Run(status, ""); std::move(pincode_callback_).Run(status, "");
pincode_callback_.Reset();
callback_run = true; callback_run = true;
} }
if (!passkey_callback_.is_null()) { if (!passkey_callback_.is_null()) {
passkey_callback_.Run(status, 0); std::move(passkey_callback_).Run(status, 0);
passkey_callback_.Reset();
callback_run = true; callback_run = true;
} }
if (!confirmation_callback_.is_null()) { if (!confirmation_callback_.is_null()) {
confirmation_callback_.Run(status); std::move(confirmation_callback_).Run(status);
confirmation_callback_.Reset();
callback_run = true; callback_run = true;
} }
......
...@@ -39,8 +39,7 @@ class BluetoothPairingBlueZ { ...@@ -39,8 +39,7 @@ class BluetoothPairingBlueZ {
// calls on this object are translated into the appropriate response to // calls on this object are translated into the appropriate response to
// |callback|. // |callback|.
void RequestPinCode( void RequestPinCode(
const bluez::BluetoothAgentServiceProvider::Delegate::PinCodeCallback& bluez::BluetoothAgentServiceProvider::Delegate::PinCodeCallback callback);
callback);
// Indicates whether the device is currently pairing and expecting a // Indicates whether the device is currently pairing and expecting a
// PIN Code to be returned. // PIN Code to be returned.
...@@ -61,8 +60,7 @@ class BluetoothPairingBlueZ { ...@@ -61,8 +60,7 @@ class BluetoothPairingBlueZ {
// calls on this object are translated into the appropriate response to // calls on this object are translated into the appropriate response to
// |callback|. // |callback|.
void RequestPasskey( void RequestPasskey(
const bluez::BluetoothAgentServiceProvider::Delegate::PasskeyCallback& bluez::BluetoothAgentServiceProvider::Delegate::PasskeyCallback callback);
callback);
// Sends the Passkey |passkey| to the remote device during pairing. // Sends the Passkey |passkey| to the remote device during pairing.
// //
...@@ -84,16 +82,18 @@ class BluetoothPairingBlueZ { ...@@ -84,16 +82,18 @@ class BluetoothPairingBlueZ {
// from the current pairing delegate. The ConfirmPairing(), RejectPairing() // from the current pairing delegate. The ConfirmPairing(), RejectPairing()
// and CancelPairing() method calls on this object are translated into the // and CancelPairing() method calls on this object are translated into the
// appropriate response to |callback|. // appropriate response to |callback|.
void RequestConfirmation(uint32_t passkey, void RequestConfirmation(
const bluez::BluetoothAgentServiceProvider:: uint32_t passkey,
Delegate::ConfirmationCallback& callback); bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback
callback);
// Requests authorization that the current device be allowed to pair with // Requests authorization that the current device be allowed to pair with
// this device from the current pairing delegate. The ConfirmPairing(), // this device from the current pairing delegate. The ConfirmPairing(),
// RejectPairing() and CancelPairing() method calls on this object are // RejectPairing() and CancelPairing() method calls on this object are
// translated into the appropriate response to |callback|. // translated into the appropriate response to |callback|.
void RequestAuthorization(const bluez::BluetoothAgentServiceProvider:: void RequestAuthorization(
Delegate::ConfirmationCallback& callback); bluez::BluetoothAgentServiceProvider::Delegate::ConfirmationCallback
callback);
// Confirms to the remote device during pairing that a passkey provided by // Confirms to the remote device during pairing that a passkey provided by
// the ConfirmPasskey() delegate call is displayed on both devices. // the ConfirmPasskey() delegate call is displayed on both devices.
......
...@@ -147,11 +147,11 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider { ...@@ -147,11 +147,11 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
return; return;
} }
Delegate::PinCodeCallback callback = base::Bind( Delegate::PinCodeCallback callback = base::BindOnce(
&BluetoothAgentServiceProviderImpl::OnPinCode, &BluetoothAgentServiceProviderImpl::OnPinCode,
weak_ptr_factory_.GetWeakPtr(), method_call, response_sender); weak_ptr_factory_.GetWeakPtr(), method_call, response_sender);
delegate_->RequestPinCode(device_path, callback); delegate_->RequestPinCode(device_path, std::move(callback));
} }
// Called by dbus:: when the Bluetooth daemon requires that the user // Called by dbus:: when the Bluetooth daemon requires that the user
...@@ -191,11 +191,11 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider { ...@@ -191,11 +191,11 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
return; return;
} }
Delegate::PasskeyCallback callback = base::Bind( Delegate::PasskeyCallback callback = base::BindOnce(
&BluetoothAgentServiceProviderImpl::OnPasskey, &BluetoothAgentServiceProviderImpl::OnPasskey,
weak_ptr_factory_.GetWeakPtr(), method_call, response_sender); weak_ptr_factory_.GetWeakPtr(), method_call, response_sender);
delegate_->RequestPasskey(device_path, callback); delegate_->RequestPasskey(device_path, std::move(callback));
} }
// Called by dbus:: when the Bluetooth daemon requires that the user // Called by dbus:: when the Bluetooth daemon requires that the user
...@@ -240,11 +240,11 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider { ...@@ -240,11 +240,11 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
return; return;
} }
Delegate::ConfirmationCallback callback = base::Bind( Delegate::ConfirmationCallback callback = base::BindOnce(
&BluetoothAgentServiceProviderImpl::OnConfirmation, &BluetoothAgentServiceProviderImpl::OnConfirmation,
weak_ptr_factory_.GetWeakPtr(), method_call, response_sender); weak_ptr_factory_.GetWeakPtr(), method_call, response_sender);
delegate_->RequestConfirmation(device_path, passkey, callback); delegate_->RequestConfirmation(device_path, passkey, std::move(callback));
} }
// Called by dbus:: when the Bluetooth daemon requires that the user // Called by dbus:: when the Bluetooth daemon requires that the user
...@@ -263,11 +263,11 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider { ...@@ -263,11 +263,11 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
return; return;
} }
Delegate::ConfirmationCallback callback = base::Bind( Delegate::ConfirmationCallback callback = base::BindOnce(
&BluetoothAgentServiceProviderImpl::OnConfirmation, &BluetoothAgentServiceProviderImpl::OnConfirmation,
weak_ptr_factory_.GetWeakPtr(), method_call, response_sender); weak_ptr_factory_.GetWeakPtr(), method_call, response_sender);
delegate_->RequestAuthorization(device_path, callback); delegate_->RequestAuthorization(device_path, std::move(callback));
} }
// Called by dbus:: when the Bluetooth daemon requires that the user // Called by dbus:: when the Bluetooth daemon requires that the user
...@@ -287,11 +287,11 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider { ...@@ -287,11 +287,11 @@ class BluetoothAgentServiceProviderImpl : public BluetoothAgentServiceProvider {
return; return;
} }
Delegate::ConfirmationCallback callback = base::Bind( Delegate::ConfirmationCallback callback = base::BindOnce(
&BluetoothAgentServiceProviderImpl::OnConfirmation, &BluetoothAgentServiceProviderImpl::OnConfirmation,
weak_ptr_factory_.GetWeakPtr(), method_call, response_sender); weak_ptr_factory_.GetWeakPtr(), method_call, response_sender);
delegate_->AuthorizeService(device_path, uuid, callback); delegate_->AuthorizeService(device_path, uuid, std::move(callback));
} }
// Called by dbus:: when the request failed before a reply was returned // Called by dbus:: when the request failed before a reply was returned
......
...@@ -46,18 +46,19 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider { ...@@ -46,18 +46,19 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider {
// The PinCodeCallback is used for the RequestPinCode() method, it should // The PinCodeCallback is used for the RequestPinCode() method, it should
// be called with two arguments, the |status| of the request (success, // be called with two arguments, the |status| of the request (success,
// rejected or cancelled) and the |pincode| requested. // rejected or cancelled) and the |pincode| requested.
typedef base::Callback<void(Status, const std::string&)> PinCodeCallback; using PinCodeCallback =
base::OnceCallback<void(Status, const std::string&)>;
// The PasskeyCallback is used for the RequestPasskey() method, it should // The PasskeyCallback is used for the RequestPasskey() method, it should
// be called with two arguments, the |status| of the request (success, // be called with two arguments, the |status| of the request (success,
// rejected or cancelled) and the |passkey| requested, a numeric in the // rejected or cancelled) and the |passkey| requested, a numeric in the
// range 0-999999, // range 0-999999,
typedef base::Callback<void(Status, uint32_t)> PasskeyCallback; using PasskeyCallback = base::OnceCallback<void(Status, uint32_t)>;
// The ConfirmationCallback is used for methods which request confirmation // The ConfirmationCallback is used for methods which request confirmation
// or authorization, it should be called with one argument, the |status| // or authorization, it should be called with one argument, the |status|
// of the request (success, rejected or cancelled). // of the request (success, rejected or cancelled).
typedef base::Callback<void(Status)> ConfirmationCallback; using ConfirmationCallback = base::OnceCallback<void(Status)>;
// This method will be called when the agent is unregistered from the // This method will be called when the agent is unregistered from the
// Bluetooth daemon, generally at the end of a pairing request. It may be // Bluetooth daemon, generally at the end of a pairing request. It may be
...@@ -74,7 +75,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider { ...@@ -74,7 +75,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider {
// PIN Codes are generally required for Bluetooth 2.0 and earlier devices // PIN Codes are generally required for Bluetooth 2.0 and earlier devices
// for which there is no automatic pairing or special handling. // for which there is no automatic pairing or special handling.
virtual void RequestPinCode(const dbus::ObjectPath& device_path, virtual void RequestPinCode(const dbus::ObjectPath& device_path,
const PinCodeCallback& callback) = 0; PinCodeCallback callback) = 0;
// This method will be called when the Bluetooth daemon requires that the // This method will be called when the Bluetooth daemon requires that the
// user enter the PIN code |pincode| into the device with object path // user enter the PIN code |pincode| into the device with object path
...@@ -98,7 +99,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider { ...@@ -98,7 +99,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider {
// which cannot provide input or display on their own, and don't accept // which cannot provide input or display on their own, and don't accept
// passkey-less pairing. // passkey-less pairing.
virtual void RequestPasskey(const dbus::ObjectPath& device_path, virtual void RequestPasskey(const dbus::ObjectPath& device_path,
const PasskeyCallback& callback) = 0; PasskeyCallback callback) = 0;
// This method will be called when the Bluetooth daemon requires that the // This method will be called when the Bluetooth daemon requires that the
// user enter the Passkey |passkey| into the device with object path // user enter the Passkey |passkey| into the device with object path
...@@ -130,7 +131,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider { ...@@ -130,7 +131,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider {
// digits. // digits.
virtual void RequestConfirmation(const dbus::ObjectPath& device_path, virtual void RequestConfirmation(const dbus::ObjectPath& device_path,
uint32_t passkey, uint32_t passkey,
const ConfirmationCallback& callback) = 0; ConfirmationCallback callback) = 0;
// This method will be called when the Bluetooth daemon requires // This method will be called when the Bluetooth daemon requires
// authorization of an incoming pairing attempt from the device with object // authorization of an incoming pairing attempt from the device with object
...@@ -140,7 +141,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider { ...@@ -140,7 +141,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider {
// The agent should confirm the incoming pairing with the user and call // The agent should confirm the incoming pairing with the user and call
// |callback| to provide their response (success, rejected or cancelled). // |callback| to provide their response (success, rejected or cancelled).
virtual void RequestAuthorization(const dbus::ObjectPath& device_path, virtual void RequestAuthorization(const dbus::ObjectPath& device_path,
const ConfirmationCallback& callback) = 0; ConfirmationCallback callback) = 0;
// This method will be called when the Bluetooth daemon requires that the // This method will be called when the Bluetooth daemon requires that the
// user confirm that the device with object path |object_path| is // user confirm that the device with object path |object_path| is
...@@ -149,7 +150,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider { ...@@ -149,7 +150,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAgentServiceProvider {
// (success, rejected or cancelled). // (success, rejected or cancelled).
virtual void AuthorizeService(const dbus::ObjectPath& device_path, virtual void AuthorizeService(const dbus::ObjectPath& device_path,
const std::string& uuid, const std::string& uuid,
const ConfirmationCallback& callback) = 0; ConfirmationCallback callback) = 0;
// This method will be called by the Bluetooth daemon to indicate that // This method will be called by the Bluetooth daemon to indicate that
// the request failed before a reply was returned from the device. // the request failed before a reply was returned from the device.
......
...@@ -37,10 +37,10 @@ void FakeBluetoothAgentServiceProvider::Release() { ...@@ -37,10 +37,10 @@ void FakeBluetoothAgentServiceProvider::Release() {
void FakeBluetoothAgentServiceProvider::RequestPinCode( void FakeBluetoothAgentServiceProvider::RequestPinCode(
const dbus::ObjectPath& device_path, const dbus::ObjectPath& device_path,
const Delegate::PinCodeCallback& callback) { Delegate::PinCodeCallback callback) {
VLOG(1) << object_path_.value() << ": RequestPinCode for " VLOG(1) << object_path_.value() << ": RequestPinCode for "
<< device_path.value(); << device_path.value();
delegate_->RequestPinCode(device_path, callback); delegate_->RequestPinCode(device_path, std::move(callback));
} }
void FakeBluetoothAgentServiceProvider::DisplayPinCode( void FakeBluetoothAgentServiceProvider::DisplayPinCode(
...@@ -53,10 +53,10 @@ void FakeBluetoothAgentServiceProvider::DisplayPinCode( ...@@ -53,10 +53,10 @@ void FakeBluetoothAgentServiceProvider::DisplayPinCode(
void FakeBluetoothAgentServiceProvider::RequestPasskey( void FakeBluetoothAgentServiceProvider::RequestPasskey(
const dbus::ObjectPath& device_path, const dbus::ObjectPath& device_path,
const Delegate::PasskeyCallback& callback) { Delegate::PasskeyCallback callback) {
VLOG(1) << object_path_.value() << ": RequestPasskey for " VLOG(1) << object_path_.value() << ": RequestPasskey for "
<< device_path.value(); << device_path.value();
delegate_->RequestPasskey(device_path, callback); delegate_->RequestPasskey(device_path, std::move(callback));
} }
void FakeBluetoothAgentServiceProvider::DisplayPasskey( void FakeBluetoothAgentServiceProvider::DisplayPasskey(
...@@ -71,27 +71,27 @@ void FakeBluetoothAgentServiceProvider::DisplayPasskey( ...@@ -71,27 +71,27 @@ void FakeBluetoothAgentServiceProvider::DisplayPasskey(
void FakeBluetoothAgentServiceProvider::RequestConfirmation( void FakeBluetoothAgentServiceProvider::RequestConfirmation(
const dbus::ObjectPath& device_path, const dbus::ObjectPath& device_path,
uint32_t passkey, uint32_t passkey,
const Delegate::ConfirmationCallback& callback) { Delegate::ConfirmationCallback callback) {
VLOG(1) << object_path_.value() << ": RequestConfirmation " << passkey VLOG(1) << object_path_.value() << ": RequestConfirmation " << passkey
<< " for " << device_path.value(); << " for " << device_path.value();
delegate_->RequestConfirmation(device_path, passkey, callback); delegate_->RequestConfirmation(device_path, passkey, std::move(callback));
} }
void FakeBluetoothAgentServiceProvider::RequestAuthorization( void FakeBluetoothAgentServiceProvider::RequestAuthorization(
const dbus::ObjectPath& device_path, const dbus::ObjectPath& device_path,
const Delegate::ConfirmationCallback& callback) { Delegate::ConfirmationCallback callback) {
VLOG(1) << object_path_.value() << ": RequestAuthorization for " VLOG(1) << object_path_.value() << ": RequestAuthorization for "
<< device_path.value(); << device_path.value();
delegate_->RequestAuthorization(device_path, callback); delegate_->RequestAuthorization(device_path, std::move(callback));
} }
void FakeBluetoothAgentServiceProvider::AuthorizeService( void FakeBluetoothAgentServiceProvider::AuthorizeService(
const dbus::ObjectPath& device_path, const dbus::ObjectPath& device_path,
const std::string& uuid, const std::string& uuid,
const Delegate::ConfirmationCallback& callback) { Delegate::ConfirmationCallback callback) {
VLOG(1) << object_path_.value() << ": AuthorizeService " << uuid << " for " VLOG(1) << object_path_.value() << ": AuthorizeService " << uuid << " for "
<< device_path.value(); << device_path.value();
delegate_->AuthorizeService(device_path, uuid, callback); delegate_->AuthorizeService(device_path, uuid, std::move(callback));
} }
void FakeBluetoothAgentServiceProvider::Cancel() { void FakeBluetoothAgentServiceProvider::Cancel() {
......
...@@ -33,24 +33,22 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAgentServiceProvider ...@@ -33,24 +33,22 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAgentServiceProvider
// method on the object passed on construction. // method on the object passed on construction.
virtual void Release(); virtual void Release();
virtual void RequestPinCode(const dbus::ObjectPath& device_path, virtual void RequestPinCode(const dbus::ObjectPath& device_path,
const Delegate::PinCodeCallback& callback); Delegate::PinCodeCallback callback);
virtual void DisplayPinCode(const dbus::ObjectPath& device_path, virtual void DisplayPinCode(const dbus::ObjectPath& device_path,
const std::string& pincode); const std::string& pincode);
virtual void RequestPasskey(const dbus::ObjectPath& device_path, virtual void RequestPasskey(const dbus::ObjectPath& device_path,
const Delegate::PasskeyCallback& callback); Delegate::PasskeyCallback callback);
virtual void DisplayPasskey(const dbus::ObjectPath& device_path, virtual void DisplayPasskey(const dbus::ObjectPath& device_path,
uint32_t passkey, uint32_t passkey,
int16_t entered); int16_t entered);
virtual void RequestConfirmation( virtual void RequestConfirmation(const dbus::ObjectPath& device_path,
const dbus::ObjectPath& device_path, uint32_t passkey,
uint32_t passkey, Delegate::ConfirmationCallback callback);
const Delegate::ConfirmationCallback& callback); virtual void RequestAuthorization(const dbus::ObjectPath& device_path,
virtual void RequestAuthorization( Delegate::ConfirmationCallback callback);
const dbus::ObjectPath& device_path,
const Delegate::ConfirmationCallback& callback);
virtual void AuthorizeService(const dbus::ObjectPath& device_path, virtual void AuthorizeService(const dbus::ObjectPath& device_path,
const std::string& uuid, const std::string& uuid,
const Delegate::ConfirmationCallback& callback); Delegate::ConfirmationCallback callback);
virtual void Cancel(); virtual void Cancel();
private: private:
......
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