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 EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_API_H_ |
6 #define EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_API_H_ | 6 #define EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_API_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 std::unique_ptr<BluetoothLowEnergyEventRouter> event_router_; | 82 std::unique_ptr<BluetoothLowEnergyEventRouter> event_router_; |
83 | 83 |
84 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAPI); | 84 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAPI); |
85 }; | 85 }; |
86 | 86 |
87 namespace api { | 87 namespace api { |
88 | 88 |
89 // Base class for bluetoothLowEnergy API functions. This class handles some of | 89 // Base class for bluetoothLowEnergy API functions. This class handles some of |
90 // the common logic involved in all API functions, such as checking for | 90 // the common logic involved in all API functions, such as checking for |
91 // platform support and returning the correct error. | 91 // platform support and returning the correct error. |
92 // | |
93 // DEPRECATED: This inherits from AsyncExtensionFunction, which we're trying to | |
94 // get rid of for various reasons. Please inherit from the | |
95 // BluetoothLowEnergyExtensionFunction class instead. | |
96 class BluetoothLowEnergyExtensionFunctionDeprecated | |
97 : public AsyncExtensionFunction { | |
98 public: | |
99 BluetoothLowEnergyExtensionFunctionDeprecated(); | |
100 | |
101 protected: | |
102 ~BluetoothLowEnergyExtensionFunctionDeprecated() override; | |
103 | |
104 // AsyncExtensionFunction override. | |
105 bool RunAsync() override; | |
106 | |
107 // Implemented by individual bluetoothLowEnergy extension functions to perform | |
108 // the body of the function. This invoked asynchonously after RunAsync after | |
109 // the BluetoothLowEnergyEventRouter has obtained a handle on the | |
110 // BluetoothAdapter. | |
111 virtual bool DoWork() = 0; | |
112 | |
113 private: | |
114 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunctionDeprecated); | |
115 }; | |
116 | |
117 // Replacement for BluetoothLowEnergyExtensionFunctionDeprecated. Has the same | |
118 // functionality except that instead of the SendResponse/return combo, we'll | |
119 // return our response with Respond(). | |
120 class BluetoothLowEnergyExtensionFunction : public UIThreadExtensionFunction { | 92 class BluetoothLowEnergyExtensionFunction : public UIThreadExtensionFunction { |
121 public: | 93 public: |
122 BluetoothLowEnergyExtensionFunction(); | 94 BluetoothLowEnergyExtensionFunction(); |
123 | 95 |
124 protected: | 96 protected: |
125 ~BluetoothLowEnergyExtensionFunction() override; | 97 ~BluetoothLowEnergyExtensionFunction() override; |
126 | 98 |
127 // ExtensionFunction override. | 99 // ExtensionFunction override. |
128 ResponseAction Run() override; | 100 ResponseAction Run() override; |
129 | 101 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 std::unique_ptr<Params> params_; | 135 std::unique_ptr<Params> params_; |
164 #else | 136 #else |
165 Params* params_; | 137 Params* params_; |
166 #endif | 138 #endif |
167 | 139 |
168 private: | 140 private: |
169 DISALLOW_COPY_AND_ASSIGN(BLEPeripheralExtensionFunction); | 141 DISALLOW_COPY_AND_ASSIGN(BLEPeripheralExtensionFunction); |
170 }; | 142 }; |
171 | 143 |
172 class BluetoothLowEnergyConnectFunction | 144 class BluetoothLowEnergyConnectFunction |
173 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 145 : public BluetoothLowEnergyExtensionFunction { |
174 public: | 146 public: |
175 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.connect", | 147 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.connect", |
176 BLUETOOTHLOWENERGY_CONNECT); | 148 BLUETOOTHLOWENERGY_CONNECT); |
177 | 149 |
178 protected: | 150 protected: |
179 ~BluetoothLowEnergyConnectFunction() override {} | 151 ~BluetoothLowEnergyConnectFunction() override {} |
180 | 152 |
181 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 153 // BluetoothLowEnergyExtensionFunction override. |
182 bool DoWork() override; | 154 void DoWork() override; |
183 | 155 |
184 private: | 156 private: |
185 // Success and error callbacks, called by | 157 // Success and error callbacks, called by |
186 // BluetoothLowEnergyEventRouter::Connect. | 158 // BluetoothLowEnergyEventRouter::Connect. |
187 void SuccessCallback(); | 159 void SuccessCallback(); |
188 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 160 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
189 }; | 161 }; |
190 | 162 |
191 class BluetoothLowEnergyDisconnectFunction | 163 class BluetoothLowEnergyDisconnectFunction |
192 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 164 : public BluetoothLowEnergyExtensionFunction { |
193 public: | 165 public: |
194 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.disconnect", | 166 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.disconnect", |
195 BLUETOOTHLOWENERGY_DISCONNECT); | 167 BLUETOOTHLOWENERGY_DISCONNECT); |
196 | 168 |
197 protected: | 169 protected: |
198 ~BluetoothLowEnergyDisconnectFunction() override {} | 170 ~BluetoothLowEnergyDisconnectFunction() override {} |
199 | 171 |
200 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 172 // BluetoothLowEnergyExtensionFunction override. |
201 bool DoWork() override; | 173 void DoWork() override; |
202 | 174 |
203 private: | 175 private: |
204 // Success and error callbacks, called by | 176 // Success and error callbacks, called by |
205 // BluetoothLowEnergyEventRouter::Disconnect. | 177 // BluetoothLowEnergyEventRouter::Disconnect. |
206 void SuccessCallback(); | 178 void SuccessCallback(); |
207 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 179 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
208 }; | 180 }; |
209 | 181 |
210 class BluetoothLowEnergyGetServiceFunction | 182 class BluetoothLowEnergyGetServiceFunction |
211 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 183 : public BluetoothLowEnergyExtensionFunction { |
212 public: | 184 public: |
213 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getService", | 185 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getService", |
214 BLUETOOTHLOWENERGY_GETSERVICE); | 186 BLUETOOTHLOWENERGY_GETSERVICE); |
215 | 187 |
216 protected: | 188 protected: |
217 ~BluetoothLowEnergyGetServiceFunction() override {} | 189 ~BluetoothLowEnergyGetServiceFunction() override {} |
218 | 190 |
219 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 191 // BluetoothLowEnergyExtensionFunction override. |
220 bool DoWork() override; | 192 void DoWork() override; |
221 }; | 193 }; |
222 | 194 |
223 class BluetoothLowEnergyGetServicesFunction | 195 class BluetoothLowEnergyGetServicesFunction |
224 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 196 : public BluetoothLowEnergyExtensionFunction { |
225 public: | 197 public: |
226 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getServices", | 198 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getServices", |
227 BLUETOOTHLOWENERGY_GETSERVICES); | 199 BLUETOOTHLOWENERGY_GETSERVICES); |
228 | 200 |
229 protected: | 201 protected: |
230 ~BluetoothLowEnergyGetServicesFunction() override {} | 202 ~BluetoothLowEnergyGetServicesFunction() override {} |
231 | 203 |
232 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 204 // BluetoothLowEnergyExtensionFunction override. |
233 bool DoWork() override; | 205 void DoWork() override; |
234 }; | 206 }; |
235 | 207 |
236 class BluetoothLowEnergyGetCharacteristicFunction | 208 class BluetoothLowEnergyGetCharacteristicFunction |
237 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 209 : public BluetoothLowEnergyExtensionFunction { |
238 public: | 210 public: |
239 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristic", | 211 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristic", |
240 BLUETOOTHLOWENERGY_GETCHARACTERISTIC); | 212 BLUETOOTHLOWENERGY_GETCHARACTERISTIC); |
241 | 213 |
242 protected: | 214 protected: |
243 ~BluetoothLowEnergyGetCharacteristicFunction() override {} | 215 ~BluetoothLowEnergyGetCharacteristicFunction() override {} |
244 | 216 |
245 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 217 // BluetoothLowEnergyExtensionFunction override. |
246 bool DoWork() override; | 218 void DoWork() override; |
247 }; | 219 }; |
248 | 220 |
249 class BluetoothLowEnergyGetCharacteristicsFunction | 221 class BluetoothLowEnergyGetCharacteristicsFunction |
250 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 222 : public BluetoothLowEnergyExtensionFunction { |
251 public: | 223 public: |
252 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristics", | 224 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristics", |
253 BLUETOOTHLOWENERGY_GETCHARACTERISTICS); | 225 BLUETOOTHLOWENERGY_GETCHARACTERISTICS); |
254 | 226 |
255 protected: | 227 protected: |
256 ~BluetoothLowEnergyGetCharacteristicsFunction() override {} | 228 ~BluetoothLowEnergyGetCharacteristicsFunction() override {} |
257 | 229 |
258 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 230 // BluetoothLowEnergyExtensionFunction override. |
259 bool DoWork() override; | 231 void DoWork() override; |
260 }; | 232 }; |
261 | 233 |
262 class BluetoothLowEnergyGetIncludedServicesFunction | 234 class BluetoothLowEnergyGetIncludedServicesFunction |
263 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 235 : public BluetoothLowEnergyExtensionFunction { |
264 public: | 236 public: |
265 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getIncludedServices", | 237 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getIncludedServices", |
266 BLUETOOTHLOWENERGY_GETINCLUDEDSERVICES); | 238 BLUETOOTHLOWENERGY_GETINCLUDEDSERVICES); |
267 | 239 |
268 protected: | 240 protected: |
269 ~BluetoothLowEnergyGetIncludedServicesFunction() override {} | 241 ~BluetoothLowEnergyGetIncludedServicesFunction() override {} |
270 | 242 |
271 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 243 // BluetoothLowEnergyExtensionFunction override. |
272 bool DoWork() override; | 244 void DoWork() override; |
273 }; | 245 }; |
274 | 246 |
275 class BluetoothLowEnergyGetDescriptorFunction | 247 class BluetoothLowEnergyGetDescriptorFunction |
276 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 248 : public BluetoothLowEnergyExtensionFunction { |
277 public: | 249 public: |
278 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptor", | 250 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptor", |
279 BLUETOOTHLOWENERGY_GETDESCRIPTOR); | 251 BLUETOOTHLOWENERGY_GETDESCRIPTOR); |
280 | 252 |
281 protected: | 253 protected: |
282 ~BluetoothLowEnergyGetDescriptorFunction() override {} | 254 ~BluetoothLowEnergyGetDescriptorFunction() override {} |
283 | 255 |
284 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 256 // BluetoothLowEnergyExtensionFunction override. |
285 bool DoWork() override; | 257 void DoWork() override; |
286 }; | 258 }; |
287 | 259 |
288 class BluetoothLowEnergyGetDescriptorsFunction | 260 class BluetoothLowEnergyGetDescriptorsFunction |
289 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 261 : public BluetoothLowEnergyExtensionFunction { |
290 public: | 262 public: |
291 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptors", | 263 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptors", |
292 BLUETOOTHLOWENERGY_GETDESCRIPTORS); | 264 BLUETOOTHLOWENERGY_GETDESCRIPTORS); |
293 | 265 |
294 protected: | 266 protected: |
295 ~BluetoothLowEnergyGetDescriptorsFunction() override {} | 267 ~BluetoothLowEnergyGetDescriptorsFunction() override {} |
296 | 268 |
297 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 269 // BluetoothLowEnergyExtensionFunction override. |
298 bool DoWork() override; | 270 void DoWork() override; |
299 }; | 271 }; |
300 | 272 |
301 class BluetoothLowEnergyReadCharacteristicValueFunction | 273 class BluetoothLowEnergyReadCharacteristicValueFunction |
302 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 274 : public BluetoothLowEnergyExtensionFunction { |
303 public: | 275 public: |
304 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readCharacteristicValue", | 276 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readCharacteristicValue", |
305 BLUETOOTHLOWENERGY_READCHARACTERISTICVALUE); | 277 BLUETOOTHLOWENERGY_READCHARACTERISTICVALUE); |
306 | 278 |
307 protected: | 279 protected: |
308 ~BluetoothLowEnergyReadCharacteristicValueFunction() override {} | 280 ~BluetoothLowEnergyReadCharacteristicValueFunction() override {} |
309 | 281 |
310 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 282 // BluetoothLowEnergyExtensionFunction override. |
311 bool DoWork() override; | 283 void DoWork() override; |
312 | 284 |
313 private: | 285 private: |
314 // Success and error callbacks, called by | 286 // Success and error callbacks, called by |
315 // BluetoothLowEnergyEventRouter::ReadCharacteristicValue. | 287 // BluetoothLowEnergyEventRouter::ReadCharacteristicValue. |
316 void SuccessCallback(); | 288 void SuccessCallback(); |
317 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 289 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
318 | 290 |
319 // The instance ID of the requested characteristic. | 291 // The instance ID of the requested characteristic. |
320 std::string instance_id_; | 292 std::string instance_id_; |
321 }; | 293 }; |
322 | 294 |
323 class BluetoothLowEnergyWriteCharacteristicValueFunction | 295 class BluetoothLowEnergyWriteCharacteristicValueFunction |
324 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 296 : public BluetoothLowEnergyExtensionFunction { |
325 public: | 297 public: |
326 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeCharacteristicValue", | 298 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeCharacteristicValue", |
327 BLUETOOTHLOWENERGY_WRITECHARACTERISTICVALUE); | 299 BLUETOOTHLOWENERGY_WRITECHARACTERISTICVALUE); |
328 | 300 |
329 protected: | 301 protected: |
330 ~BluetoothLowEnergyWriteCharacteristicValueFunction() override {} | 302 ~BluetoothLowEnergyWriteCharacteristicValueFunction() override {} |
331 | 303 |
332 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 304 // BluetoothLowEnergyExtensionFunction override. |
333 bool DoWork() override; | 305 void DoWork() override; |
334 | 306 |
335 private: | 307 private: |
336 // Success and error callbacks, called by | 308 // Success and error callbacks, called by |
337 // BluetoothLowEnergyEventRouter::WriteCharacteristicValue. | 309 // BluetoothLowEnergyEventRouter::WriteCharacteristicValue. |
338 void SuccessCallback(); | 310 void SuccessCallback(); |
339 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 311 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
340 | 312 |
341 // The instance ID of the requested characteristic. | 313 // The instance ID of the requested characteristic. |
342 std::string instance_id_; | 314 std::string instance_id_; |
343 }; | 315 }; |
344 | 316 |
345 class BluetoothLowEnergyStartCharacteristicNotificationsFunction | 317 class BluetoothLowEnergyStartCharacteristicNotificationsFunction |
346 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 318 : public BluetoothLowEnergyExtensionFunction { |
347 public: | 319 public: |
348 DECLARE_EXTENSION_FUNCTION( | 320 DECLARE_EXTENSION_FUNCTION( |
349 "bluetoothLowEnergy.startCharacteristicNotifications", | 321 "bluetoothLowEnergy.startCharacteristicNotifications", |
350 BLUETOOTHLOWENERGY_STARTCHARACTERISTICNOTIFICATIONS); | 322 BLUETOOTHLOWENERGY_STARTCHARACTERISTICNOTIFICATIONS); |
351 | 323 |
352 protected: | 324 protected: |
353 ~BluetoothLowEnergyStartCharacteristicNotificationsFunction() override {} | 325 ~BluetoothLowEnergyStartCharacteristicNotificationsFunction() override {} |
354 | 326 |
355 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 327 // BluetoothLowEnergyExtensionFunction override. |
356 bool DoWork() override; | 328 void DoWork() override; |
357 | 329 |
358 private: | 330 private: |
359 // Success and error callbacks, called by | 331 // Success and error callbacks, called by |
360 // BluetoothLowEnergyEventRouter::StartCharacteristicNotifications. | 332 // BluetoothLowEnergyEventRouter::StartCharacteristicNotifications. |
361 void SuccessCallback(); | 333 void SuccessCallback(); |
362 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 334 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
363 }; | 335 }; |
364 | 336 |
365 class BluetoothLowEnergyStopCharacteristicNotificationsFunction | 337 class BluetoothLowEnergyStopCharacteristicNotificationsFunction |
366 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 338 : public BluetoothLowEnergyExtensionFunction { |
367 public: | 339 public: |
368 DECLARE_EXTENSION_FUNCTION( | 340 DECLARE_EXTENSION_FUNCTION( |
369 "bluetoothLowEnergy.stopCharacteristicNotifications", | 341 "bluetoothLowEnergy.stopCharacteristicNotifications", |
370 BLUETOOTHLOWENERGY_STOPCHARACTERISTICNOTIFICATIONS); | 342 BLUETOOTHLOWENERGY_STOPCHARACTERISTICNOTIFICATIONS); |
371 | 343 |
372 protected: | 344 protected: |
373 ~BluetoothLowEnergyStopCharacteristicNotificationsFunction() override {} | 345 ~BluetoothLowEnergyStopCharacteristicNotificationsFunction() override {} |
374 | 346 |
375 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 347 // BluetoothLowEnergyExtensionFunction override. |
376 bool DoWork() override; | 348 void DoWork() override; |
377 | 349 |
378 private: | 350 private: |
379 // Success and error callbacks, called by | 351 // Success and error callbacks, called by |
380 // BluetoothLowEnergyEventRouter::StopCharacteristicNotifications. | 352 // BluetoothLowEnergyEventRouter::StopCharacteristicNotifications. |
381 void SuccessCallback(); | 353 void SuccessCallback(); |
382 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 354 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
383 }; | 355 }; |
384 | 356 |
385 class BluetoothLowEnergyReadDescriptorValueFunction | 357 class BluetoothLowEnergyReadDescriptorValueFunction |
386 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 358 : public BluetoothLowEnergyExtensionFunction { |
387 public: | 359 public: |
388 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readDescriptorValue", | 360 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readDescriptorValue", |
389 BLUETOOTHLOWENERGY_READDESCRIPTORVALUE); | 361 BLUETOOTHLOWENERGY_READDESCRIPTORVALUE); |
390 | 362 |
391 protected: | 363 protected: |
392 ~BluetoothLowEnergyReadDescriptorValueFunction() override {} | 364 ~BluetoothLowEnergyReadDescriptorValueFunction() override {} |
393 | 365 |
394 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 366 // BluetoothLowEnergyExtensionFunction override. |
395 bool DoWork() override; | 367 void DoWork() override; |
396 | 368 |
397 private: | 369 private: |
398 // Success and error callbacks, called by | 370 // Success and error callbacks, called by |
399 // BluetoothLowEnergyEventRouter::ReadDescriptorValue. | 371 // BluetoothLowEnergyEventRouter::ReadDescriptorValue. |
400 void SuccessCallback(); | 372 void SuccessCallback(); |
401 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 373 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
402 | 374 |
403 // The instance ID of the requested descriptor. | 375 // The instance ID of the requested descriptor. |
404 std::string instance_id_; | 376 std::string instance_id_; |
405 }; | 377 }; |
406 | 378 |
407 class BluetoothLowEnergyWriteDescriptorValueFunction | 379 class BluetoothLowEnergyWriteDescriptorValueFunction |
408 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 380 : public BluetoothLowEnergyExtensionFunction { |
409 public: | 381 public: |
410 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeDescriptorValue", | 382 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeDescriptorValue", |
411 BLUETOOTHLOWENERGY_WRITEDESCRIPTORVALUE); | 383 BLUETOOTHLOWENERGY_WRITEDESCRIPTORVALUE); |
412 | 384 |
413 protected: | 385 protected: |
414 ~BluetoothLowEnergyWriteDescriptorValueFunction() override {} | 386 ~BluetoothLowEnergyWriteDescriptorValueFunction() override {} |
415 | 387 |
416 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 388 // BluetoothLowEnergyExtensionFunction override. |
417 bool DoWork() override; | 389 void DoWork() override; |
418 | 390 |
419 private: | 391 private: |
420 // Success and error callbacks, called by | 392 // Success and error callbacks, called by |
421 // BluetoothLowEnergyEventRouter::WriteDescriptorValue. | 393 // BluetoothLowEnergyEventRouter::WriteDescriptorValue. |
422 void SuccessCallback(); | 394 void SuccessCallback(); |
423 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | 395 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); |
424 | 396 |
425 // The instance ID of the requested descriptor. | 397 // The instance ID of the requested descriptor. |
426 std::string instance_id_; | 398 std::string instance_id_; |
427 }; | 399 }; |
428 | 400 |
429 class BluetoothLowEnergyAdvertisementFunction | 401 class BluetoothLowEnergyAdvertisementFunction |
430 : public BluetoothLowEnergyExtensionFunctionDeprecated { | 402 : public BluetoothLowEnergyExtensionFunction { |
431 public: | 403 public: |
432 BluetoothLowEnergyAdvertisementFunction(); | 404 BluetoothLowEnergyAdvertisementFunction(); |
433 | 405 |
434 protected: | 406 protected: |
435 ~BluetoothLowEnergyAdvertisementFunction() override; | 407 ~BluetoothLowEnergyAdvertisementFunction() override; |
436 | 408 |
437 // Takes ownership. | 409 // Takes ownership. |
438 int AddAdvertisement(BluetoothApiAdvertisement* advertisement); | 410 int AddAdvertisement(BluetoothApiAdvertisement* advertisement); |
439 BluetoothApiAdvertisement* GetAdvertisement(int advertisement_id); | 411 BluetoothApiAdvertisement* GetAdvertisement(int advertisement_id); |
440 void RemoveAdvertisement(int advertisement_id); | 412 void RemoveAdvertisement(int advertisement_id); |
441 const base::hash_set<int>* GetAdvertisementIds(); | 413 const base::hash_set<int>* GetAdvertisementIds(); |
442 | 414 |
443 // ExtensionFunction override. | 415 // ExtensionFunction override. |
444 bool RunAsync() override; | 416 ResponseAction Run() override; |
445 | 417 |
446 private: | 418 private: |
447 void Initialize(); | 419 void Initialize(); |
448 | 420 |
449 ApiResourceManager<BluetoothApiAdvertisement>* advertisements_manager_; | 421 ApiResourceManager<BluetoothApiAdvertisement>* advertisements_manager_; |
450 | 422 |
451 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAdvertisementFunction); | 423 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAdvertisementFunction); |
452 }; | 424 }; |
453 | 425 |
454 class BluetoothLowEnergyRegisterAdvertisementFunction | 426 class BluetoothLowEnergyRegisterAdvertisementFunction |
455 : public BluetoothLowEnergyAdvertisementFunction { | 427 : public BluetoothLowEnergyAdvertisementFunction { |
456 public: | 428 public: |
457 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerAdvertisement", | 429 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerAdvertisement", |
458 BLUETOOTHLOWENERGY_REGISTERADVERTISEMENT); | 430 BLUETOOTHLOWENERGY_REGISTERADVERTISEMENT); |
459 | 431 |
460 protected: | 432 protected: |
461 ~BluetoothLowEnergyRegisterAdvertisementFunction() override {} | 433 ~BluetoothLowEnergyRegisterAdvertisementFunction() override {} |
462 | 434 |
463 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 435 // BluetoothLowEnergyExtensionFunction override. |
464 bool DoWork() override; | 436 void DoWork() override; |
465 | 437 |
466 private: | 438 private: |
467 void SuccessCallback(scoped_refptr<device::BluetoothAdvertisement>); | 439 void SuccessCallback(scoped_refptr<device::BluetoothAdvertisement>); |
468 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); | 440 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); |
469 }; | 441 }; |
470 | 442 |
471 class BluetoothLowEnergyUnregisterAdvertisementFunction | 443 class BluetoothLowEnergyUnregisterAdvertisementFunction |
472 : public BluetoothLowEnergyAdvertisementFunction { | 444 : public BluetoothLowEnergyAdvertisementFunction { |
473 public: | 445 public: |
474 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterAdvertisement", | 446 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterAdvertisement", |
475 BLUETOOTHLOWENERGY_UNREGISTERADVERTISEMENT); | 447 BLUETOOTHLOWENERGY_UNREGISTERADVERTISEMENT); |
476 | 448 |
477 protected: | 449 protected: |
478 ~BluetoothLowEnergyUnregisterAdvertisementFunction() override {} | 450 ~BluetoothLowEnergyUnregisterAdvertisementFunction() override {} |
479 | 451 |
480 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 452 // BluetoothLowEnergyExtensionFunction override. |
481 bool DoWork() override; | 453 void DoWork() override; |
482 | 454 |
483 private: | 455 private: |
484 void SuccessCallback(int advertisement_id); | 456 void SuccessCallback(int advertisement_id); |
485 void ErrorCallback(int advertisement_id, | 457 void ErrorCallback(int advertisement_id, |
486 device::BluetoothAdvertisement::ErrorCode status); | 458 device::BluetoothAdvertisement::ErrorCode status); |
487 }; | 459 }; |
488 | 460 |
489 class BluetoothLowEnergyResetAdvertisingFunction | 461 class BluetoothLowEnergyResetAdvertisingFunction |
490 : public BluetoothLowEnergyAdvertisementFunction { | 462 : public BluetoothLowEnergyAdvertisementFunction { |
491 public: | 463 public: |
492 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.resetAdvertising", | 464 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.resetAdvertising", |
493 BLUETOOTHLOWENERGY_RESETADVERTISING); | 465 BLUETOOTHLOWENERGY_RESETADVERTISING); |
494 | 466 |
495 protected: | 467 protected: |
496 ~BluetoothLowEnergyResetAdvertisingFunction() override {} | 468 ~BluetoothLowEnergyResetAdvertisingFunction() override {} |
497 | 469 |
498 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 470 // BluetoothLowEnergyExtensionFunction override. |
499 bool DoWork() override; | 471 void DoWork() override; |
500 | 472 |
501 private: | 473 private: |
502 void SuccessCallback(); | 474 void SuccessCallback(); |
503 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); | 475 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); |
504 }; | 476 }; |
505 | 477 |
506 class BluetoothLowEnergySetAdvertisingIntervalFunction | 478 class BluetoothLowEnergySetAdvertisingIntervalFunction |
507 : public BLEPeripheralExtensionFunction< | 479 : public BLEPeripheralExtensionFunction< |
508 extensions::api::bluetooth_low_energy::SetAdvertisingInterval:: | 480 extensions::api::bluetooth_low_energy::SetAdvertisingInterval:: |
509 Params> { | 481 Params> { |
510 public: | 482 public: |
511 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.setAdvertisingInterval", | 483 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.setAdvertisingInterval", |
512 BLUETOOTHLOWENERGY_SETADVERTISINGINTERVAL); | 484 BLUETOOTHLOWENERGY_SETADVERTISINGINTERVAL); |
513 | 485 |
514 protected: | 486 protected: |
515 ~BluetoothLowEnergySetAdvertisingIntervalFunction() override {} | 487 ~BluetoothLowEnergySetAdvertisingIntervalFunction() override {} |
516 | 488 |
517 // BluetoothLowEnergyExtensionFunctionDeprecated override. | 489 // BluetoothLowEnergyExtensionFunction override. |
518 void DoWork() override; | 490 void DoWork() override; |
519 | 491 |
520 private: | 492 private: |
521 void SuccessCallback(); | 493 void SuccessCallback(); |
522 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); | 494 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); |
523 }; | 495 }; |
524 | 496 |
525 class BluetoothLowEnergyCreateServiceFunction | 497 class BluetoothLowEnergyCreateServiceFunction |
526 : public BLEPeripheralExtensionFunction< | 498 : public BLEPeripheralExtensionFunction< |
527 extensions::api::bluetooth_low_energy::CreateService::Params> { | 499 extensions::api::bluetooth_low_energy::CreateService::Params> { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 ~BluetoothLowEnergySendRequestResponseFunction() override {} | 615 ~BluetoothLowEnergySendRequestResponseFunction() override {} |
644 | 616 |
645 // BluetoothLowEnergyPeripheralExtensionFunction override. | 617 // BluetoothLowEnergyPeripheralExtensionFunction override. |
646 void DoWork() override; | 618 void DoWork() override; |
647 }; | 619 }; |
648 | 620 |
649 } // namespace api | 621 } // namespace api |
650 } // namespace extensions | 622 } // namespace extensions |
651 | 623 |
652 #endif // EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_API_
H_ | 624 #endif // EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_API_
H_ |
OLD | NEW |