| Index: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.h
|
| diff --git a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.h b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.h
|
| index 4f302adc174aa44defd580af72a9a6d86c4c12ce..f5dda5cfa96e003a2c5c2cc97b601b360f371e0d 100644
|
| --- a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.h
|
| +++ b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.h
|
| @@ -5,13 +5,80 @@
|
| #ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_API_H_
|
| #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_API_H_
|
|
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "extensions/browser/browser_context_keyed_api_factory.h"
|
| #include "extensions/browser/extension_function.h"
|
| #include "extensions/browser/extension_function_histogram_value.h"
|
|
|
| namespace extensions {
|
| +
|
| +class BluetoothLowEnergyEventRouter;
|
| +
|
| +// The profile-keyed service that manages the bluetoothLowEnergy extension API.
|
| +class BluetoothLowEnergyAPI : public BrowserContextKeyedAPI {
|
| + public:
|
| + static BrowserContextKeyedAPIFactory<BluetoothLowEnergyAPI>*
|
| + GetFactoryInstance();
|
| +
|
| + // Convenience method to get the BluetoothLowEnergy API for a browser context.
|
| + static BluetoothLowEnergyAPI* Get(content::BrowserContext* context);
|
| +
|
| + explicit BluetoothLowEnergyAPI(content::BrowserContext* context);
|
| + virtual ~BluetoothLowEnergyAPI();
|
| +
|
| + // KeyedService implementation..
|
| + virtual void Shutdown() OVERRIDE;
|
| +
|
| + BluetoothLowEnergyEventRouter* event_router() const {
|
| + return event_router_.get();
|
| + }
|
| +
|
| + // BrowserContextKeyedAPI implementation.
|
| + static const char* service_name() { return "BluetoothLowEnergyAPI"; }
|
| + static const bool kServiceRedirectedInIncognito = true;
|
| + static const bool kServiceIsNULLWhileTesting = true;
|
| +
|
| + private:
|
| + friend class BrowserContextKeyedAPIFactory<BluetoothLowEnergyAPI>;
|
| +
|
| + scoped_ptr<BluetoothLowEnergyEventRouter> event_router_;
|
| +
|
| + content::BrowserContext* browser_context_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAPI);
|
| +};
|
| +
|
| namespace api {
|
|
|
| -class BluetoothLowEnergyGetServiceFunction : public UIThreadExtensionFunction {
|
| +// Base class for bluetoothLowEnergy API functions. This class handles some of
|
| +// the common logic involved in all API functions, such as checking for
|
| +// platform support and returning the correct error.
|
| +class BluetoothLowEnergyExtensionFunction : public UIThreadExtensionFunction {
|
| + public:
|
| + BluetoothLowEnergyExtensionFunction();
|
| +
|
| + protected:
|
| + virtual ~BluetoothLowEnergyExtensionFunction();
|
| +
|
| + // ExtensionFunction override.
|
| + virtual bool RunImpl() OVERRIDE;
|
| +
|
| + // Implemented by individual bluetoothLowEnergy extension functions to perform
|
| + // the body of the function. This invoked asynchonously after RunImpl after
|
| + // the BluetoothLowEnergyEventRouter has obtained a handle on the
|
| + // BluetoothAdapter.
|
| + virtual void DoWork() = 0;
|
| +
|
| + private:
|
| + // Note: This should remain the last member so it'll be destroyed and
|
| + // invalidate its weak pointers before any other members are destroyed.
|
| + base::WeakPtrFactory<BluetoothLowEnergyExtensionFunction> weak_ptr_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunction);
|
| +};
|
| +
|
| +class BluetoothLowEnergyGetServiceFunction
|
| + : public BluetoothLowEnergyExtensionFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getService",
|
| BLUETOOTHLOWENERGY_GETSERVICE);
|
| @@ -19,11 +86,12 @@ class BluetoothLowEnergyGetServiceFunction : public UIThreadExtensionFunction {
|
| protected:
|
| virtual ~BluetoothLowEnergyGetServiceFunction() {}
|
|
|
| - // UIThreadExtensionFunction override.
|
| - virtual bool RunImpl() OVERRIDE;
|
| + // BluetoothLowEnergyExtensionFunction override.
|
| + virtual void DoWork() OVERRIDE;
|
| };
|
|
|
| -class BluetoothLowEnergyGetServicesFunction : public UIThreadExtensionFunction {
|
| +class BluetoothLowEnergyGetServicesFunction
|
| + : public BluetoothLowEnergyExtensionFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getServices",
|
| BLUETOOTHLOWENERGY_GETSERVICES);
|
| @@ -31,12 +99,12 @@ class BluetoothLowEnergyGetServicesFunction : public UIThreadExtensionFunction {
|
| protected:
|
| virtual ~BluetoothLowEnergyGetServicesFunction() {}
|
|
|
| - // UIThreadExtensionFunction override.
|
| - virtual bool RunImpl() OVERRIDE;
|
| + // BluetoothLowEnergyExtensionFunction override.
|
| + virtual void DoWork() OVERRIDE;
|
| };
|
|
|
| class BluetoothLowEnergyGetCharacteristicFunction
|
| - : public UIThreadExtensionFunction {
|
| + : public BluetoothLowEnergyExtensionFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristic",
|
| BLUETOOTHLOWENERGY_GETCHARACTERISTIC);
|
| @@ -44,12 +112,12 @@ class BluetoothLowEnergyGetCharacteristicFunction
|
| protected:
|
| virtual ~BluetoothLowEnergyGetCharacteristicFunction() {}
|
|
|
| - // UIThreadExtensionFunction override.
|
| - virtual bool RunImpl() OVERRIDE;
|
| + // BluetoothLowEnergyExtensionFunction override.
|
| + virtual void DoWork() OVERRIDE;
|
| };
|
|
|
| class BluetoothLowEnergyGetCharacteristicsFunction
|
| - : public UIThreadExtensionFunction {
|
| + : public BluetoothLowEnergyExtensionFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristics",
|
| BLUETOOTHLOWENERGY_GETCHARACTERISTICS);
|
| @@ -57,12 +125,12 @@ class BluetoothLowEnergyGetCharacteristicsFunction
|
| protected:
|
| virtual ~BluetoothLowEnergyGetCharacteristicsFunction() {}
|
|
|
| - // UIThreadExtensionFunction override.
|
| - virtual bool RunImpl() OVERRIDE;
|
| + // BluetoothLowEnergyExtensionFunction override.
|
| + virtual void DoWork() OVERRIDE;
|
| };
|
|
|
| class BluetoothLowEnergyGetIncludedServicesFunction
|
| - : public UIThreadExtensionFunction {
|
| + : public BluetoothLowEnergyExtensionFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getIncludedServices",
|
| BLUETOOTHLOWENERGY_GETINCLUDEDSERVICES);
|
| @@ -70,12 +138,12 @@ class BluetoothLowEnergyGetIncludedServicesFunction
|
| protected:
|
| virtual ~BluetoothLowEnergyGetIncludedServicesFunction() {}
|
|
|
| - // UIThreadExtensionFunction override.
|
| - virtual bool RunImpl() OVERRIDE;
|
| + // BluetoothLowEnergyExtensionFunction override.
|
| + virtual void DoWork() OVERRIDE;
|
| };
|
|
|
| class BluetoothLowEnergyGetDescriptorFunction
|
| - : public UIThreadExtensionFunction {
|
| + : public BluetoothLowEnergyExtensionFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptor",
|
| BLUETOOTHLOWENERGY_GETDESCRIPTOR);
|
| @@ -83,12 +151,12 @@ class BluetoothLowEnergyGetDescriptorFunction
|
| protected:
|
| virtual ~BluetoothLowEnergyGetDescriptorFunction() {}
|
|
|
| - // UIThreadExtensionFunction override.
|
| - virtual bool RunImpl() OVERRIDE;
|
| + // BluetoothLowEnergyExtensionFunction override.
|
| + virtual void DoWork() OVERRIDE;
|
| };
|
|
|
| class BluetoothLowEnergyGetDescriptorsFunction
|
| - : public UIThreadExtensionFunction {
|
| + : public BluetoothLowEnergyExtensionFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptors",
|
| BLUETOOTHLOWENERGY_GETDESCRIPTORS);
|
| @@ -96,12 +164,12 @@ class BluetoothLowEnergyGetDescriptorsFunction
|
| protected:
|
| virtual ~BluetoothLowEnergyGetDescriptorsFunction() {}
|
|
|
| - // UIThreadExtensionFunction override.
|
| - virtual bool RunImpl() OVERRIDE;
|
| + // BluetoothLowEnergyExtensionFunction override.
|
| + virtual void DoWork() OVERRIDE;
|
| };
|
|
|
| class BluetoothLowEnergyReadCharacteristicValueFunction
|
| - : public UIThreadExtensionFunction {
|
| + : public BluetoothLowEnergyExtensionFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readCharacteristicValue",
|
| BLUETOOTHLOWENERGY_READCHARACTERISTICVALUE);
|
| @@ -109,12 +177,12 @@ class BluetoothLowEnergyReadCharacteristicValueFunction
|
| protected:
|
| virtual ~BluetoothLowEnergyReadCharacteristicValueFunction() {}
|
|
|
| - // UIThreadExtensionFunction override.
|
| - virtual bool RunImpl() OVERRIDE;
|
| + // BluetoothLowEnergyExtensionFunction override.
|
| + virtual void DoWork() OVERRIDE;
|
| };
|
|
|
| class BluetoothLowEnergyWriteCharacteristicValueFunction
|
| - : public UIThreadExtensionFunction {
|
| + : public BluetoothLowEnergyExtensionFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeCharacteristicValue",
|
| BLUETOOTHLOWENERGY_WRITECHARACTERISTICVALUE);
|
| @@ -122,12 +190,12 @@ class BluetoothLowEnergyWriteCharacteristicValueFunction
|
| protected:
|
| virtual ~BluetoothLowEnergyWriteCharacteristicValueFunction() {}
|
|
|
| - // UIThreadExtensionFunction override.
|
| - virtual bool RunImpl() OVERRIDE;
|
| + // BluetoothLowEnergyExtensionFunction override.
|
| + virtual void DoWork() OVERRIDE;
|
| };
|
|
|
| class BluetoothLowEnergyReadDescriptorValueFunction
|
| - : public UIThreadExtensionFunction {
|
| + : public BluetoothLowEnergyExtensionFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readDescriptorValue",
|
| BLUETOOTHLOWENERGY_READDESCRIPTORVALUE);
|
| @@ -135,12 +203,12 @@ class BluetoothLowEnergyReadDescriptorValueFunction
|
| protected:
|
| virtual ~BluetoothLowEnergyReadDescriptorValueFunction() {}
|
|
|
| - // UIThreadExtensionFunction override.
|
| - virtual bool RunImpl() OVERRIDE;
|
| + // BluetoothLowEnergyExtensionFunction override.
|
| + virtual void DoWork() OVERRIDE;
|
| };
|
|
|
| class BluetoothLowEnergyWriteDescriptorValueFunction
|
| - : public UIThreadExtensionFunction {
|
| + : public BluetoothLowEnergyExtensionFunction {
|
| public:
|
| DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeDescriptorValue",
|
| BLUETOOTHLOWENERGY_WRITEDESCRIPTORVALUE);
|
| @@ -148,8 +216,8 @@ class BluetoothLowEnergyWriteDescriptorValueFunction
|
| protected:
|
| virtual ~BluetoothLowEnergyWriteDescriptorValueFunction() {}
|
|
|
| - // UIThreadExtensionFunction override.
|
| - virtual bool RunImpl() OVERRIDE;
|
| + // BluetoothLowEnergyExtensionFunction override.
|
| + virtual void DoWork() OVERRIDE;
|
| };
|
|
|
| } // namespace api
|
|
|