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 WebBluetooth_h | 5 #ifndef WebBluetooth_h |
6 #define WebBluetooth_h | 6 #define WebBluetooth_h |
7 | 7 |
8 #include "public/platform/WebCallbacks.h" | 8 #include "public/platform/WebCallbacks.h" |
9 #include "public/platform/WebString.h" | 9 #include "public/platform/WebString.h" |
10 #include "public/platform/WebVector.h" | 10 #include "public/platform/WebVector.h" |
11 #include "public/platform/modules/bluetooth/WebBluetoothError.h" | 11 #include "public/platform/modules/bluetooth/WebBluetoothError.h" |
| 12 #include "public/platform/modules/bluetooth/web_bluetooth.mojom.h" |
12 | 13 |
13 #include <memory> | 14 #include <memory> |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 | 17 |
17 class WebBluetoothRemoteGATTCharacteristic; | 18 class WebBluetoothRemoteGATTCharacteristic; |
18 | 19 |
19 struct WebBluetoothDevice; | 20 struct WebBluetoothDevice; |
20 struct WebBluetoothRemoteGATTCharacteristicInit; | 21 struct WebBluetoothRemoteGATTCharacteristicInit; |
21 struct WebBluetoothRemoteGATTService; | 22 struct WebBluetoothRemoteGATTService; |
22 struct WebRequestDeviceOptions; | 23 struct WebRequestDeviceOptions; |
23 | 24 |
24 // Success and failure callbacks for requestDevice. | 25 // Success and failure callbacks for requestDevice. |
25 using WebBluetoothRequestDeviceCallbacks = WebCallbacks<std::unique_ptr<WebBluet
oothDevice>, const WebBluetoothError&>; | 26 using WebBluetoothRequestDeviceCallbacks = WebCallbacks<std::unique_ptr<WebBluet
oothDevice>, const WebBluetoothError&>; |
26 | 27 |
27 // Success and failure callbacks for connectGATT. | 28 // Success and failure callbacks for connectGATT. |
28 using WebBluetoothRemoteGATTServerConnectCallbacks = WebCallbacks<void, const We
bBluetoothError&>; | 29 using WebBluetoothRemoteGATTServerConnectCallbacks = WebCallbacks<void, const We
bBluetoothError&>; |
29 | 30 |
30 // Success and failure callbacks for getPrimaryService. | 31 // Success and failure callbacks for getPrimaryService. |
31 using WebBluetoothGetPrimaryServiceCallbacks = WebCallbacks<std::unique_ptr<WebB
luetoothRemoteGATTService>, const WebBluetoothError&>; | 32 using WebBluetoothGetPrimaryServiceCallbacks = WebCallbacks<std::unique_ptr<WebB
luetoothRemoteGATTService>, const WebBluetoothError&>; |
32 | 33 |
33 // Success and failure callbacks for getCharacteristic. | 34 // Success and failure callbacks for getCharacteristic(s). |
34 using WebBluetoothGetCharacteristicCallbacks = WebCallbacks<std::unique_ptr<WebB
luetoothRemoteGATTCharacteristicInit>, const WebBluetoothError&>; | 35 using WebBluetoothGetCharacteristicsCallbacks = WebCallbacks<const WebVector<Web
BluetoothRemoteGATTCharacteristicInit*>&, const WebBluetoothError&>; |
35 | |
36 // Success and failure callbacks for getCharacteristics. | |
37 using WebBluetoothGetCharacteristicsCallbacks = WebCallbacks<std::unique_ptr<Web
Vector<WebBluetoothRemoteGATTCharacteristicInit*>>, const WebBluetoothError&>; | |
38 | 36 |
39 // Success and failure callbacks for readValue. | 37 // Success and failure callbacks for readValue. |
40 using WebBluetoothReadValueCallbacks = WebCallbacks<const WebVector<uint8_t>&, c
onst WebBluetoothError&>; | 38 using WebBluetoothReadValueCallbacks = WebCallbacks<const WebVector<uint8_t>&, c
onst WebBluetoothError&>; |
41 | 39 |
42 // Success and failure callbacks for writeValue. | 40 // Success and failure callbacks for writeValue. |
43 using WebBluetoothWriteValueCallbacks = WebCallbacks<const WebVector<uint8_t>&,
const WebBluetoothError&>; | 41 using WebBluetoothWriteValueCallbacks = WebCallbacks<const WebVector<uint8_t>&,
const WebBluetoothError&>; |
44 | 42 |
45 // Success and failure callbacks for characteristic.startNotifications and | 43 // Success and failure callbacks for characteristic.startNotifications and |
46 // characteristic.stopNotifications. | 44 // characteristic.stopNotifications. |
47 using WebBluetoothNotificationsCallbacks = WebCallbacks<void, const WebBluetooth
Error&>; | 45 using WebBluetoothNotificationsCallbacks = WebCallbacks<void, const WebBluetooth
Error&>; |
(...skipping 14 matching lines...) Expand all Loading... |
62 virtual void connect(const WebString& deviceId, | 60 virtual void connect(const WebString& deviceId, |
63 WebBluetoothRemoteGATTServerConnectCallbacks*) { } | 61 WebBluetoothRemoteGATTServerConnectCallbacks*) { } |
64 virtual void disconnect(const WebString& deviceId) = 0; | 62 virtual void disconnect(const WebString& deviceId) = 0; |
65 virtual void getPrimaryService(const WebString& deviceId, | 63 virtual void getPrimaryService(const WebString& deviceId, |
66 const WebString& serviceUUID, | 64 const WebString& serviceUUID, |
67 WebBluetoothGetPrimaryServiceCallbacks*) { } | 65 WebBluetoothGetPrimaryServiceCallbacks*) { } |
68 // virtual void getPrimaryServices() { } | 66 // virtual void getPrimaryServices() { } |
69 | 67 |
70 // BluetoothRemoteGATTService methods: | 68 // BluetoothRemoteGATTService methods: |
71 // See https://webbluetoothchrome.github.io/web-bluetooth/#idl-def-bluetooth
gattservice | 69 // See https://webbluetoothchrome.github.io/web-bluetooth/#idl-def-bluetooth
gattservice |
72 virtual void getCharacteristic(const WebString& serviceInstanceID, | |
73 const WebString& characteristicUUID, | |
74 WebBluetoothGetCharacteristicCallbacks*) { } | |
75 virtual void getCharacteristics(const WebString& serviceInstanceID, | 70 virtual void getCharacteristics(const WebString& serviceInstanceID, |
| 71 mojom::WebBluetoothQueryType, |
76 const WebString& characteristicsUUID, | 72 const WebString& characteristicsUUID, |
77 WebBluetoothGetCharacteristicsCallbacks*) = 0; | 73 WebBluetoothGetCharacteristicsCallbacks*) = 0; |
78 | 74 |
79 // BluetoothRemoteGATTCharacteristic methods: | 75 // BluetoothRemoteGATTCharacteristic methods: |
80 // See https://webbluetoothchrome.github.io/web-bluetooth/#bluetoothgattchar
acteristic | 76 // See https://webbluetoothchrome.github.io/web-bluetooth/#bluetoothgattchar
acteristic |
81 virtual void readValue(const WebString& characteristicInstanceID, | 77 virtual void readValue(const WebString& characteristicInstanceID, |
82 WebBluetoothReadValueCallbacks*) { } | 78 WebBluetoothReadValueCallbacks*) { } |
83 virtual void writeValue(const WebString& characteristicInstanceID, | 79 virtual void writeValue(const WebString& characteristicInstanceID, |
84 const WebVector<uint8_t>& value, | 80 const WebVector<uint8_t>& value, |
85 WebBluetoothWriteValueCallbacks*) {} | 81 WebBluetoothWriteValueCallbacks*) {} |
86 virtual void startNotifications(const WebString& characteristicInstanceID, | 82 virtual void startNotifications(const WebString& characteristicInstanceID, |
87 WebBluetoothNotificationsCallbacks*) {} | 83 WebBluetoothNotificationsCallbacks*) {} |
88 virtual void stopNotifications(const WebString& characteristicInstanceID, | 84 virtual void stopNotifications(const WebString& characteristicInstanceID, |
89 WebBluetoothNotificationsCallbacks*) {} | 85 WebBluetoothNotificationsCallbacks*) {} |
90 | 86 |
91 // Called when addEventListener is called on a characteristic. | 87 // Called when addEventListener is called on a characteristic. |
92 virtual void registerCharacteristicObject( | 88 virtual void registerCharacteristicObject( |
93 const WebString& characteristicInstanceID, | 89 const WebString& characteristicInstanceID, |
94 WebBluetoothRemoteGATTCharacteristic*) = 0; | 90 WebBluetoothRemoteGATTCharacteristic*) = 0; |
95 virtual void characteristicObjectRemoved( | 91 virtual void characteristicObjectRemoved( |
96 const WebString& characteristicInstanceID, | 92 const WebString& characteristicInstanceID, |
97 WebBluetoothRemoteGATTCharacteristic*) {} | 93 WebBluetoothRemoteGATTCharacteristic*) {} |
98 }; | 94 }; |
99 | 95 |
100 } // namespace blink | 96 } // namespace blink |
101 | 97 |
102 #endif // WebBluetooth_h | 98 #endif // WebBluetooth_h |
OLD | NEW |