Chromium Code Reviews| Index: extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h |
| diff --git a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h |
| index debb635c92b0f5dd77816cf1ad4411de1d5cd2e9..b6e6f8f278c41991a9cdd5ac41be37ec12867c31 100644 |
| --- a/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h |
| +++ b/extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h |
| @@ -6,6 +6,8 @@ |
| #define EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_API_H_ |
| #include "base/memory/scoped_ptr.h" |
| +#include "device/bluetooth/bluetooth_advertisement.h" |
| +#include "extensions/browser/api/api_resource_manager.h" |
| #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event_router.h" |
| #include "extensions/browser/browser_context_keyed_api_factory.h" |
| #include "extensions/browser/extension_function.h" |
| @@ -13,6 +15,7 @@ |
| namespace extensions { |
| +class BluetoothApiAdvertisement; |
| class BluetoothLowEnergyEventRouter; |
| // The profile-keyed service that manages the bluetoothLowEnergy extension API. |
| @@ -329,9 +332,33 @@ class BluetoothLowEnergyWriteDescriptorValueFunction |
| std::string instance_id_; |
| }; |
| -class BluetoothLowEnergyRegisterAdvertisementFunction |
| +class BluetoothLowEnergyAdvertisementFunction |
| : public BluetoothLowEnergyExtensionFunction { |
|
armansito
2015/05/08 22:46:13
I'm trying to understand why this base class is ne
rkc
2015/05/11 21:59:35
Explained offline.
|
| public: |
| + BluetoothLowEnergyAdvertisementFunction(); |
| + |
| + protected: |
| + ~BluetoothLowEnergyAdvertisementFunction() override; |
| + |
| + // Takes ownership. |
| + int AddAdvertisement(BluetoothApiAdvertisement* advertisement); |
| + BluetoothApiAdvertisement* GetAdvertisement(int advertisement_id); |
| + void RemoveAdvertisement(int advertisement_id); |
| + |
| + // ExtensionFunction override. |
| + bool RunAsync() override; |
| + |
| + private: |
| + void Initialize(); |
| + |
| + ApiResourceManager<BluetoothApiAdvertisement>* advertisements_manager_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAdvertisementFunction); |
| +}; |
| + |
| +class BluetoothLowEnergyRegisterAdvertisementFunction |
| + : public BluetoothLowEnergyAdvertisementFunction { |
| + public: |
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerAdvertisement", |
| BLUETOOTHLOWENERGY_REGISTERADVERTISEMENT); |
| @@ -342,17 +369,15 @@ class BluetoothLowEnergyRegisterAdvertisementFunction |
| bool DoWork() override; |
| private: |
| - // Success and error callbacks, called by |
| - // BluetoothLowEnergyEventRouter::WriteDescriptorValue. |
| - void SuccessCallback(); |
| - void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
| + void SuccessCallback(scoped_refptr<device::BluetoothAdvertisement>); |
| + void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); |
| // The instance ID of the requested descriptor. |
| std::string instance_id_; |
| }; |
| class BluetoothLowEnergyUnregisterAdvertisementFunction |
| - : public BluetoothLowEnergyExtensionFunction { |
| + : public BluetoothLowEnergyAdvertisementFunction { |
| public: |
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterAdvertisement", |
| BLUETOOTHLOWENERGY_UNREGISTERADVERTISEMENT); |
| @@ -364,10 +389,9 @@ class BluetoothLowEnergyUnregisterAdvertisementFunction |
| bool DoWork() override; |
| private: |
| - // Success and error callbacks, called by |
| - // BluetoothLowEnergyEventRouter::WriteDescriptorValue. |
| - void SuccessCallback(); |
| - void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
| + void SuccessCallback(int advertisement_id); |
| + void ErrorCallback(int advertisement_id, |
| + device::BluetoothAdvertisement::ErrorCode status); |
| // The instance ID of the requested descriptor. |
| std::string instance_id_; |