Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_api.h

Issue 1132173002: Implement the advertising functions for the BLE API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 {
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_;

Powered by Google App Engine
This is Rietveld 408576698