| 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/WebPassOwnPtr.h" | 9 #include "public/platform/WebPassOwnPtr.h" |
| 10 #include "public/platform/WebString.h" | 10 #include "public/platform/WebString.h" |
| 11 #include "public/platform/WebVector.h" | 11 #include "public/platform/WebVector.h" |
| 12 #include "public/platform/modules/bluetooth/WebBluetoothError.h" | 12 #include "public/platform/modules/bluetooth/WebBluetoothError.h" |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class WebBluetoothGATTCharacteristic; |
| 18 |
| 17 struct WebBluetoothDevice; | 19 struct WebBluetoothDevice; |
| 18 struct WebBluetoothGATTCharacteristicInit; | 20 struct WebBluetoothGATTCharacteristicInit; |
| 19 struct WebBluetoothGATTRemoteServer; | 21 struct WebBluetoothGATTRemoteServer; |
| 20 struct WebBluetoothGATTService; | 22 struct WebBluetoothGATTService; |
| 21 struct WebRequestDeviceOptions; | 23 struct WebRequestDeviceOptions; |
| 22 | 24 |
| 23 // Success and failure callbacks for requestDevice. | 25 // Success and failure callbacks for requestDevice. |
| 24 using WebBluetoothRequestDeviceCallbacks = WebCallbacks<WebPassOwnPtr<WebBluetoo
thDevice>, const WebBluetoothError&>; | 26 using WebBluetoothRequestDeviceCallbacks = WebCallbacks<WebPassOwnPtr<WebBluetoo
thDevice>, const WebBluetoothError&>; |
| 25 | 27 |
| 26 // Success and failure callbacks for connectGATT. | 28 // Success and failure callbacks for connectGATT. |
| 27 using WebBluetoothConnectGATTCallbacks = WebCallbacks<WebPassOwnPtr<WebBluetooth
GATTRemoteServer>, const WebBluetoothError&>; | 29 using WebBluetoothConnectGATTCallbacks = WebCallbacks<WebPassOwnPtr<WebBluetooth
GATTRemoteServer>, const WebBluetoothError&>; |
| 28 | 30 |
| 29 // Success and failure callbacks for getPrimaryService. | 31 // Success and failure callbacks for getPrimaryService. |
| 30 using WebBluetoothGetPrimaryServiceCallbacks = WebCallbacks<WebPassOwnPtr<WebBlu
etoothGATTService>, const WebBluetoothError&>; | 32 using WebBluetoothGetPrimaryServiceCallbacks = WebCallbacks<WebPassOwnPtr<WebBlu
etoothGATTService>, const WebBluetoothError&>; |
| 31 | 33 |
| 32 // Success and failure callbacks for getCharacteristic. | 34 // Success and failure callbacks for getCharacteristic. |
| 33 using WebBluetoothGetCharacteristicCallbacks = WebCallbacks<WebPassOwnPtr<WebBlu
etoothGATTCharacteristicInit>, const WebBluetoothError&>; | 35 using WebBluetoothGetCharacteristicCallbacks = WebCallbacks<WebPassOwnPtr<WebBlu
etoothGATTCharacteristicInit>, const WebBluetoothError&>; |
| 34 | 36 |
| 35 // Success and failure callbacks for readValue. | 37 // Success and failure callbacks for readValue. |
| 36 using WebBluetoothReadValueCallbacks = WebCallbacks<const WebVector<uint8_t>&, c
onst WebBluetoothError&>; | 38 using WebBluetoothReadValueCallbacks = WebCallbacks<const WebVector<uint8_t>&, c
onst WebBluetoothError&>; |
| 37 | 39 |
| 38 // Success and failure callbacks for writeValue. | 40 // Success and failure callbacks for writeValue. |
| 39 using WebBluetoothWriteValueCallbacks = WebCallbacks<void, const WebBluetoothErr
or&>; | 41 using WebBluetoothWriteValueCallbacks = WebCallbacks<void, const WebBluetoothErr
or&>; |
| 40 | 42 |
| 43 // Success and failure callbacks for characteristic.startNotifications and |
| 44 // characteristic.stopNotifications. |
| 45 using WebBluetoothNotificationsCallbacks = WebCallbacks<void, const WebBluetooth
Error&>; |
| 46 |
| 41 class WebBluetooth { | 47 class WebBluetooth { |
| 42 public: | 48 public: |
| 43 virtual ~WebBluetooth() { } | 49 virtual ~WebBluetooth() { } |
| 44 | 50 |
| 45 // Bluetooth Methods: | 51 // Bluetooth Methods: |
| 46 // See https://webbluetoothchrome.github.io/web-bluetooth/#device-discovery | 52 // See https://webbluetoothchrome.github.io/web-bluetooth/#device-discovery |
| 47 // WebBluetoothRequestDeviceCallbacks ownership transferred to the client. | 53 // WebBluetoothRequestDeviceCallbacks ownership transferred to the client. |
| 48 virtual void requestDevice(const WebRequestDeviceOptions&, WebBluetoothReque
stDeviceCallbacks*) { } | 54 virtual void requestDevice(const WebRequestDeviceOptions&, WebBluetoothReque
stDeviceCallbacks*) { } |
| 49 | 55 |
| 50 // BluetoothDevice methods: | 56 // BluetoothDevice methods: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 67 const WebString& characteristicUUID, | 73 const WebString& characteristicUUID, |
| 68 WebBluetoothGetCharacteristicCallbacks*) { } | 74 WebBluetoothGetCharacteristicCallbacks*) { } |
| 69 | 75 |
| 70 // BluetoothGATTCharacteristic methods: | 76 // BluetoothGATTCharacteristic methods: |
| 71 // See https://webbluetoothchrome.github.io/web-bluetooth/#bluetoothgattchar
acteristic | 77 // See https://webbluetoothchrome.github.io/web-bluetooth/#bluetoothgattchar
acteristic |
| 72 virtual void readValue(const WebString& characteristicInstanceID, | 78 virtual void readValue(const WebString& characteristicInstanceID, |
| 73 WebBluetoothReadValueCallbacks*) { } | 79 WebBluetoothReadValueCallbacks*) { } |
| 74 virtual void writeValue(const WebString& characteristicInstanceID, | 80 virtual void writeValue(const WebString& characteristicInstanceID, |
| 75 const std::vector<uint8_t>& value, | 81 const std::vector<uint8_t>& value, |
| 76 WebBluetoothWriteValueCallbacks*) { } | 82 WebBluetoothWriteValueCallbacks*) { } |
| 83 virtual void startNotifications(const WebString& characteristicInstanceID, |
| 84 WebBluetoothGATTCharacteristic*, |
| 85 WebBluetoothNotificationsCallbacks*) {} |
| 86 virtual void stopNotifications(const WebString& characteristicInstanceID, |
| 87 WebBluetoothGATTCharacteristic*, |
| 88 WebBluetoothNotificationsCallbacks*) {} |
| 89 virtual void characteristicObjectRemoved( |
| 90 const WebString& characteristicInstanceID, |
| 91 WebBluetoothGATTCharacteristic*) {} |
| 77 }; | 92 }; |
| 78 | 93 |
| 79 } // namespace blink | 94 } // namespace blink |
| 80 | 95 |
| 81 #endif // WebBluetooth_h | 96 #endif // WebBluetooth_h |
| OLD | NEW |