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

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

Issue 1915243003: API Bindings for GATT server functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@adapter_and_tests
Patch Set: Created 4 years, 8 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: 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 a7f4ed5bf7fc6c2fe6298e6ab7f364f82ce6639e..381ccdcc5cd5eb20de7a8967d498f92767ba4053 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,16 @@
#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 <memory>
+#include <string>
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_api_advertisement.h"
Devlin 2016/04/27 14:45:03 do we need the full include here, or is the forwar
rkc 2016/04/27 20:38:56 We need the full include. We refer to an enum with
#include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.h"
-#include "chrome/browser/extensions/browser_context_keyed_service_factories.h"
+#include "content/public/browser/browser_context.h"
#include "device/bluetooth/bluetooth_advertisement.h"
#include "extensions/browser/api/api_resource_manager.h"
+#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_function_histogram_value.h"
@@ -57,14 +60,19 @@ namespace api {
// 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 AsyncExtensionFunction {
+//
+// DEPRECATED: This inherits from AsyncExtensionFunction, which we're trying to
+// get rid of for various reasons. Please inherit from the
+// BluetoothLowEnergyExtensionFunction class instead.
+class BluetoothLowEnergyExtensionFunctionDeprecated
+ : public AsyncExtensionFunction {
public:
- BluetoothLowEnergyExtensionFunction();
+ BluetoothLowEnergyExtensionFunctionDeprecated();
protected:
- ~BluetoothLowEnergyExtensionFunction() override;
+ ~BluetoothLowEnergyExtensionFunctionDeprecated() override;
- // ExtensionFunction override.
+ // AsyncExtensionFunction override.
bool RunAsync() override;
// Implemented by individual bluetoothLowEnergy extension functions to perform
@@ -74,11 +82,34 @@ class BluetoothLowEnergyExtensionFunction : public AsyncExtensionFunction {
virtual bool DoWork() = 0;
private:
+ DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunctionDeprecated);
+};
+
+// Replacement for BluetoothLowEnergyExtensionFunctionDeprecated. Has the same
+// functionality except that instead of the SendResponse/return combo, we'll
+// return our response with Respond().
+class BluetoothLowEnergyExtensionFunction : public UIThreadExtensionFunction {
+ public:
+ BluetoothLowEnergyExtensionFunction();
+
+ protected:
+ ~BluetoothLowEnergyExtensionFunction() override;
+
+ // ExtensionFunction override.
+ ExtensionFunction::ResponseAction Run() override;
+
+ // Implemented by individual bluetoothLowEnergy extension functions to perform
+ // the body of the function. This invoked asynchonously after Run after
+ // the BluetoothLowEnergyEventRouter has obtained a handle on the
+ // BluetoothAdapter.
+ virtual void DoWork() = 0;
+
+ private:
DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunction);
};
class BluetoothLowEnergyConnectFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.connect",
BLUETOOTHLOWENERGY_CONNECT);
@@ -86,7 +117,7 @@ class BluetoothLowEnergyConnectFunction
protected:
~BluetoothLowEnergyConnectFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
private:
@@ -97,7 +128,7 @@ class BluetoothLowEnergyConnectFunction
};
class BluetoothLowEnergyDisconnectFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.disconnect",
BLUETOOTHLOWENERGY_DISCONNECT);
@@ -105,7 +136,7 @@ class BluetoothLowEnergyDisconnectFunction
protected:
~BluetoothLowEnergyDisconnectFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
private:
@@ -116,7 +147,7 @@ class BluetoothLowEnergyDisconnectFunction
};
class BluetoothLowEnergyGetServiceFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getService",
BLUETOOTHLOWENERGY_GETSERVICE);
@@ -124,12 +155,12 @@ class BluetoothLowEnergyGetServiceFunction
protected:
~BluetoothLowEnergyGetServiceFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
};
class BluetoothLowEnergyGetServicesFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getServices",
BLUETOOTHLOWENERGY_GETSERVICES);
@@ -137,12 +168,12 @@ class BluetoothLowEnergyGetServicesFunction
protected:
~BluetoothLowEnergyGetServicesFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
};
class BluetoothLowEnergyGetCharacteristicFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristic",
BLUETOOTHLOWENERGY_GETCHARACTERISTIC);
@@ -150,12 +181,12 @@ class BluetoothLowEnergyGetCharacteristicFunction
protected:
~BluetoothLowEnergyGetCharacteristicFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
};
class BluetoothLowEnergyGetCharacteristicsFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristics",
BLUETOOTHLOWENERGY_GETCHARACTERISTICS);
@@ -163,12 +194,12 @@ class BluetoothLowEnergyGetCharacteristicsFunction
protected:
~BluetoothLowEnergyGetCharacteristicsFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
};
class BluetoothLowEnergyGetIncludedServicesFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getIncludedServices",
BLUETOOTHLOWENERGY_GETINCLUDEDSERVICES);
@@ -176,12 +207,12 @@ class BluetoothLowEnergyGetIncludedServicesFunction
protected:
~BluetoothLowEnergyGetIncludedServicesFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
};
class BluetoothLowEnergyGetDescriptorFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptor",
BLUETOOTHLOWENERGY_GETDESCRIPTOR);
@@ -189,12 +220,12 @@ class BluetoothLowEnergyGetDescriptorFunction
protected:
~BluetoothLowEnergyGetDescriptorFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
};
class BluetoothLowEnergyGetDescriptorsFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptors",
BLUETOOTHLOWENERGY_GETDESCRIPTORS);
@@ -202,12 +233,12 @@ class BluetoothLowEnergyGetDescriptorsFunction
protected:
~BluetoothLowEnergyGetDescriptorsFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
};
class BluetoothLowEnergyReadCharacteristicValueFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readCharacteristicValue",
BLUETOOTHLOWENERGY_READCHARACTERISTICVALUE);
@@ -215,7 +246,7 @@ class BluetoothLowEnergyReadCharacteristicValueFunction
protected:
~BluetoothLowEnergyReadCharacteristicValueFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
private:
@@ -229,7 +260,7 @@ class BluetoothLowEnergyReadCharacteristicValueFunction
};
class BluetoothLowEnergyWriteCharacteristicValueFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeCharacteristicValue",
BLUETOOTHLOWENERGY_WRITECHARACTERISTICVALUE);
@@ -237,7 +268,7 @@ class BluetoothLowEnergyWriteCharacteristicValueFunction
protected:
~BluetoothLowEnergyWriteCharacteristicValueFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
private:
@@ -251,7 +282,7 @@ class BluetoothLowEnergyWriteCharacteristicValueFunction
};
class BluetoothLowEnergyStartCharacteristicNotificationsFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION(
"bluetoothLowEnergy.startCharacteristicNotifications",
@@ -260,7 +291,7 @@ class BluetoothLowEnergyStartCharacteristicNotificationsFunction
protected:
~BluetoothLowEnergyStartCharacteristicNotificationsFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
private:
@@ -271,7 +302,7 @@ class BluetoothLowEnergyStartCharacteristicNotificationsFunction
};
class BluetoothLowEnergyStopCharacteristicNotificationsFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION(
"bluetoothLowEnergy.stopCharacteristicNotifications",
@@ -280,7 +311,7 @@ class BluetoothLowEnergyStopCharacteristicNotificationsFunction
protected:
~BluetoothLowEnergyStopCharacteristicNotificationsFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
private:
@@ -291,7 +322,7 @@ class BluetoothLowEnergyStopCharacteristicNotificationsFunction
};
class BluetoothLowEnergyReadDescriptorValueFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readDescriptorValue",
BLUETOOTHLOWENERGY_READDESCRIPTORVALUE);
@@ -299,7 +330,7 @@ class BluetoothLowEnergyReadDescriptorValueFunction
protected:
~BluetoothLowEnergyReadDescriptorValueFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
private:
@@ -313,7 +344,7 @@ class BluetoothLowEnergyReadDescriptorValueFunction
};
class BluetoothLowEnergyWriteDescriptorValueFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeDescriptorValue",
BLUETOOTHLOWENERGY_WRITEDESCRIPTORVALUE);
@@ -321,7 +352,7 @@ class BluetoothLowEnergyWriteDescriptorValueFunction
protected:
~BluetoothLowEnergyWriteDescriptorValueFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
private:
@@ -335,7 +366,7 @@ class BluetoothLowEnergyWriteDescriptorValueFunction
};
class BluetoothLowEnergyAdvertisementFunction
- : public BluetoothLowEnergyExtensionFunction {
+ : public BluetoothLowEnergyExtensionFunctionDeprecated {
public:
BluetoothLowEnergyAdvertisementFunction();
@@ -367,7 +398,7 @@ class BluetoothLowEnergyRegisterAdvertisementFunction
protected:
~BluetoothLowEnergyRegisterAdvertisementFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
private:
@@ -378,6 +409,32 @@ class BluetoothLowEnergyRegisterAdvertisementFunction
std::string instance_id_;
};
+class BluetoothLowEnergyRegisterServiceFunction
+ : public BluetoothLowEnergyExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerService",
+ BLUETOOTHLOWENERGY_CREATESERVICE);
+
+ protected:
+ ~BluetoothLowEnergyRegisterServiceFunction() override {}
+
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
+ void DoWork() override;
+};
+
+class BluetoothLowEnergyUnregisterServiceFunction
+ : public BluetoothLowEnergyExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterService",
+ BLUETOOTHLOWENERGY_CREATESERVICE);
+
+ protected:
+ ~BluetoothLowEnergyUnregisterServiceFunction() override {}
+
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
+ void DoWork() override;
+};
+
class BluetoothLowEnergyUnregisterAdvertisementFunction
: public BluetoothLowEnergyAdvertisementFunction {
public:
@@ -387,7 +444,7 @@ class BluetoothLowEnergyUnregisterAdvertisementFunction
protected:
~BluetoothLowEnergyUnregisterAdvertisementFunction() override {}
- // BluetoothLowEnergyExtensionFunction override.
+ // BluetoothLowEnergyExtensionFunctionDeprecated override.
bool DoWork() override;
private:
@@ -399,6 +456,45 @@ class BluetoothLowEnergyUnregisterAdvertisementFunction
std::string instance_id_;
};
+class BluetoothLowEnergyCreateServiceFunction
+ : public BluetoothLowEnergyExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createService",
+ BLUETOOTHLOWENERGY_CREATESERVICE);
+
+ protected:
+ ~BluetoothLowEnergyCreateServiceFunction() override {}
+
+ // BluetoothLowEnergyExtensionFunction override.
+ void DoWork() override;
+};
+
+class BluetoothLowEnergyCreateCharacteristicFunction
+ : public BluetoothLowEnergyExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createCharacteristic",
+ BLUETOOTHLOWENERGY_CREATESERVICE);
+
+ protected:
+ ~BluetoothLowEnergyCreateCharacteristicFunction() override {}
+
+ // BluetoothLowEnergyExtensionFunction override.
+ void DoWork() override;
+};
+
+class BluetoothLowEnergyCreateDescriptorFunction
+ : public BluetoothLowEnergyExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createDescriptor",
+ BLUETOOTHLOWENERGY_CREATESERVICE);
+
+ protected:
+ ~BluetoothLowEnergyCreateDescriptorFunction() override {}
+
+ // BluetoothLowEnergyExtensionFunction override.
+ void DoWork() override;
+};
+
} // namespace api
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698