OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
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_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/macros.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_api_adver
tisement.h" | |
14 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ
y_event_router.h" | |
15 #include "content/public/browser/browser_context.h" | |
16 #include "device/bluetooth/bluetooth_advertisement.h" | |
17 #include "extensions/browser/api/api_resource_manager.h" | |
18 #include "extensions/browser/browser_context_keyed_api_factory.h" | |
19 #include "extensions/browser/extension_function.h" | |
20 #include "extensions/browser/extension_function_histogram_value.h" | |
21 | |
22 namespace extensions { | |
23 class BluetoothApiAdvertisement; | |
24 class BluetoothLowEnergyEventRouter; | |
25 | |
26 namespace api { | |
27 namespace bluetooth_low_energy { | |
28 namespace CreateService { | |
29 struct Params; | |
30 } | |
31 namespace CreateCharacteristic { | |
32 struct Params; | |
33 } | |
34 namespace CreateDescriptor { | |
35 struct Params; | |
36 } | |
37 namespace RegisterService { | |
38 struct Params; | |
39 } | |
40 namespace UnregisterService { | |
41 struct Params; | |
42 } | |
43 namespace NotifyCharacteristicValueChanged { | |
44 struct Params; | |
45 } | |
46 namespace RemoveService { | |
47 struct Params; | |
48 } | |
49 namespace SendRequestResponse { | |
50 struct Params; | |
51 } | |
52 } // namespace bluetooth_low_energy | |
53 } // namespace api | |
54 | |
55 // The profile-keyed service that manages the bluetoothLowEnergy extension API. | |
56 class BluetoothLowEnergyAPI : public BrowserContextKeyedAPI { | |
57 public: | |
58 static BrowserContextKeyedAPIFactory<BluetoothLowEnergyAPI>* | |
59 GetFactoryInstance(); | |
60 | |
61 // Convenience method to get the BluetoothLowEnergy API for a browser context. | |
62 static BluetoothLowEnergyAPI* Get(content::BrowserContext* context); | |
63 | |
64 explicit BluetoothLowEnergyAPI(content::BrowserContext* context); | |
65 ~BluetoothLowEnergyAPI() override; | |
66 | |
67 // KeyedService implementation.. | |
68 void Shutdown() override; | |
69 | |
70 BluetoothLowEnergyEventRouter* event_router() const { | |
71 return event_router_.get(); | |
72 } | |
73 | |
74 // BrowserContextKeyedAPI implementation. | |
75 static const char* service_name() { return "BluetoothLowEnergyAPI"; } | |
76 static const bool kServiceRedirectedInIncognito = true; | |
77 static const bool kServiceIsNULLWhileTesting = true; | |
78 | |
79 private: | |
80 friend class BrowserContextKeyedAPIFactory<BluetoothLowEnergyAPI>; | |
81 | |
82 std::unique_ptr<BluetoothLowEnergyEventRouter> event_router_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAPI); | |
85 }; | |
86 | |
87 namespace api { | |
88 | |
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 | |
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 { | |
121 public: | |
122 BluetoothLowEnergyExtensionFunction(); | |
123 | |
124 protected: | |
125 ~BluetoothLowEnergyExtensionFunction() override; | |
126 | |
127 // ExtensionFunction override. | |
128 ResponseAction Run() override; | |
129 | |
130 // Implemented by individual bluetoothLowEnergy extension functions to perform | |
131 // the body of the function. This invoked asynchonously after Run after | |
132 // the BluetoothLowEnergyEventRouter has obtained a handle on the | |
133 // BluetoothAdapter. | |
134 virtual void DoWork() = 0; | |
135 | |
136 BluetoothLowEnergyEventRouter* event_router_; | |
137 | |
138 private: | |
139 // Internal method to do common setup before actual DoWork is called. | |
140 void PreDoWork(); | |
141 | |
142 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyExtensionFunction); | |
143 }; | |
144 | |
145 // Base class for bluetoothLowEnergy API peripheral mode functions. This class | |
146 // handles some of the common logic involved in all API peripheral mode | |
147 // functions, such as checking for peripheral permissions and returning the | |
148 // correct error. | |
149 template <typename Params> | |
150 class BLEPeripheralExtensionFunction | |
151 : public BluetoothLowEnergyExtensionFunction { | |
152 public: | |
153 BLEPeripheralExtensionFunction(); | |
154 | |
155 protected: | |
156 ~BLEPeripheralExtensionFunction() override; | |
157 | |
158 // ExtensionFunction override. | |
159 ResponseAction Run() override; | |
160 | |
161 // Causes link error on Windows. API will never be on Windows, so #ifdefing. | |
162 #if !defined(OS_WIN) | |
163 std::unique_ptr<Params> params_; | |
164 #else | |
165 Params* params_; | |
166 #endif | |
167 | |
168 private: | |
169 DISALLOW_COPY_AND_ASSIGN(BLEPeripheralExtensionFunction); | |
170 }; | |
171 | |
172 class BluetoothLowEnergyConnectFunction | |
173 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
174 public: | |
175 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.connect", | |
176 BLUETOOTHLOWENERGY_CONNECT); | |
177 | |
178 protected: | |
179 ~BluetoothLowEnergyConnectFunction() override {} | |
180 | |
181 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
182 bool DoWork() override; | |
183 | |
184 private: | |
185 // Success and error callbacks, called by | |
186 // BluetoothLowEnergyEventRouter::Connect. | |
187 void SuccessCallback(); | |
188 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | |
189 }; | |
190 | |
191 class BluetoothLowEnergyDisconnectFunction | |
192 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
193 public: | |
194 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.disconnect", | |
195 BLUETOOTHLOWENERGY_DISCONNECT); | |
196 | |
197 protected: | |
198 ~BluetoothLowEnergyDisconnectFunction() override {} | |
199 | |
200 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
201 bool DoWork() override; | |
202 | |
203 private: | |
204 // Success and error callbacks, called by | |
205 // BluetoothLowEnergyEventRouter::Disconnect. | |
206 void SuccessCallback(); | |
207 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | |
208 }; | |
209 | |
210 class BluetoothLowEnergyGetServiceFunction | |
211 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
212 public: | |
213 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getService", | |
214 BLUETOOTHLOWENERGY_GETSERVICE); | |
215 | |
216 protected: | |
217 ~BluetoothLowEnergyGetServiceFunction() override {} | |
218 | |
219 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
220 bool DoWork() override; | |
221 }; | |
222 | |
223 class BluetoothLowEnergyGetServicesFunction | |
224 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
225 public: | |
226 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getServices", | |
227 BLUETOOTHLOWENERGY_GETSERVICES); | |
228 | |
229 protected: | |
230 ~BluetoothLowEnergyGetServicesFunction() override {} | |
231 | |
232 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
233 bool DoWork() override; | |
234 }; | |
235 | |
236 class BluetoothLowEnergyGetCharacteristicFunction | |
237 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
238 public: | |
239 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristic", | |
240 BLUETOOTHLOWENERGY_GETCHARACTERISTIC); | |
241 | |
242 protected: | |
243 ~BluetoothLowEnergyGetCharacteristicFunction() override {} | |
244 | |
245 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
246 bool DoWork() override; | |
247 }; | |
248 | |
249 class BluetoothLowEnergyGetCharacteristicsFunction | |
250 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
251 public: | |
252 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getCharacteristics", | |
253 BLUETOOTHLOWENERGY_GETCHARACTERISTICS); | |
254 | |
255 protected: | |
256 ~BluetoothLowEnergyGetCharacteristicsFunction() override {} | |
257 | |
258 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
259 bool DoWork() override; | |
260 }; | |
261 | |
262 class BluetoothLowEnergyGetIncludedServicesFunction | |
263 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
264 public: | |
265 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getIncludedServices", | |
266 BLUETOOTHLOWENERGY_GETINCLUDEDSERVICES); | |
267 | |
268 protected: | |
269 ~BluetoothLowEnergyGetIncludedServicesFunction() override {} | |
270 | |
271 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
272 bool DoWork() override; | |
273 }; | |
274 | |
275 class BluetoothLowEnergyGetDescriptorFunction | |
276 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
277 public: | |
278 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptor", | |
279 BLUETOOTHLOWENERGY_GETDESCRIPTOR); | |
280 | |
281 protected: | |
282 ~BluetoothLowEnergyGetDescriptorFunction() override {} | |
283 | |
284 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
285 bool DoWork() override; | |
286 }; | |
287 | |
288 class BluetoothLowEnergyGetDescriptorsFunction | |
289 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
290 public: | |
291 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.getDescriptors", | |
292 BLUETOOTHLOWENERGY_GETDESCRIPTORS); | |
293 | |
294 protected: | |
295 ~BluetoothLowEnergyGetDescriptorsFunction() override {} | |
296 | |
297 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
298 bool DoWork() override; | |
299 }; | |
300 | |
301 class BluetoothLowEnergyReadCharacteristicValueFunction | |
302 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
303 public: | |
304 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readCharacteristicValue", | |
305 BLUETOOTHLOWENERGY_READCHARACTERISTICVALUE); | |
306 | |
307 protected: | |
308 ~BluetoothLowEnergyReadCharacteristicValueFunction() override {} | |
309 | |
310 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
311 bool DoWork() override; | |
312 | |
313 private: | |
314 // Success and error callbacks, called by | |
315 // BluetoothLowEnergyEventRouter::ReadCharacteristicValue. | |
316 void SuccessCallback(); | |
317 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | |
318 | |
319 // The instance ID of the requested characteristic. | |
320 std::string instance_id_; | |
321 }; | |
322 | |
323 class BluetoothLowEnergyWriteCharacteristicValueFunction | |
324 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
325 public: | |
326 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeCharacteristicValue", | |
327 BLUETOOTHLOWENERGY_WRITECHARACTERISTICVALUE); | |
328 | |
329 protected: | |
330 ~BluetoothLowEnergyWriteCharacteristicValueFunction() override {} | |
331 | |
332 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
333 bool DoWork() override; | |
334 | |
335 private: | |
336 // Success and error callbacks, called by | |
337 // BluetoothLowEnergyEventRouter::WriteCharacteristicValue. | |
338 void SuccessCallback(); | |
339 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | |
340 | |
341 // The instance ID of the requested characteristic. | |
342 std::string instance_id_; | |
343 }; | |
344 | |
345 class BluetoothLowEnergyStartCharacteristicNotificationsFunction | |
346 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
347 public: | |
348 DECLARE_EXTENSION_FUNCTION( | |
349 "bluetoothLowEnergy.startCharacteristicNotifications", | |
350 BLUETOOTHLOWENERGY_STARTCHARACTERISTICNOTIFICATIONS); | |
351 | |
352 protected: | |
353 ~BluetoothLowEnergyStartCharacteristicNotificationsFunction() override {} | |
354 | |
355 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
356 bool DoWork() override; | |
357 | |
358 private: | |
359 // Success and error callbacks, called by | |
360 // BluetoothLowEnergyEventRouter::StartCharacteristicNotifications. | |
361 void SuccessCallback(); | |
362 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | |
363 }; | |
364 | |
365 class BluetoothLowEnergyStopCharacteristicNotificationsFunction | |
366 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
367 public: | |
368 DECLARE_EXTENSION_FUNCTION( | |
369 "bluetoothLowEnergy.stopCharacteristicNotifications", | |
370 BLUETOOTHLOWENERGY_STOPCHARACTERISTICNOTIFICATIONS); | |
371 | |
372 protected: | |
373 ~BluetoothLowEnergyStopCharacteristicNotificationsFunction() override {} | |
374 | |
375 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
376 bool DoWork() override; | |
377 | |
378 private: | |
379 // Success and error callbacks, called by | |
380 // BluetoothLowEnergyEventRouter::StopCharacteristicNotifications. | |
381 void SuccessCallback(); | |
382 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | |
383 }; | |
384 | |
385 class BluetoothLowEnergyReadDescriptorValueFunction | |
386 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
387 public: | |
388 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.readDescriptorValue", | |
389 BLUETOOTHLOWENERGY_READDESCRIPTORVALUE); | |
390 | |
391 protected: | |
392 ~BluetoothLowEnergyReadDescriptorValueFunction() override {} | |
393 | |
394 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
395 bool DoWork() override; | |
396 | |
397 private: | |
398 // Success and error callbacks, called by | |
399 // BluetoothLowEnergyEventRouter::ReadDescriptorValue. | |
400 void SuccessCallback(); | |
401 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | |
402 | |
403 // The instance ID of the requested descriptor. | |
404 std::string instance_id_; | |
405 }; | |
406 | |
407 class BluetoothLowEnergyWriteDescriptorValueFunction | |
408 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
409 public: | |
410 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.writeDescriptorValue", | |
411 BLUETOOTHLOWENERGY_WRITEDESCRIPTORVALUE); | |
412 | |
413 protected: | |
414 ~BluetoothLowEnergyWriteDescriptorValueFunction() override {} | |
415 | |
416 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
417 bool DoWork() override; | |
418 | |
419 private: | |
420 // Success and error callbacks, called by | |
421 // BluetoothLowEnergyEventRouter::WriteDescriptorValue. | |
422 void SuccessCallback(); | |
423 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | |
424 | |
425 // The instance ID of the requested descriptor. | |
426 std::string instance_id_; | |
427 }; | |
428 | |
429 class BluetoothLowEnergyAdvertisementFunction | |
430 : public BluetoothLowEnergyExtensionFunctionDeprecated { | |
431 public: | |
432 BluetoothLowEnergyAdvertisementFunction(); | |
433 | |
434 protected: | |
435 ~BluetoothLowEnergyAdvertisementFunction() override; | |
436 | |
437 // Takes ownership. | |
438 int AddAdvertisement(BluetoothApiAdvertisement* advertisement); | |
439 BluetoothApiAdvertisement* GetAdvertisement(int advertisement_id); | |
440 void RemoveAdvertisement(int advertisement_id); | |
441 | |
442 // ExtensionFunction override. | |
443 bool RunAsync() override; | |
444 | |
445 private: | |
446 void Initialize(); | |
447 | |
448 ApiResourceManager<BluetoothApiAdvertisement>* advertisements_manager_; | |
449 | |
450 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyAdvertisementFunction); | |
451 }; | |
452 | |
453 class BluetoothLowEnergyRegisterAdvertisementFunction | |
454 : public BluetoothLowEnergyAdvertisementFunction { | |
455 public: | |
456 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerAdvertisement", | |
457 BLUETOOTHLOWENERGY_REGISTERADVERTISEMENT); | |
458 | |
459 protected: | |
460 ~BluetoothLowEnergyRegisterAdvertisementFunction() override {} | |
461 | |
462 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
463 bool DoWork() override; | |
464 | |
465 private: | |
466 void SuccessCallback(scoped_refptr<device::BluetoothAdvertisement>); | |
467 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); | |
468 }; | |
469 | |
470 class BluetoothLowEnergyUnregisterAdvertisementFunction | |
471 : public BluetoothLowEnergyAdvertisementFunction { | |
472 public: | |
473 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterAdvertisement", | |
474 BLUETOOTHLOWENERGY_UNREGISTERADVERTISEMENT); | |
475 | |
476 protected: | |
477 ~BluetoothLowEnergyUnregisterAdvertisementFunction() override {} | |
478 | |
479 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
480 bool DoWork() override; | |
481 | |
482 private: | |
483 void SuccessCallback(int advertisement_id); | |
484 void ErrorCallback(int advertisement_id, | |
485 device::BluetoothAdvertisement::ErrorCode status); | |
486 }; | |
487 | |
488 class BluetoothLowEnergySetAdvertisingIntervalFunction | |
489 : public BLEPeripheralExtensionFunction< | |
490 extensions::api::bluetooth_low_energy::SetAdvertisingInterval:: | |
491 Params> { | |
492 public: | |
493 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.setAdvertisingInterval", | |
494 BLUETOOTHLOWENERGY_SETADVERTISINGINTERVAL); | |
495 | |
496 protected: | |
497 ~BluetoothLowEnergySetAdvertisingIntervalFunction() override {} | |
498 | |
499 // BluetoothLowEnergyExtensionFunctionDeprecated override. | |
500 void DoWork() override; | |
501 | |
502 private: | |
503 void SuccessCallback(); | |
504 void ErrorCallback(device::BluetoothAdvertisement::ErrorCode status); | |
505 }; | |
506 | |
507 class BluetoothLowEnergyCreateServiceFunction | |
508 : public BLEPeripheralExtensionFunction< | |
509 extensions::api::bluetooth_low_energy::CreateService::Params> { | |
510 public: | |
511 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createService", | |
512 BLUETOOTHLOWENERGY_CREATESERVICE); | |
513 | |
514 protected: | |
515 ~BluetoothLowEnergyCreateServiceFunction() override {} | |
516 | |
517 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
518 void DoWork() override; | |
519 }; | |
520 | |
521 class BluetoothLowEnergyCreateCharacteristicFunction | |
522 : public BLEPeripheralExtensionFunction< | |
523 extensions::api::bluetooth_low_energy::CreateCharacteristic::Params> { | |
524 public: | |
525 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createCharacteristic", | |
526 BLUETOOTHLOWENERGY_CREATECHARACTERISTIC); | |
527 | |
528 protected: | |
529 ~BluetoothLowEnergyCreateCharacteristicFunction() override {} | |
530 | |
531 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
532 void DoWork() override; | |
533 }; | |
534 | |
535 class BluetoothLowEnergyNotifyCharacteristicValueChangedFunction | |
536 : public BLEPeripheralExtensionFunction< | |
537 extensions::api::bluetooth_low_energy:: | |
538 NotifyCharacteristicValueChanged::Params> { | |
539 public: | |
540 DECLARE_EXTENSION_FUNCTION( | |
541 "bluetoothLowEnergy.notifyCharacteristicValueChanged", | |
542 BLUETOOTHLOWENERGY_NOTIFYCHARACTERISTICVALUECHANGED); | |
543 | |
544 protected: | |
545 ~BluetoothLowEnergyNotifyCharacteristicValueChangedFunction() override {} | |
546 | |
547 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
548 void DoWork() override; | |
549 }; | |
550 | |
551 class BluetoothLowEnergyCreateDescriptorFunction | |
552 : public BLEPeripheralExtensionFunction< | |
553 extensions::api::bluetooth_low_energy::CreateDescriptor::Params> { | |
554 public: | |
555 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.createDescriptor", | |
556 BLUETOOTHLOWENERGY_CREATEDESCRIPTOR); | |
557 | |
558 protected: | |
559 ~BluetoothLowEnergyCreateDescriptorFunction() override {} | |
560 | |
561 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
562 void DoWork() override; | |
563 }; | |
564 | |
565 class BluetoothLowEnergyRegisterServiceFunction | |
566 : public BLEPeripheralExtensionFunction< | |
567 extensions::api::bluetooth_low_energy::RegisterService::Params> { | |
568 public: | |
569 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.registerService", | |
570 BLUETOOTHLOWENERGY_REGISTERSERVICE); | |
571 | |
572 protected: | |
573 ~BluetoothLowEnergyRegisterServiceFunction() override {} | |
574 | |
575 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
576 void DoWork() override; | |
577 | |
578 private: | |
579 void SuccessCallback(); | |
580 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | |
581 }; | |
582 | |
583 class BluetoothLowEnergyUnregisterServiceFunction | |
584 : public BLEPeripheralExtensionFunction< | |
585 extensions::api::bluetooth_low_energy::UnregisterService::Params> { | |
586 public: | |
587 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.unregisterService", | |
588 BLUETOOTHLOWENERGY_UNREGISTERSERVICE); | |
589 | |
590 protected: | |
591 ~BluetoothLowEnergyUnregisterServiceFunction() override {} | |
592 | |
593 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
594 void DoWork() override; | |
595 | |
596 private: | |
597 // Success and error callbacks, called by | |
598 // BluetoothLowEnergyEventRouter::RegisterService. | |
599 void SuccessCallback(); | |
600 void ErrorCallback(BluetoothLowEnergyEventRouter::Status status); | |
601 }; | |
602 | |
603 class BluetoothLowEnergyRemoveServiceFunction | |
604 : public BLEPeripheralExtensionFunction< | |
605 extensions::api::bluetooth_low_energy::RemoveService::Params> { | |
606 public: | |
607 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.removeService", | |
608 BLUETOOTHLOWENERGY_REMOVESERVICE); | |
609 | |
610 protected: | |
611 ~BluetoothLowEnergyRemoveServiceFunction() override {} | |
612 | |
613 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
614 void DoWork() override; | |
615 }; | |
616 | |
617 class BluetoothLowEnergySendRequestResponseFunction | |
618 : public BLEPeripheralExtensionFunction< | |
619 extensions::api::bluetooth_low_energy::SendRequestResponse::Params> { | |
620 public: | |
621 DECLARE_EXTENSION_FUNCTION("bluetoothLowEnergy.sendRequestResponse", | |
622 BLUETOOTHLOWENERGY_SENDREQUESTRESPONSE); | |
623 | |
624 protected: | |
625 ~BluetoothLowEnergySendRequestResponseFunction() override {} | |
626 | |
627 // BluetoothLowEnergyPeripheralExtensionFunction override. | |
628 void DoWork() override; | |
629 }; | |
630 | |
631 } // namespace api | |
632 } // namespace extensions | |
633 | |
634 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENER
GY_API_H_ | |
OLD | NEW |