Commit 782fc629 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

[Code Health] Migrate bluetooth low energy extension API to OnceCallback

This also ended up touching some of //device/bluetooth.

Bug: 834319, 1007786
Change-Id: Iebcf042a74af77d3aac2cce8afb4fc4d2af9d831
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2285450
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786060}
parent e62f453c
...@@ -184,12 +184,12 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattService ...@@ -184,12 +184,12 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattService
// Registers this GATT service. Calling Register will make this service and // Registers this GATT service. Calling Register will make this service and
// all of its associated attributes available on the local adapters GATT // all of its associated attributes available on the local adapters GATT
// database. Call Unregister to make this service no longer available. // database. Call Unregister to make this service no longer available.
virtual void Register(const base::Closure& callback, virtual void Register(base::OnceClosure callback,
ErrorCallback error_callback) = 0; ErrorCallback error_callback) = 0;
// Unregisters this GATT service. This will remove the service from the list // Unregisters this GATT service. This will remove the service from the list
// of services exposed by the adapter this service was registered on. // of services exposed by the adapter this service was registered on.
virtual void Unregister(const base::Closure& callback, virtual void Unregister(base::OnceClosure callback,
ErrorCallback error_callback) = 0; ErrorCallback error_callback) = 0;
// Returns if this service is currently registered. // Returns if this service is currently registered.
......
...@@ -167,7 +167,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ final ...@@ -167,7 +167,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ final
// service not being discoverable in any further scans of the adapter. Any // service not being discoverable in any further scans of the adapter. Any
// sockets listening on this service will need to be closed separately. // sockets listening on this service will need to be closed separately.
void RemoveServiceRecord(uint32_t handle, void RemoveServiceRecord(uint32_t handle,
const base::Closure& callback, base::OnceClosure callback,
const ServiceRecordErrorCallback& error_callback); const ServiceRecordErrorCallback& error_callback);
// Locates the device object by object path (the devices map and // Locates the device object by object path (the devices map and
...@@ -231,13 +231,13 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ final ...@@ -231,13 +231,13 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ final
// Register a GATT service. The service must belong to this adapter. // Register a GATT service. The service must belong to this adapter.
void RegisterGattService( void RegisterGattService(
BluetoothLocalGattServiceBlueZ* service, BluetoothLocalGattServiceBlueZ* service,
const base::Closure& callback, base::OnceClosure callback,
device::BluetoothGattService::ErrorCallback error_callback); device::BluetoothGattService::ErrorCallback error_callback);
// Unregister a GATT service. The service must already be registered. // Unregister a GATT service. The service must already be registered.
void UnregisterGattService( void UnregisterGattService(
BluetoothLocalGattServiceBlueZ* service, BluetoothLocalGattServiceBlueZ* service,
const base::Closure& callback, base::OnceClosure callback,
device::BluetoothGattService::ErrorCallback error_callback); device::BluetoothGattService::ErrorCallback error_callback);
// Returns if a given service is currently registered. // Returns if a given service is currently registered.
...@@ -363,12 +363,12 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ final ...@@ -363,12 +363,12 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ final
void PresentChanged(bool present); void PresentChanged(bool present);
// Called by dbus:: on completion of the discoverable property change. // Called by dbus:: on completion of the discoverable property change.
void OnSetDiscoverable(const base::Closure& callback, void OnSetDiscoverable(base::OnceClosure callback,
const ErrorCallback& error_callback, const ErrorCallback& error_callback,
bool success); bool success);
// Called by dbus:: on completion of an adapter property change. // Called by dbus:: on completion of an adapter property change.
void OnPropertyChangeCompleted(const base::Closure& callback, void OnPropertyChangeCompleted(base::OnceClosure callback,
const ErrorCallback& error_callback, const ErrorCallback& error_callback,
bool success); bool success);
...@@ -384,32 +384,32 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ final ...@@ -384,32 +384,32 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ final
void StopScan(DiscoverySessionResultCallback callback) override; void StopScan(DiscoverySessionResultCallback callback) override;
void SetDiscoveryFilter( void SetDiscoveryFilter(
std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter, std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter,
const base::Closure& callback, base::OnceClosure callback,
DiscoverySessionErrorCallback error_callback); DiscoverySessionErrorCallback error_callback);
// Called by dbus:: on completion of the D-Bus method call to start discovery. // Called by dbus:: on completion of the D-Bus method call to start discovery.
void OnStartDiscovery(const base::Closure& callback, void OnStartDiscovery(base::OnceClosure callback,
DiscoverySessionErrorCallback error_callback); DiscoverySessionErrorCallback error_callback);
void OnStartDiscoveryError(const base::Closure& callback, void OnStartDiscoveryError(base::OnceClosure callback,
DiscoverySessionErrorCallback error_callback, DiscoverySessionErrorCallback error_callback,
const std::string& error_name, const std::string& error_name,
const std::string& error_message); const std::string& error_message);
// Called by dbus:: on completion of the D-Bus method call to stop discovery. // Called by dbus:: on completion of the D-Bus method call to stop discovery.
void OnStopDiscovery(const base::Closure& callback); void OnStopDiscovery(base::OnceClosure callback);
void OnStopDiscoveryError(DiscoverySessionErrorCallback error_callback, void OnStopDiscoveryError(DiscoverySessionErrorCallback error_callback,
const std::string& error_name, const std::string& error_name,
const std::string& error_message); const std::string& error_message);
void OnPreSetDiscoveryFilter(const base::Closure& callback, void OnPreSetDiscoveryFilter(base::OnceClosure callback,
DiscoverySessionErrorCallback error_callback); DiscoverySessionErrorCallback error_callback);
void OnPreSetDiscoveryFilterError( void OnPreSetDiscoveryFilterError(
const base::Closure& callback, base::OnceClosure callback,
DiscoverySessionErrorCallback error_callback, DiscoverySessionErrorCallback error_callback,
device::UMABluetoothDiscoverySessionOutcome outcome); device::UMABluetoothDiscoverySessionOutcome outcome);
void OnSetDiscoveryFilter(const base::Closure& callback, void OnSetDiscoveryFilter(base::OnceClosure callback,
DiscoverySessionErrorCallback error_callback); DiscoverySessionErrorCallback error_callback);
void OnSetDiscoveryFilterError(const base::Closure& callback, void OnSetDiscoveryFilterError(base::OnceClosure callback,
DiscoverySessionErrorCallback error_callback, DiscoverySessionErrorCallback error_callback,
const std::string& error_name, const std::string& error_name,
const std::string& error_message); const std::string& error_message);
...@@ -437,19 +437,19 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ final ...@@ -437,19 +437,19 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ final
// register even if the initial unregister call fails. // register even if the initial unregister call fails.
void UpdateRegisteredApplication( void UpdateRegisteredApplication(
bool ignore_unregister_failure, bool ignore_unregister_failure,
const base::Closure& callback, base::OnceClosure callback,
device::BluetoothGattService::ErrorCallback error_callback); device::BluetoothGattService::ErrorCallback error_callback);
// Make the call to GattManager1 to register the services currently // Make the call to GattManager1 to register the services currently
// registered. // registered.
void RegisterApplication( void RegisterApplication(
const base::Closure& callback, base::OnceClosure callback,
device::BluetoothGattService::ErrorCallback error_callback); device::BluetoothGattService::ErrorCallback error_callback);
// Register application, ignoring the given errors. Used to register a GATT // Register application, ignoring the given errors. Used to register a GATT
// application even if a previous unregister application call fails. // application even if a previous unregister application call fails.
void RegisterApplicationOnError( void RegisterApplicationOnError(
const base::Closure& callback, base::OnceClosure callback,
device::BluetoothGattService::ErrorCallback error_callback, device::BluetoothGattService::ErrorCallback error_callback,
const std::string& error_name, const std::string& error_name,
const std::string& error_message); const std::string& error_message);
......
...@@ -59,15 +59,16 @@ bool BluetoothLocalGattServiceBlueZ::IsPrimary() const { ...@@ -59,15 +59,16 @@ bool BluetoothLocalGattServiceBlueZ::IsPrimary() const {
return is_primary_; return is_primary_;
} }
void BluetoothLocalGattServiceBlueZ::Register(const base::Closure& callback, void BluetoothLocalGattServiceBlueZ::Register(base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
GetAdapter()->RegisterGattService(this, callback, std::move(error_callback)); GetAdapter()->RegisterGattService(this, std::move(callback),
std::move(error_callback));
} }
void BluetoothLocalGattServiceBlueZ::Unregister(const base::Closure& callback, void BluetoothLocalGattServiceBlueZ::Unregister(base::OnceClosure callback,
ErrorCallback error_callback) { ErrorCallback error_callback) {
DCHECK(GetAdapter()); DCHECK(GetAdapter());
GetAdapter()->UnregisterGattService(this, callback, GetAdapter()->UnregisterGattService(this, std::move(callback),
std::move(error_callback)); std::move(error_callback));
} }
......
...@@ -40,9 +40,9 @@ class BluetoothLocalGattServiceBlueZ ...@@ -40,9 +40,9 @@ class BluetoothLocalGattServiceBlueZ
bool IsPrimary() const override; bool IsPrimary() const override;
// device::BluetoothLocalGattService overrides. // device::BluetoothLocalGattService overrides.
void Register(const base::Closure& callback, void Register(base::OnceClosure callback,
ErrorCallback error_callback) override; ErrorCallback error_callback) override;
void Unregister(const base::Closure& callback, void Unregister(base::OnceClosure callback,
ErrorCallback error_callback) override; ErrorCallback error_callback) override;
bool IsRegistered() override; bool IsRegistered() override;
void Delete() override; void Delete() override;
......
...@@ -443,8 +443,8 @@ void BluetoothLowEnergyConnectFunction::DoWork() { ...@@ -443,8 +443,8 @@ void BluetoothLowEnergyConnectFunction::DoWork() {
event_router->Connect( event_router->Connect(
persistent, extension(), params_->device_address, persistent, extension(), params_->device_address,
base::Bind(&BluetoothLowEnergyConnectFunction::SuccessCallback, this), base::BindOnce(&BluetoothLowEnergyConnectFunction::SuccessCallback, this),
base::Bind(&BluetoothLowEnergyConnectFunction::ErrorCallback, this)); base::BindOnce(&BluetoothLowEnergyConnectFunction::ErrorCallback, this));
} }
void BluetoothLowEnergyConnectFunction::SuccessCallback() { void BluetoothLowEnergyConnectFunction::SuccessCallback() {
...@@ -478,8 +478,10 @@ void BluetoothLowEnergyDisconnectFunction::DoWork() { ...@@ -478,8 +478,10 @@ void BluetoothLowEnergyDisconnectFunction::DoWork() {
event_router->Disconnect( event_router->Disconnect(
extension(), params_->device_address, extension(), params_->device_address,
base::Bind(&BluetoothLowEnergyDisconnectFunction::SuccessCallback, this), base::BindOnce(&BluetoothLowEnergyDisconnectFunction::SuccessCallback,
base::Bind(&BluetoothLowEnergyDisconnectFunction::ErrorCallback, this)); this),
base::BindOnce(&BluetoothLowEnergyDisconnectFunction::ErrorCallback,
this));
} }
void BluetoothLowEnergyDisconnectFunction::SuccessCallback() { void BluetoothLowEnergyDisconnectFunction::SuccessCallback() {
...@@ -766,10 +768,10 @@ void BluetoothLowEnergyReadCharacteristicValueFunction::DoWork() { ...@@ -766,10 +768,10 @@ void BluetoothLowEnergyReadCharacteristicValueFunction::DoWork() {
instance_id_ = params_->characteristic_id; instance_id_ = params_->characteristic_id;
event_router->ReadCharacteristicValue( event_router->ReadCharacteristicValue(
extension(), instance_id_, extension(), instance_id_,
base::Bind( base::BindOnce(
&BluetoothLowEnergyReadCharacteristicValueFunction::SuccessCallback, &BluetoothLowEnergyReadCharacteristicValueFunction::SuccessCallback,
this), this),
base::Bind( base::BindOnce(
&BluetoothLowEnergyReadCharacteristicValueFunction::ErrorCallback, &BluetoothLowEnergyReadCharacteristicValueFunction::ErrorCallback,
this)); this));
} }
...@@ -822,10 +824,10 @@ void BluetoothLowEnergyWriteCharacteristicValueFunction::DoWork() { ...@@ -822,10 +824,10 @@ void BluetoothLowEnergyWriteCharacteristicValueFunction::DoWork() {
std::vector<uint8_t> value(params_->value.begin(), params_->value.end()); std::vector<uint8_t> value(params_->value.begin(), params_->value.end());
event_router->WriteCharacteristicValue( event_router->WriteCharacteristicValue(
extension(), params_->characteristic_id, value, extension(), params_->characteristic_id, value,
base::Bind( base::BindOnce(
&BluetoothLowEnergyWriteCharacteristicValueFunction::SuccessCallback, &BluetoothLowEnergyWriteCharacteristicValueFunction::SuccessCallback,
this), this),
base::Bind( base::BindOnce(
&BluetoothLowEnergyWriteCharacteristicValueFunction::ErrorCallback, &BluetoothLowEnergyWriteCharacteristicValueFunction::ErrorCallback,
this)); this));
} }
...@@ -868,10 +870,12 @@ void BluetoothLowEnergyStartCharacteristicNotificationsFunction::DoWork() { ...@@ -868,10 +870,12 @@ void BluetoothLowEnergyStartCharacteristicNotificationsFunction::DoWork() {
event_router->StartCharacteristicNotifications( event_router->StartCharacteristicNotifications(
persistent, extension(), params_->characteristic_id, persistent, extension(), params_->characteristic_id,
base::Bind(&BluetoothLowEnergyStartCharacteristicNotificationsFunction:: base::BindOnce(
&BluetoothLowEnergyStartCharacteristicNotificationsFunction::
SuccessCallback, SuccessCallback,
this), this),
base::Bind(&BluetoothLowEnergyStartCharacteristicNotificationsFunction:: base::BindOnce(
&BluetoothLowEnergyStartCharacteristicNotificationsFunction::
ErrorCallback, ErrorCallback,
this)); this));
} }
...@@ -910,10 +914,12 @@ void BluetoothLowEnergyStopCharacteristicNotificationsFunction::DoWork() { ...@@ -910,10 +914,12 @@ void BluetoothLowEnergyStopCharacteristicNotificationsFunction::DoWork() {
event_router->StopCharacteristicNotifications( event_router->StopCharacteristicNotifications(
extension(), params_->characteristic_id, extension(), params_->characteristic_id,
base::Bind(&BluetoothLowEnergyStopCharacteristicNotificationsFunction:: base::BindOnce(
&BluetoothLowEnergyStopCharacteristicNotificationsFunction::
SuccessCallback, SuccessCallback,
this), this),
base::Bind(&BluetoothLowEnergyStopCharacteristicNotificationsFunction:: base::BindOnce(
&BluetoothLowEnergyStopCharacteristicNotificationsFunction::
ErrorCallback, ErrorCallback,
this)); this));
} }
...@@ -953,11 +959,11 @@ void BluetoothLowEnergyReadDescriptorValueFunction::DoWork() { ...@@ -953,11 +959,11 @@ void BluetoothLowEnergyReadDescriptorValueFunction::DoWork() {
instance_id_ = params_->descriptor_id; instance_id_ = params_->descriptor_id;
event_router->ReadDescriptorValue( event_router->ReadDescriptorValue(
extension(), instance_id_, extension(), instance_id_,
base::Bind( base::BindOnce(
&BluetoothLowEnergyReadDescriptorValueFunction::SuccessCallback, &BluetoothLowEnergyReadDescriptorValueFunction::SuccessCallback,
this), this),
base::Bind(&BluetoothLowEnergyReadDescriptorValueFunction::ErrorCallback, base::BindOnce(
this)); &BluetoothLowEnergyReadDescriptorValueFunction::ErrorCallback, this));
} }
void BluetoothLowEnergyReadDescriptorValueFunction::SuccessCallback() { void BluetoothLowEnergyReadDescriptorValueFunction::SuccessCallback() {
...@@ -1008,10 +1014,11 @@ void BluetoothLowEnergyWriteDescriptorValueFunction::DoWork() { ...@@ -1008,10 +1014,11 @@ void BluetoothLowEnergyWriteDescriptorValueFunction::DoWork() {
std::vector<uint8_t> value(params_->value.begin(), params_->value.end()); std::vector<uint8_t> value(params_->value.begin(), params_->value.end());
event_router->WriteDescriptorValue( event_router->WriteDescriptorValue(
extension(), params_->descriptor_id, value, extension(), params_->descriptor_id, value,
base::Bind( base::BindOnce(
&BluetoothLowEnergyWriteDescriptorValueFunction::SuccessCallback, &BluetoothLowEnergyWriteDescriptorValueFunction::SuccessCallback,
this), this),
base::Bind(&BluetoothLowEnergyWriteDescriptorValueFunction::ErrorCallback, base::BindOnce(
&BluetoothLowEnergyWriteDescriptorValueFunction::ErrorCallback,
this)); this));
} }
...@@ -1426,9 +1433,9 @@ bool BluetoothLowEnergyRegisterServiceFunction::ParseParams() { ...@@ -1426,9 +1433,9 @@ bool BluetoothLowEnergyRegisterServiceFunction::ParseParams() {
void BluetoothLowEnergyRegisterServiceFunction::DoWork() { void BluetoothLowEnergyRegisterServiceFunction::DoWork() {
event_router_->RegisterGattService( event_router_->RegisterGattService(
extension(), params_->service_id, extension(), params_->service_id,
base::Bind(&BluetoothLowEnergyRegisterServiceFunction::SuccessCallback, base::BindOnce(
this), &BluetoothLowEnergyRegisterServiceFunction::SuccessCallback, this),
base::Bind(&BluetoothLowEnergyRegisterServiceFunction::ErrorCallback, base::BindOnce(&BluetoothLowEnergyRegisterServiceFunction::ErrorCallback,
this)); this));
} }
...@@ -1457,10 +1464,10 @@ bool BluetoothLowEnergyUnregisterServiceFunction::ParseParams() { ...@@ -1457,10 +1464,10 @@ bool BluetoothLowEnergyUnregisterServiceFunction::ParseParams() {
void BluetoothLowEnergyUnregisterServiceFunction::DoWork() { void BluetoothLowEnergyUnregisterServiceFunction::DoWork() {
event_router_->UnregisterGattService( event_router_->UnregisterGattService(
extension(), params_->service_id, extension(), params_->service_id,
base::Bind(&BluetoothLowEnergyUnregisterServiceFunction::SuccessCallback, base::BindOnce(
this), &BluetoothLowEnergyUnregisterServiceFunction::SuccessCallback, this),
base::Bind(&BluetoothLowEnergyUnregisterServiceFunction::ErrorCallback, base::BindOnce(
this)); &BluetoothLowEnergyUnregisterServiceFunction::ErrorCallback, this));
} }
void BluetoothLowEnergyUnregisterServiceFunction::SuccessCallback() { void BluetoothLowEnergyUnregisterServiceFunction::SuccessCallback() {
......
...@@ -110,7 +110,7 @@ class BluetoothLowEnergyEventRouter ...@@ -110,7 +110,7 @@ class BluetoothLowEnergyEventRouter
}; };
// Error callback is used by asynchronous methods to report failures. // Error callback is used by asynchronous methods to report failures.
using ErrorCallback = base::Callback<void(Status)>; using ErrorCallback = base::OnceCallback<void(Status)>;
// Returns true if Bluetooth is supported on the current platform or if the // Returns true if Bluetooth is supported on the current platform or if the
// internal |adapter_| instance has been initialized for testing. // internal |adapter_| instance has been initialized for testing.
...@@ -135,8 +135,8 @@ class BluetoothLowEnergyEventRouter ...@@ -135,8 +135,8 @@ class BluetoothLowEnergyEventRouter
void Connect(bool persistent, void Connect(bool persistent,
const Extension* extension, const Extension* extension,
const std::string& device_address, const std::string& device_address,
const base::Closure& callback, base::OnceClosure callback,
const ErrorCallback& error_callback); ErrorCallback error_callback);
// Disconnects the currently open GATT connection of extension |extension| to // Disconnects the currently open GATT connection of extension |extension| to
// device with address |device_address|. |error_callback| is called with an // device with address |device_address|. |error_callback| is called with an
...@@ -145,8 +145,8 @@ class BluetoothLowEnergyEventRouter ...@@ -145,8 +145,8 @@ class BluetoothLowEnergyEventRouter
// extension does not have an open connection to the device. // extension does not have an open connection to the device.
void Disconnect(const Extension* extension, void Disconnect(const Extension* extension,
const std::string& device_address, const std::string& device_address,
const base::Closure& callback, base::OnceClosure callback,
const ErrorCallback& error_callback); ErrorCallback error_callback);
// Returns the list of api::bluetooth_low_energy::Service objects // Returns the list of api::bluetooth_low_energy::Service objects
// associated with the Bluetooth device with address |device_address| in // associated with the Bluetooth device with address |device_address| in
...@@ -219,8 +219,8 @@ class BluetoothLowEnergyEventRouter ...@@ -219,8 +219,8 @@ class BluetoothLowEnergyEventRouter
// failure. |extension| is the extension that made the call. // failure. |extension| is the extension that made the call.
void ReadCharacteristicValue(const Extension* extension, void ReadCharacteristicValue(const Extension* extension,
const std::string& instance_id, const std::string& instance_id,
const base::Closure& callback, base::OnceClosure callback,
const ErrorCallback& error_callback); ErrorCallback error_callback);
// Sends a request to write the value of the characteristic with instance ID // Sends a request to write the value of the characteristic with instance ID
// |instance_id|. Invokes |callback| on success and |error_callback| on // |instance_id|. Invokes |callback| on success and |error_callback| on
...@@ -228,8 +228,8 @@ class BluetoothLowEnergyEventRouter ...@@ -228,8 +228,8 @@ class BluetoothLowEnergyEventRouter
void WriteCharacteristicValue(const Extension* extension, void WriteCharacteristicValue(const Extension* extension,
const std::string& instance_id, const std::string& instance_id,
const std::vector<uint8_t>& value, const std::vector<uint8_t>& value,
const base::Closure& callback, base::OnceClosure callback,
const ErrorCallback& error_callback); ErrorCallback error_callback);
// Sends a request to start characteristic notifications from characteristic // Sends a request to start characteristic notifications from characteristic
// with instance ID |instance_id|, for extension |extension|. Invokes // with instance ID |instance_id|, for extension |extension|. Invokes
...@@ -238,24 +238,24 @@ class BluetoothLowEnergyEventRouter ...@@ -238,24 +238,24 @@ class BluetoothLowEnergyEventRouter
void StartCharacteristicNotifications(bool persistent, void StartCharacteristicNotifications(bool persistent,
const Extension* extension, const Extension* extension,
const std::string& instance_id, const std::string& instance_id,
const base::Closure& callback, base::OnceClosure callback,
const ErrorCallback& error_callback); ErrorCallback error_callback);
// Sends a request to stop characteristic notifications from characteristic // Sends a request to stop characteristic notifications from characteristic
// with instance ID |instance_id|, for extension |extension|. Invokes // with instance ID |instance_id|, for extension |extension|. Invokes
// |callback| on success and |error_callback| on failure. // |callback| on success and |error_callback| on failure.
void StopCharacteristicNotifications(const Extension* extension, void StopCharacteristicNotifications(const Extension* extension,
const std::string& instance_id, const std::string& instance_id,
const base::Closure& callback, base::OnceClosure callback,
const ErrorCallback& error_callback); ErrorCallback error_callback);
// Sends a request to read the value of the descriptor with instance ID // Sends a request to read the value of the descriptor with instance ID
// |instance_id|. Invokes |callback| on success and |error_callback| on // |instance_id|. Invokes |callback| on success and |error_callback| on
// failure. |extension| is the extension that made the call. // failure. |extension| is the extension that made the call.
void ReadDescriptorValue(const Extension* extension, void ReadDescriptorValue(const Extension* extension,
const std::string& instance_id, const std::string& instance_id,
const base::Closure& callback, base::OnceClosure callback,
const ErrorCallback& error_callback); ErrorCallback error_callback);
// Sends a request to write the value of the descriptor with instance ID // Sends a request to write the value of the descriptor with instance ID
// |instance_id|. Invokes |callback| on success and |error_callback| on // |instance_id|. Invokes |callback| on success and |error_callback| on
...@@ -263,8 +263,8 @@ class BluetoothLowEnergyEventRouter ...@@ -263,8 +263,8 @@ class BluetoothLowEnergyEventRouter
void WriteDescriptorValue(const Extension* extension, void WriteDescriptorValue(const Extension* extension,
const std::string& instance_id, const std::string& instance_id,
const std::vector<uint8_t>& value, const std::vector<uint8_t>& value,
const base::Closure& callback, base::OnceClosure callback,
const ErrorCallback& error_callback); ErrorCallback error_callback);
// Initializes the adapter for testing. Used by unit tests only. // Initializes the adapter for testing. Used by unit tests only.
void SetAdapterForTesting(device::BluetoothAdapter* adapter); void SetAdapterForTesting(device::BluetoothAdapter* adapter);
...@@ -372,14 +372,14 @@ class BluetoothLowEnergyEventRouter ...@@ -372,14 +372,14 @@ class BluetoothLowEnergyEventRouter
// Register a local GATT service. // Register a local GATT service.
void RegisterGattService(const Extension* extension, void RegisterGattService(const Extension* extension,
const std::string& service_id, const std::string& service_id,
const base::Closure& callback, base::OnceClosure callback,
const ErrorCallback& error_callback); ErrorCallback error_callback);
// Unregister a local GATT service. // Unregister a local GATT service.
void UnregisterGattService(const Extension* extension, void UnregisterGattService(const Extension* extension,
const std::string& service_id, const std::string& service_id,
const base::Closure& callback, base::OnceClosure callback,
const ErrorCallback& error_callback); ErrorCallback error_callback);
// Handle a response from the app for the given request id. // Handle a response from the app for the given request id.
void HandleRequestResponse(const Extension* extension, void HandleRequestResponse(const Extension* extension,
...@@ -437,11 +437,11 @@ class BluetoothLowEnergyEventRouter ...@@ -437,11 +437,11 @@ class BluetoothLowEnergyEventRouter
// |callback|. // |callback|.
void OnReadRemoteCharacteristicSuccess( void OnReadRemoteCharacteristicSuccess(
const std::string& characteristic_instance_id, const std::string& characteristic_instance_id,
const base::Closure& callback, base::OnceClosure callback,
const std::vector<uint8_t>& value); const std::vector<uint8_t>& value);
// Runs |callback|. // Runs |callback|.
void OnReadRemoteDescriptorSuccess(const base::Closure& callback, void OnReadRemoteDescriptorSuccess(base::OnceClosure callback,
const std::vector<uint8_t>& value); const std::vector<uint8_t>& value);
// Called by BluetoothDevice in response to a call to CreateGattConnection. // Called by BluetoothDevice in response to a call to CreateGattConnection.
...@@ -449,29 +449,29 @@ class BluetoothLowEnergyEventRouter ...@@ -449,29 +449,29 @@ class BluetoothLowEnergyEventRouter
bool persistent, bool persistent,
const std::string& extension_id, const std::string& extension_id,
const std::string& device_address, const std::string& device_address,
const base::Closure& callback, base::OnceClosure callback,
std::unique_ptr<device::BluetoothGattConnection> connection); std::unique_ptr<device::BluetoothGattConnection> connection);
// Called by BluetoothGattService in response to Register(). // Called by BluetoothGattService in response to Register().
void OnRegisterGattServiceSuccess(const std::string& service_id, void OnRegisterGattServiceSuccess(const std::string& service_id,
const std::string& extension_id, const std::string& extension_id,
const base::Closure& callback); base::OnceClosure callback);
// Called by BluetoothGattService in response to Unregister(). // Called by BluetoothGattService in response to Unregister().
void OnUnregisterGattServiceSuccess(const std::string& service_id, void OnUnregisterGattServiceSuccess(const std::string& service_id,
const std::string& extension_id, const std::string& extension_id,
const base::Closure& callback); base::OnceClosure callback);
// Called by BluetoothRemoteGattCharacteristic and // Called by BluetoothRemoteGattCharacteristic and
// BluetoothRemoteGattDescriptor in // BluetoothRemoteGattDescriptor in
// case of an error during the read/write operations. // case of an error during the read/write operations.
void OnError(const ErrorCallback& error_callback, void OnError(ErrorCallback error_callback,
device::BluetoothRemoteGattService::GattErrorCode error_code); device::BluetoothRemoteGattService::GattErrorCode error_code);
// Called by BluetoothDevice in response to a call to CreateGattConnection. // Called by BluetoothDevice in response to a call to CreateGattConnection.
void OnConnectError(const std::string& extension_id, void OnConnectError(const std::string& extension_id,
const std::string& device_address, const std::string& device_address,
const ErrorCallback& error_callback, ErrorCallback error_callback,
device::BluetoothDevice::ConnectErrorCode error_code); device::BluetoothDevice::ConnectErrorCode error_code);
// Called by BluetoothRemoteGattCharacteristic in response to a call to // Called by BluetoothRemoteGattCharacteristic in response to a call to
...@@ -480,7 +480,7 @@ class BluetoothLowEnergyEventRouter ...@@ -480,7 +480,7 @@ class BluetoothLowEnergyEventRouter
bool persistent, bool persistent,
const std::string& extension_id, const std::string& extension_id,
const std::string& characteristic_id, const std::string& characteristic_id,
const base::Closure& callback, base::OnceClosure callback,
std::unique_ptr<device::BluetoothGattNotifySession> session); std::unique_ptr<device::BluetoothGattNotifySession> session);
// Called by BluetoothRemoteGattCharacteristic in response to a call to // Called by BluetoothRemoteGattCharacteristic in response to a call to
...@@ -488,13 +488,13 @@ class BluetoothLowEnergyEventRouter ...@@ -488,13 +488,13 @@ class BluetoothLowEnergyEventRouter
void OnStartNotifySessionError( void OnStartNotifySessionError(
const std::string& extension_id, const std::string& extension_id,
const std::string& characteristic_id, const std::string& characteristic_id,
const ErrorCallback& error_callback, ErrorCallback error_callback,
device::BluetoothRemoteGattService::GattErrorCode error_code); device::BluetoothRemoteGattService::GattErrorCode error_code);
// Called by BluetoothGattNotifySession in response to a call to Stop. // Called by BluetoothGattNotifySession in response to a call to Stop.
void OnStopNotifySession(const std::string& extension_id, void OnStopNotifySession(const std::string& extension_id,
const std::string& characteristic_id, const std::string& characteristic_id,
const base::Closure& callback); base::OnceClosure callback);
// Finds and returns a BluetoothLowEnergyConnection to device with address // Finds and returns a BluetoothLowEnergyConnection to device with address
// |device_address| from the managed API resources for extension with ID // |device_address| from the managed API resources for extension with ID
......
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