Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_ API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_ API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_ API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_ API_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_api_adver tisement.h" | |
| 11 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ y_event_router.h" | 13 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ y_event_router.h" |
| 12 #include "chrome/browser/extensions/browser_context_keyed_service_factories.h" | 14 #include "content/public/browser/browser_context.h" |
| 13 #include "device/bluetooth/bluetooth_advertisement.h" | 15 #include "device/bluetooth/bluetooth_advertisement.h" |
| 14 #include "extensions/browser/api/api_resource_manager.h" | 16 #include "extensions/browser/api/api_resource_manager.h" |
| 17 #include "extensions/browser/browser_context_keyed_api_factory.h" | |
| 15 #include "extensions/browser/extension_function.h" | 18 #include "extensions/browser/extension_function.h" |
| 16 #include "extensions/browser/extension_function_histogram_value.h" | 19 #include "extensions/browser/extension_function_histogram_value.h" |
| 17 | 20 |
| 21 namespace apibtle = extensions::api::bluetooth_low_energy; | |
|
Devlin
2016/05/02 22:27:58
nit: this isn't typically allowed - only in .cc fi
rkc
2016/05/02 23:25:50
Done.
| |
| 22 | |
| 18 namespace extensions { | 23 namespace extensions { |
| 19 | |
| 20 class BluetoothApiAdvertisement; | 24 class BluetoothApiAdvertisement; |
| 21 class BluetoothLowEnergyEventRouter; | 25 class BluetoothLowEnergyEventRouter; |
| 22 | 26 |
| 27 namespace api { | |
| 28 namespace bluetooth_low_energy { | |
| 29 namespace CreateService { | |
| 30 struct Params; | |
| 31 } | |
| 32 namespace CreateCharacteristic { | |
| 33 struct Params; | |
| 34 } | |
| 35 namespace CreateDescriptor { | |
| 36 struct Params; | |
| 37 } | |
| 38 namespace RegisterService { | |
| 39 struct Params; | |
| 40 } | |
| 41 namespace UnregisterService { | |
| 42 struct Params; | |
| 43 } | |
| 44 namespace SendRequestResponse { | |
| 45 struct Params; | |
| 46 } | |
| 47 } // namespace bluetooth_low_energy | |
| 48 } // namespace api | |
| 49 | |
| 23 // The profile-keyed service that manages the bluetoothLowEnergy extension API. | 50 // The profile-keyed service that manages the bluetoothLowEnergy extension API. |
| 24 class BluetoothLowEnergyAPI : public BrowserContextKeyedAPI { | 51 class BluetoothLowEnergyAPI : public BrowserContextKeyedAPI { |
| 25 public: | 52 public: |
| 26 static BrowserContextKeyedAPIFactory<BluetoothLowEnergyAPI>* | 53 static BrowserContextKeyedAPIFactory<BluetoothLowEnergyAPI>* |
| 27 GetFactoryInstance(); | 54 GetFactoryInstance(); |
| 28 | 55 |
| 29 // Convenience method to get the BluetoothLowEnergy API for a browser context. | 56 // Convenience method to get the BluetoothLowEnergy API for a browser context. |
| 30 static BluetoothLowEnergyAPI* Get(content::BrowserContext* context); | 57 static BluetoothLowEnergyAPI* Get(content::BrowserContext* context); |
| 31 | 58 |
| 32 explicit BluetoothLowEnergyAPI(content::BrowserContext* context); | 59 explicit BluetoothLowEnergyAPI(content::BrowserContext* context); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 50 std::unique_ptr<BluetoothLowEnergyEventRouter> event_router_; | 77 std::unique_ptr<BluetoothLowEnergyEventRouter> event_router_; |
| 51 | 78 |
| 52 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAPI); | 79 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAPI); |
| 53 }; | 80 }; |
| 54 | 81 |
| 55 namespace api { | 82 namespace api { |
| 56 | 83 |
| 57 // Base class for bluetoothLowEnergy API functions. This class handles some of | 84 // Base class for bluetoothLowEnergy API functions. This class handles some of |
| 58 // the common logic involved in all API functions, such as checking for | 85 // the common logic involved in all API functions, such as checking for |
| 59 // platform support and returning the correct error. | 86 // platform support and returning the correct error. |
| 60 class BluetoothLowEnergyExtensionFunction : public AsyncExtensionFunction { | 87 // |
| 88 // DEPRECATED: This inherits from AsyncExtensionFunction, which we're trying to | |
| 89 // get rid of for various reasons. Please inherit from the | |
| 90 // BluetoothLowEnergyExtensionFunction class instead. | |
| 91 class BluetoothLowEnergyExtensionFunctionDeprecated | |
| 92 : public AsyncExtensionFunction { | |
| 61 public: | 93 public: |
| 62 BluetoothLowEnergyExtensionFunction(); | 94 BluetoothLowEnergyExtensionFunctionDeprecated(); |
| 63 | 95 |
| 64 protected: | 96 protected: |
| 65 ~BluetoothLowEnergyExtensionFunction() override; | 97 ~BluetoothLowEnergyExtensionFunctionDeprecated() override; |
| 66 | 98 |
| 67 // ExtensionFunction override. | 99 // AsyncExtensionFunction override. |
| 68 bool RunAsync() override; | 100 bool RunAsync() override; |
| 69 | 101 |
| 70 // Implemented by individual bluetoothLowEnergy extension functions to perform | 102 // Implemented by individual bluetoothLowEnergy extension functions to perform |
| 71 // the body of the function. This invoked asynchonously after RunAsync after | 103 // the body of the function. This invoked asynchonously after RunAsync after |
| 72 // the BluetoothLowEnergyEventRouter has obtained a handle on the | 104 // the BluetoothLowEnergyEventRouter has obtained a handle on the |
| 73 // BluetoothAdapter. | 105 // BluetoothAdapter. |
| 74 virtual bool DoWork() = 0; | 106 virtual bool DoWork() = 0; |
| 75 | 107 |
| 76 private: | 108 private: |
| 109 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunctionDeprecated); | |
| 110 }; | |
| 111 | |
| 112 // Replacement for BluetoothLowEnergyExtensionFunctionDeprecated. Has the same | |
| 113 // functionality except that instead of the SendResponse/return combo, we'll | |
| 114 // return our response with Respond(). | |
| 115 class BluetoothLowEnergyExtensionFunction : public UIThreadExtensionFunction { | |
| 116 public: | |
| 117 BluetoothLowEnergyExtensionFunction(); | |
| 118 | |
| 119 protected: | |
| 120 ~BluetoothLowEnergyExtensionFunction() override; | |
| 121 | |
| 122 // ExtensionFunction override. | |
| 123 ResponseAction Run() override; | |
| 124 | |
| 125 // Implemented by individual bluetoothLowEnergy extension functions to perform | |
| 126 // the body of the function. This invoked asynchonously after Run after | |
| 127 // the BluetoothLowEnergyEventRouter has obtained a handle on the | |
| 128 // BluetoothAdapter. | |
| 129 virtual void DoWork() = 0; | |
| 130 | |
| 131 private: | |
| 77 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunction); | 132 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunction); |
| 78 }; | 133 }; |
| 79 | 134 |
| 135 // Base class for bluetoothLowEnergy API peripheral mode functions. This class | |
| 136 // handles some of the common logic involved in all API peripheral mode | |
| 137 // functions, such as checking for peripheral permissions and returning the | |
| 138 // correct error. | |
| 139 template <typename Params> | |
| 140 class BLEPeripheralExtensionFunction | |
| 141 : public BluetoothLowEnergyExtensionFunction { | |
| 142 public: | |
| 143 BLEPeripheralExtensionFunction(); | |
| 144 | |
| 145 protected: | |
| 146 ~BLEPeripheralExtensionFunction() override; | |
| 147 | |
| 148 // ExtensionFunction override. | |
| 149 ResponseAction Run() override; | |
| 150 | |
| 151 std::unique_ptr<Params> params_; | |
| 152 | |
| 153 private: | |
| 154 DISALLOW_COPY_AND_ASSIGN(BLEPeripheralExtensionFunction); | |
| 155 }; | |
| 156 | |
| 80 class BluetoothLowEnergyConnectFunction | 157 class BluetoothLowEnergyConnectFunction |
| 81 : public BluetoothLowEnergyExtensionFunction { | 158 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 82 public: | 159 public: |
| 83 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.connect", | 160 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.connect", |
| 84 BLUETOOTHLOWENERGY_CONNECT); | 161 BLUETOOTHLOWENERGY_CONNECT); |
| 85 | 162 |
| 86 protected: | 163 protected: |
| 87 ~BluetoothLowEnergyConnectFunction() override {} | 164 ~BluetoothLowEnergyConnectFunction() override {} |
| 88 | 165 |
| 89 // BluetoothLowEnergyExtensionFunction override. | 166 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 90 bool DoWork() override; | 167 bool DoWork() override; |
| 91 | 168 |
| 92 private: | 169 private: |
| 93 // Success and error callbacks, called by | 170 // Success and error callbacks, called by |
| 94 // BluetoothLowEnergyEventRouter::Connect. | 171 // BluetoothLowEnergyEventRouter::Connect. |
| 95 void SuccessCallback(); | 172 void SuccessCallback(); |
| 96 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 173 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
| 97 }; | 174 }; |
| 98 | 175 |
| 99 class BluetoothLowEnergyDisconnectFunction | 176 class BluetoothLowEnergyDisconnectFunction |
| 100 : public BluetoothLowEnergyExtensionFunction { | 177 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 101 public: | 178 public: |
| 102 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.disconnect", | 179 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.disconnect", |
| 103 BLUETOOTHLOWENERGY_DISCONNECT); | 180 BLUETOOTHLOWENERGY_DISCONNECT); |
| 104 | 181 |
| 105 protected: | 182 protected: |
| 106 ~BluetoothLowEnergyDisconnectFunction() override {} | 183 ~BluetoothLowEnergyDisconnectFunction() override {} |
| 107 | 184 |
| 108 // BluetoothLowEnergyExtensionFunction override. | 185 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 109 bool DoWork() override; | 186 bool DoWork() override; |
| 110 | 187 |
| 111 private: | 188 private: |
| 112 // Success and error callbacks, called by | 189 // Success and error callbacks, called by |
| 113 // BluetoothLowEnergyEventRouter::Disconnect. | 190 // BluetoothLowEnergyEventRouter::Disconnect. |
| 114 void SuccessCallback(); | 191 void SuccessCallback(); |
| 115 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 192 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
| 116 }; | 193 }; |
| 117 | 194 |
| 118 class BluetoothLowEnergyGetServiceFunction | 195 class BluetoothLowEnergyGetServiceFunction |
| 119 : public BluetoothLowEnergyExtensionFunction { | 196 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 120 public: | 197 public: |
| 121 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getService", | 198 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getService", |
| 122 BLUETOOTHLOWENERGY_GETSERVICE); | 199 BLUETOOTHLOWENERGY_GETSERVICE); |
| 123 | 200 |
| 124 protected: | 201 protected: |
| 125 ~BluetoothLowEnergyGetServiceFunction() override {} | 202 ~BluetoothLowEnergyGetServiceFunction() override {} |
| 126 | 203 |
| 127 // BluetoothLowEnergyExtensionFunction override. | 204 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 128 bool DoWork() override; | 205 bool DoWork() override; |
| 129 }; | 206 }; |
| 130 | 207 |
| 131 class BluetoothLowEnergyGetServicesFunction | 208 class BluetoothLowEnergyGetServicesFunction |
| 132 : public BluetoothLowEnergyExtensionFunction { | 209 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 133 public: | 210 public: |
| 134 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getServices", | 211 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getServices", |
| 135 BLUETOOTHLOWENERGY_GETSERVICES); | 212 BLUETOOTHLOWENERGY_GETSERVICES); |
| 136 | 213 |
| 137 protected: | 214 protected: |
| 138 ~BluetoothLowEnergyGetServicesFunction() override {} | 215 ~BluetoothLowEnergyGetServicesFunction() override {} |
| 139 | 216 |
| 140 // BluetoothLowEnergyExtensionFunction override. | 217 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 141 bool DoWork() override; | 218 bool DoWork() override; |
| 142 }; | 219 }; |
| 143 | 220 |
| 144 class BluetoothLowEnergyGetCharacteristicFunction | 221 class BluetoothLowEnergyGetCharacteristicFunction |
| 145 : public BluetoothLowEnergyExtensionFunction { | 222 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 146 public: | 223 public: |
| 147 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristic", | 224 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristic", |
| 148 BLUETOOTHLOWENERGY_GETCHARACTERISTIC); | 225 BLUETOOTHLOWENERGY_GETCHARACTERISTIC); |
| 149 | 226 |
| 150 protected: | 227 protected: |
| 151 ~BluetoothLowEnergyGetCharacteristicFunction() override {} | 228 ~BluetoothLowEnergyGetCharacteristicFunction() override {} |
| 152 | 229 |
| 153 // BluetoothLowEnergyExtensionFunction override. | 230 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 154 bool DoWork() override; | 231 bool DoWork() override; |
| 155 }; | 232 }; |
| 156 | 233 |
| 157 class BluetoothLowEnergyGetCharacteristicsFunction | 234 class BluetoothLowEnergyGetCharacteristicsFunction |
| 158 : public BluetoothLowEnergyExtensionFunction { | 235 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 159 public: | 236 public: |
| 160 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristics", | 237 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristics", |
| 161 BLUETOOTHLOWENERGY_GETCHARACTERISTICS); | 238 BLUETOOTHLOWENERGY_GETCHARACTERISTICS); |
| 162 | 239 |
| 163 protected: | 240 protected: |
| 164 ~BluetoothLowEnergyGetCharacteristicsFunction() override {} | 241 ~BluetoothLowEnergyGetCharacteristicsFunction() override {} |
| 165 | 242 |
| 166 // BluetoothLowEnergyExtensionFunction override. | 243 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 167 bool DoWork() override; | 244 bool DoWork() override; |
| 168 }; | 245 }; |
| 169 | 246 |
| 170 class BluetoothLowEnergyGetIncludedServicesFunction | 247 class BluetoothLowEnergyGetIncludedServicesFunction |
| 171 : public BluetoothLowEnergyExtensionFunction { | 248 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 172 public: | 249 public: |
| 173 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getIncludedServices", | 250 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getIncludedServices", |
| 174 BLUETOOTHLOWENERGY_GETINCLUDEDSERVICES); | 251 BLUETOOTHLOWENERGY_GETINCLUDEDSERVICES); |
| 175 | 252 |
| 176 protected: | 253 protected: |
| 177 ~BluetoothLowEnergyGetIncludedServicesFunction() override {} | 254 ~BluetoothLowEnergyGetIncludedServicesFunction() override {} |
| 178 | 255 |
| 179 // BluetoothLowEnergyExtensionFunction override. | 256 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 180 bool DoWork() override; | 257 bool DoWork() override; |
| 181 }; | 258 }; |
| 182 | 259 |
| 183 class BluetoothLowEnergyGetDescriptorFunction | 260 class BluetoothLowEnergyGetDescriptorFunction |
| 184 : public BluetoothLowEnergyExtensionFunction { | 261 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 185 public: | 262 public: |
| 186 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptor", | 263 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptor", |
| 187 BLUETOOTHLOWENERGY_GETDESCRIPTOR); | 264 BLUETOOTHLOWENERGY_GETDESCRIPTOR); |
| 188 | 265 |
| 189 protected: | 266 protected: |
| 190 ~BluetoothLowEnergyGetDescriptorFunction() override {} | 267 ~BluetoothLowEnergyGetDescriptorFunction() override {} |
| 191 | 268 |
| 192 // BluetoothLowEnergyExtensionFunction override. | 269 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 193 bool DoWork() override; | 270 bool DoWork() override; |
| 194 }; | 271 }; |
| 195 | 272 |
| 196 class BluetoothLowEnergyGetDescriptorsFunction | 273 class BluetoothLowEnergyGetDescriptorsFunction |
| 197 : public BluetoothLowEnergyExtensionFunction { | 274 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 198 public: | 275 public: |
| 199 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptors", | 276 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptors", |
| 200 BLUETOOTHLOWENERGY_GETDESCRIPTORS); | 277 BLUETOOTHLOWENERGY_GETDESCRIPTORS); |
| 201 | 278 |
| 202 protected: | 279 protected: |
| 203 ~BluetoothLowEnergyGetDescriptorsFunction() override {} | 280 ~BluetoothLowEnergyGetDescriptorsFunction() override {} |
| 204 | 281 |
| 205 // BluetoothLowEnergyExtensionFunction override. | 282 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 206 bool DoWork() override; | 283 bool DoWork() override; |
| 207 }; | 284 }; |
| 208 | 285 |
| 209 class BluetoothLowEnergyReadCharacteristicValueFunction | 286 class BluetoothLowEnergyReadCharacteristicValueFunction |
| 210 : public BluetoothLowEnergyExtensionFunction { | 287 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 211 public: | 288 public: |
| 212 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readCharacteristicValue", | 289 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readCharacteristicValue", |
| 213 BLUETOOTHLOWENERGY_READCHARACTERISTICVALUE); | 290 BLUETOOTHLOWENERGY_READCHARACTERISTICVALUE); |
| 214 | 291 |
| 215 protected: | 292 protected: |
| 216 ~BluetoothLowEnergyReadCharacteristicValueFunction() override {} | 293 ~BluetoothLowEnergyReadCharacteristicValueFunction() override {} |
| 217 | 294 |
| 218 // BluetoothLowEnergyExtensionFunction override. | 295 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 219 bool DoWork() override; | 296 bool DoWork() override; |
| 220 | 297 |
| 221 private: | 298 private: |
| 222 // Success and error callbacks, called by | 299 // Success and error callbacks, called by |
| 223 // BluetoothLowEnergyEventRouter::ReadCharacteristicValue. | 300 // BluetoothLowEnergyEventRouter::ReadCharacteristicValue. |
| 224 void SuccessCallback(); | 301 void SuccessCallback(); |
| 225 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 302 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
| 226 | 303 |
| 227 // The instance ID of the requested characteristic. | 304 // The instance ID of the requested characteristic. |
| 228 std::string instance_id_; | 305 std::string instance_id_; |
| 229 }; | 306 }; |
| 230 | 307 |
| 231 class BluetoothLowEnergyWriteCharacteristicValueFunction | 308 class BluetoothLowEnergyWriteCharacteristicValueFunction |
| 232 : public BluetoothLowEnergyExtensionFunction { | 309 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 233 public: | 310 public: |
| 234 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeCharacteristicValue", | 311 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeCharacteristicValue", |
| 235 BLUETOOTHLOWENERGY_WRITECHARACTERISTICVALUE); | 312 BLUETOOTHLOWENERGY_WRITECHARACTERISTICVALUE); |
| 236 | 313 |
| 237 protected: | 314 protected: |
| 238 ~BluetoothLowEnergyWriteCharacteristicValueFunction() override {} | 315 ~BluetoothLowEnergyWriteCharacteristicValueFunction() override {} |
| 239 | 316 |
| 240 // BluetoothLowEnergyExtensionFunction override. | 317 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 241 bool DoWork() override; | 318 bool DoWork() override; |
| 242 | 319 |
| 243 private: | 320 private: |
| 244 // Success and error callbacks, called by | 321 // Success and error callbacks, called by |
| 245 // BluetoothLowEnergyEventRouter::WriteCharacteristicValue. | 322 // BluetoothLowEnergyEventRouter::WriteCharacteristicValue. |
| 246 void SuccessCallback(); | 323 void SuccessCallback(); |
| 247 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 324 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
| 248 | 325 |
| 249 // The instance ID of the requested characteristic. | 326 // The instance ID of the requested characteristic. |
| 250 std::string instance_id_; | 327 std::string instance_id_; |
| 251 }; | 328 }; |
| 252 | 329 |
| 253 class BluetoothLowEnergyStartCharacteristicNotificationsFunction | 330 class BluetoothLowEnergyStartCharacteristicNotificationsFunction |
| 254 : public BluetoothLowEnergyExtensionFunction { | 331 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 255 public: | 332 public: |
| 256 DECLARE_EXTENSION_FUNCTION( | 333 DECLARE_EXTENSION_FUNCTION( |
| 257 "bluetoothLowEnergy.startCharacteristicNotifications", | 334 "bluetoothLowEnergy.startCharacteristicNotifications", |
| 258 BLUETOOTHLOWENERGY_STARTCHARACTERISTICNOTIFICATIONS); | 335 BLUETOOTHLOWENERGY_STARTCHARACTERISTICNOTIFICATIONS); |
| 259 | 336 |
| 260 protected: | 337 protected: |
| 261 ~BluetoothLowEnergyStartCharacteristicNotificationsFunction() override {} | 338 ~BluetoothLowEnergyStartCharacteristicNotificationsFunction() override {} |
| 262 | 339 |
| 263 // BluetoothLowEnergyExtensionFunction override. | 340 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 264 bool DoWork() override; | 341 bool DoWork() override; |
| 265 | 342 |
| 266 private: | 343 private: |
| 267 // Success and error callbacks, called by | 344 // Success and error callbacks, called by |
| 268 // BluetoothLowEnergyEventRouter::StartCharacteristicNotifications. | 345 // BluetoothLowEnergyEventRouter::StartCharacteristicNotifications. |
| 269 void SuccessCallback(); | 346 void SuccessCallback(); |
| 270 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 347 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
| 271 }; | 348 }; |
| 272 | 349 |
| 273 class BluetoothLowEnergyStopCharacteristicNotificationsFunction | 350 class BluetoothLowEnergyStopCharacteristicNotificationsFunction |
| 274 : public BluetoothLowEnergyExtensionFunction { | 351 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 275 public: | 352 public: |
| 276 DECLARE_EXTENSION_FUNCTION( | 353 DECLARE_EXTENSION_FUNCTION( |
| 277 "bluetoothLowEnergy.stopCharacteristicNotifications", | 354 "bluetoothLowEnergy.stopCharacteristicNotifications", |
| 278 BLUETOOTHLOWENERGY_STOPCHARACTERISTICNOTIFICATIONS); | 355 BLUETOOTHLOWENERGY_STOPCHARACTERISTICNOTIFICATIONS); |
| 279 | 356 |
| 280 protected: | 357 protected: |
| 281 ~BluetoothLowEnergyStopCharacteristicNotificationsFunction() override {} | 358 ~BluetoothLowEnergyStopCharacteristicNotificationsFunction() override {} |
| 282 | 359 |
| 283 // BluetoothLowEnergyExtensionFunction override. | 360 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 284 bool DoWork() override; | 361 bool DoWork() override; |
| 285 | 362 |
| 286 private: | 363 private: |
| 287 // Success and error callbacks, called by | 364 // Success and error callbacks, called by |
| 288 // BluetoothLowEnergyEventRouter::StopCharacteristicNotifications. | 365 // BluetoothLowEnergyEventRouter::StopCharacteristicNotifications. |
| 289 void SuccessCallback(); | 366 void SuccessCallback(); |
| 290 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 367 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
| 291 }; | 368 }; |
| 292 | 369 |
| 293 class BluetoothLowEnergyReadDescriptorValueFunction | 370 class BluetoothLowEnergyReadDescriptorValueFunction |
| 294 : public BluetoothLowEnergyExtensionFunction { | 371 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 295 public: | 372 public: |
| 296 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readDescriptorValue", | 373 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readDescriptorValue", |
| 297 BLUETOOTHLOWENERGY_READDESCRIPTORVALUE); | 374 BLUETOOTHLOWENERGY_READDESCRIPTORVALUE); |
| 298 | 375 |
| 299 protected: | 376 protected: |
| 300 ~BluetoothLowEnergyReadDescriptorValueFunction() override {} | 377 ~BluetoothLowEnergyReadDescriptorValueFunction() override {} |
| 301 | 378 |
| 302 // BluetoothLowEnergyExtensionFunction override. | 379 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 303 bool DoWork() override; | 380 bool DoWork() override; |
| 304 | 381 |
| 305 private: | 382 private: |
| 306 // Success and error callbacks, called by | 383 // Success and error callbacks, called by |
| 307 // BluetoothLowEnergyEventRouter::ReadDescriptorValue. | 384 // BluetoothLowEnergyEventRouter::ReadDescriptorValue. |
| 308 void SuccessCallback(); | 385 void SuccessCallback(); |
| 309 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 386 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
| 310 | 387 |
| 311 // The instance ID of the requested descriptor. | 388 // The instance ID of the requested descriptor. |
| 312 std::string instance_id_; | 389 std::string instance_id_; |
| 313 }; | 390 }; |
| 314 | 391 |
| 315 class BluetoothLowEnergyWriteDescriptorValueFunction | 392 class BluetoothLowEnergyWriteDescriptorValueFunction |
| 316 : public BluetoothLowEnergyExtensionFunction { | 393 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 317 public: | 394 public: |
| 318 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeDescriptorValue", | 395 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeDescriptorValue", |
| 319 BLUETOOTHLOWENERGY_WRITEDESCRIPTORVALUE); | 396 BLUETOOTHLOWENERGY_WRITEDESCRIPTORVALUE); |
| 320 | 397 |
| 321 protected: | 398 protected: |
| 322 ~BluetoothLowEnergyWriteDescriptorValueFunction() override {} | 399 ~BluetoothLowEnergyWriteDescriptorValueFunction() override {} |
| 323 | 400 |
| 324 // BluetoothLowEnergyExtensionFunction override. | 401 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 325 bool DoWork() override; | 402 bool DoWork() override; |
| 326 | 403 |
| 327 private: | 404 private: |
| 328 // Success and error callbacks, called by | 405 // Success and error callbacks, called by |
| 329 // BluetoothLowEnergyEventRouter::WriteDescriptorValue. | 406 // BluetoothLowEnergyEventRouter::WriteDescriptorValue. |
| 330 void SuccessCallback(); | 407 void SuccessCallback(); |
| 331 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 408 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
| 332 | 409 |
| 333 // The instance ID of the requested descriptor. | 410 // The instance ID of the requested descriptor. |
| 334 std::string instance_id_; | 411 std::string instance_id_; |
| 335 }; | 412 }; |
| 336 | 413 |
| 337 class BluetoothLowEnergyAdvertisementFunction | 414 class BluetoothLowEnergyAdvertisementFunction |
| 338 : public BluetoothLowEnergyExtensionFunction { | 415 : public BluetoothLowEnergyExtensionFunctionDeprecated { |
| 339 public: | 416 public: |
| 340 BluetoothLowEnergyAdvertisementFunction(); | 417 BluetoothLowEnergyAdvertisementFunction(); |
| 341 | 418 |
| 342 protected: | 419 protected: |
| 343 ~BluetoothLowEnergyAdvertisementFunction() override; | 420 ~BluetoothLowEnergyAdvertisementFunction() override; |
| 344 | 421 |
| 345 // Takes ownership. | 422 // Takes ownership. |
| 346 int AddAdvertisement(BluetoothApiAdvertisement* advertisement); | 423 int AddAdvertisement(BluetoothApiAdvertisement* advertisement); |
| 347 BluetoothApiAdvertisement* GetAdvertisement(int advertisement_id); | 424 BluetoothApiAdvertisement* GetAdvertisement(int advertisement_id); |
| 348 void RemoveAdvertisement(int advertisement_id); | 425 void RemoveAdvertisement(int advertisement_id); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 360 | 437 |
| 361 class BluetoothLowEnergyRegisterAdvertisementFunction | 438 class BluetoothLowEnergyRegisterAdvertisementFunction |
| 362 : public BluetoothLowEnergyAdvertisementFunction { | 439 : public BluetoothLowEnergyAdvertisementFunction { |
| 363 public: | 440 public: |
| 364 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerAdvertisement", | 441 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerAdvertisement", |
| 365 BLUETOOTHLOWENERGY_REGISTERADVERTISEMENT); | 442 BLUETOOTHLOWENERGY_REGISTERADVERTISEMENT); |
| 366 | 443 |
| 367 protected: | 444 protected: |
| 368 ~BluetoothLowEnergyRegisterAdvertisementFunction() override {} | 445 ~BluetoothLowEnergyRegisterAdvertisementFunction() override {} |
| 369 | 446 |
| 370 // BluetoothLowEnergyExtensionFunction override. | 447 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 371 bool DoWork() override; | 448 bool DoWork() override; |
| 372 | 449 |
| 373 private: | 450 private: |
| 374 void SuccessCallback(scoped_refptr<device::BluetoothAdvertisement>); | 451 void SuccessCallback(scoped_refptr<device::BluetoothAdvertisement>); |
| 375 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); | 452 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); |
| 376 | 453 |
| 377 // The instance ID of the requested descriptor. | 454 // The instance ID of the requested descriptor. |
| 378 std::string instance_id_; | 455 std::string instance_id_; |
| 379 }; | 456 }; |
| 380 | 457 |
| 381 class BluetoothLowEnergyUnregisterAdvertisementFunction | 458 class BluetoothLowEnergyUnregisterAdvertisementFunction |
| 382 : public BluetoothLowEnergyAdvertisementFunction { | 459 : public BluetoothLowEnergyAdvertisementFunction { |
| 383 public: | 460 public: |
| 384 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterAdvertisement", | 461 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterAdvertisement", |
| 385 BLUETOOTHLOWENERGY_UNREGISTERADVERTISEMENT); | 462 BLUETOOTHLOWENERGY_UNREGISTERADVERTISEMENT); |
| 386 | 463 |
| 387 protected: | 464 protected: |
| 388 ~BluetoothLowEnergyUnregisterAdvertisementFunction() override {} | 465 ~BluetoothLowEnergyUnregisterAdvertisementFunction() override {} |
| 389 | 466 |
| 390 // BluetoothLowEnergyExtensionFunction override. | 467 // BluetoothLowEnergyExtensionFunctionDeprecated override. |
| 391 bool DoWork() override; | 468 bool DoWork() override; |
| 392 | 469 |
| 393 private: | 470 private: |
| 394 void SuccessCallback(int advertisement_id); | 471 void SuccessCallback(int advertisement_id); |
| 395 void ErrorCallback(int advertisement_id, | 472 void ErrorCallback(int advertisement_id, |
| 396 device::BluetoothAdvertisement::ErrorCode status); | 473 device::BluetoothAdvertisement::ErrorCode status); |
| 397 | 474 |
| 398 // The instance ID of the requested descriptor. | 475 // The instance ID of the requested descriptor. |
| 399 std::string instance_id_; | 476 std::string instance_id_; |
| 400 }; | 477 }; |
| 401 | 478 |
| 479 class BluetoothLowEnergyCreateServiceFunction | |
| 480 : public BLEPeripheralExtensionFunction<apibtle::CreateService::Params> { | |
| 481 public: | |
| 482 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createService", | |
| 483 BLUETOOTHLOWENERGY_CREATESERVICE); | |
| 484 | |
| 485 protected: | |
| 486 ~BluetoothLowEnergyCreateServiceFunction() override {} | |
| 487 | |
| 488 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
| 489 void DoWork() override; | |
| 490 }; | |
| 491 | |
| 492 class BluetoothLowEnergyCreateCharacteristicFunction | |
| 493 : public BLEPeripheralExtensionFunction< | |
| 494 apibtle::CreateCharacteristic::Params> { | |
| 495 public: | |
| 496 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createCharacteristic", | |
| 497 BLUETOOTHLOWENERGY_CREATECHARACTERISTIC); | |
| 498 | |
| 499 protected: | |
| 500 ~BluetoothLowEnergyCreateCharacteristicFunction() override {} | |
| 501 | |
| 502 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
| 503 void DoWork() override; | |
| 504 }; | |
| 505 | |
| 506 class BluetoothLowEnergyCreateDescriptorFunction | |
| 507 : public BLEPeripheralExtensionFunction<apibtle::CreateDescriptor::Params> { | |
| 508 public: | |
| 509 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createDescriptor", | |
| 510 BLUETOOTHLOWENERGY_CREATEDESCRIPTOR); | |
| 511 | |
| 512 protected: | |
| 513 ~BluetoothLowEnergyCreateDescriptorFunction() override {} | |
| 514 | |
| 515 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
| 516 void DoWork() override; | |
| 517 }; | |
| 518 | |
| 519 class BluetoothLowEnergyRegisterServiceFunction | |
| 520 : public BLEPeripheralExtensionFunction<apibtle::RegisterService::Params> { | |
| 521 public: | |
| 522 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerService", | |
| 523 BLUETOOTHLOWENERGY_REGISTERSERVICE); | |
| 524 | |
| 525 protected: | |
| 526 ~BluetoothLowEnergyRegisterServiceFunction() override {} | |
| 527 | |
| 528 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
| 529 void DoWork() override; | |
| 530 }; | |
| 531 | |
| 532 class BluetoothLowEnergyUnregisterServiceFunction | |
| 533 : public BLEPeripheralExtensionFunction< | |
| 534 apibtle::UnregisterService::Params> { | |
| 535 public: | |
| 536 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterService", | |
| 537 BLUETOOTHLOWENERGY_UNREGISTERSERVICE); | |
| 538 | |
| 539 protected: | |
| 540 ~BluetoothLowEnergyUnregisterServiceFunction() override {} | |
| 541 | |
| 542 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
| 543 void DoWork() override; | |
| 544 }; | |
| 545 | |
| 546 class BluetoothLowEnergySendRequestResponseFunction | |
| 547 : public BLEPeripheralExtensionFunction< | |
| 548 apibtle::SendRequestResponse::Params> { | |
| 549 public: | |
| 550 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.sendRequestResponse", | |
| 551 BLUETOOTHLOWENERGY_SENDREQUESTRESPONSE); | |
| 552 | |
| 553 protected: | |
| 554 ~BluetoothLowEnergySendRequestResponseFunction() override {} | |
| 555 | |
| 556 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
| 557 void DoWork() override; | |
| 558 }; | |
| 559 | |
| 402 } // namespace api | 560 } // namespace api |
| 403 } // namespace extensions | 561 } // namespace extensions |
| 404 | 562 |
| 405 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENER GY_API_H_ | 563 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENER GY_API_H_ |
| OLD | NEW |