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 | 11 |
12 #include <memory> | 12 #include <memory> |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 class WebBluetoothDevice; | 16 class WebBluetoothDevice; |
17 class WebBluetoothRemoteGATTCharacteristic; | 17 class WebBluetoothRemoteGATTCharacteristic; |
18 | 18 |
19 struct WebBluetoothDeviceInit; | 19 struct WebBluetoothDeviceInit; |
20 struct WebBluetoothRemoteGATTCharacteristicInit; | 20 struct WebBluetoothRemoteGATTCharacteristicInit; |
21 struct WebBluetoothRemoteGATTDescriptorInit; | |
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< | 26 using WebBluetoothRequestDeviceCallbacks = WebCallbacks< |
26 std::unique_ptr<WebBluetoothDeviceInit>, | 27 std::unique_ptr<WebBluetoothDeviceInit>, |
27 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | 28 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; |
28 | 29 |
29 // Success and failure callbacks for GattServer.connect(). | 30 // Success and failure callbacks for GattServer.connect(). |
30 using WebBluetoothRemoteGATTServerConnectCallbacks = WebCallbacks< | 31 using WebBluetoothRemoteGATTServerConnectCallbacks = WebCallbacks< |
31 void, | 32 void, |
32 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | 33 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; |
33 | 34 |
34 // Success and failure callbacks for getPrimaryService(s). | 35 // Success and failure callbacks for getPrimaryService(s). |
35 using WebBluetoothGetPrimaryServicesCallbacks = WebCallbacks< | 36 using WebBluetoothGetPrimaryServicesCallbacks = WebCallbacks< |
36 const WebVector<WebBluetoothRemoteGATTService*>&, | 37 const WebVector<WebBluetoothRemoteGATTService*>&, |
37 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | 38 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; |
38 | 39 |
39 // Success and failure callbacks for getCharacteristic(s). | 40 // Success and failure callbacks for getCharacteristic(s). |
40 using WebBluetoothGetCharacteristicsCallbacks = WebCallbacks< | 41 using WebBluetoothGetCharacteristicsCallbacks = WebCallbacks< |
41 const WebVector<WebBluetoothRemoteGATTCharacteristicInit*>&, | 42 const WebVector<WebBluetoothRemoteGATTCharacteristicInit*>&, |
42 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | 43 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; |
43 | 44 |
45 // Success and failure callbacks for getDescriptor(s). | |
46 using WebBluetoothGetDescriptorsCallbacks = WebCallbacks< | |
47 const WebVector<WebBluetoothRemoteGATTDescriptorInit*>&, | |
48 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | |
49 | |
44 // Success and failure callbacks for readValue. | 50 // Success and failure callbacks for readValue. |
45 using WebBluetoothReadValueCallbacks = WebCallbacks< | 51 using WebBluetoothReadValueCallbacks = WebCallbacks< |
46 const WebVector<uint8_t>&, | 52 const WebVector<uint8_t>&, |
47 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | 53 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; |
48 | 54 |
49 // Success and failure callbacks for writeValue. | 55 // Success and failure callbacks for writeValue. |
50 using WebBluetoothWriteValueCallbacks = WebCallbacks< | 56 using WebBluetoothWriteValueCallbacks = WebCallbacks< |
51 const WebVector<uint8_t>&, | 57 const WebVector<uint8_t>&, |
52 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | 58 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; |
53 | 59 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 virtual void getCharacteristics( | 95 virtual void getCharacteristics( |
90 const WebString& serviceInstanceID, | 96 const WebString& serviceInstanceID, |
91 // Corresponds to WebBluetoothGATTQueryQuantity in web_bluetooth.mojom | 97 // Corresponds to WebBluetoothGATTQueryQuantity in web_bluetooth.mojom |
92 int32_t quantity, | 98 int32_t quantity, |
93 const WebString& characteristicsUUID, | 99 const WebString& characteristicsUUID, |
94 WebBluetoothGetCharacteristicsCallbacks*) = 0; | 100 WebBluetoothGetCharacteristicsCallbacks*) = 0; |
95 | 101 |
96 // BluetoothRemoteGATTCharacteristic methods: | 102 // BluetoothRemoteGATTCharacteristic methods: |
97 // See | 103 // See |
98 // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacte ristic | 104 // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacte ristic |
99 virtual void readValue(const WebString& characteristicInstanceID, | 105 virtual void characteristicReadValue( |
100 WebBluetoothReadValueCallbacks*) {} | 106 const WebString& characteristicInstanceID, |
101 virtual void writeValue(const WebString& characteristicInstanceID, | 107 WebBluetoothReadValueCallbacks*) {} |
102 const WebVector<uint8_t>& value, | 108 virtual void characteristicWriteValue( |
103 WebBluetoothWriteValueCallbacks*) {} | 109 const WebString& characteristicInstanceID, |
110 const WebVector<uint8_t>& value, | |
111 WebBluetoothWriteValueCallbacks*) {} | |
104 virtual void startNotifications(const WebString& characteristicInstanceID, | 112 virtual void startNotifications(const WebString& characteristicInstanceID, |
105 WebBluetoothNotificationsCallbacks*) {} | 113 WebBluetoothNotificationsCallbacks*) {} |
106 virtual void stopNotifications(const WebString& characteristicInstanceID, | 114 virtual void stopNotifications(const WebString& characteristicInstanceID, |
107 WebBluetoothNotificationsCallbacks*) {} | 115 WebBluetoothNotificationsCallbacks*) {} |
116 virtual void getDescriptors( | |
117 const WebString& characteristicInstanceID, | |
118 // Corresponds to WebBluetoothGATTQueryQuantity in web_bluetooth.mojom | |
119 int32_t quantity, | |
dcheng
2016/12/09 08:17:57
Out of curiosity... why can't we use an enum type
dougt
2016/12/09 19:20:07
I think that's right. You can't include third_part
scheib
2016/12/10 01:12:59
This file in
third_party/WebKit/public/platform
| |
120 const WebString& descriptorsUUID, | |
121 WebBluetoothGetDescriptorsCallbacks*) = 0; | |
108 | 122 |
109 // Called when addEventListener is called on a characteristic. | 123 // Called when addEventListener is called on a characteristic. |
110 virtual void registerCharacteristicObject( | 124 virtual void registerCharacteristicObject( |
111 const WebString& characteristicInstanceID, | 125 const WebString& characteristicInstanceID, |
112 WebBluetoothRemoteGATTCharacteristic*) = 0; | 126 WebBluetoothRemoteGATTCharacteristic*) = 0; |
113 virtual void characteristicObjectRemoved( | 127 virtual void characteristicObjectRemoved( |
114 const WebString& characteristicInstanceID, | 128 const WebString& characteristicInstanceID, |
115 WebBluetoothRemoteGATTCharacteristic*) {} | 129 WebBluetoothRemoteGATTCharacteristic*) {} |
116 }; | 130 }; |
117 | 131 |
118 } // namespace blink | 132 } // namespace blink |
119 | 133 |
120 #endif // WebBluetooth_h | 134 #endif // WebBluetooth_h |
OLD | NEW |