| 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 WebBluetooth_h | |
| 6 #define WebBluetooth_h | |
| 7 | |
| 8 #include "public/platform/WebCallbacks.h" | |
| 9 #include "public/platform/WebString.h" | |
| 10 #include "public/platform/WebVector.h" | |
| 11 | |
| 12 #include <memory> | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 class WebBluetoothDevice; | |
| 17 class WebBluetoothRemoteGATTCharacteristic; | |
| 18 | |
| 19 struct WebBluetoothDeviceInit; | |
| 20 struct WebBluetoothRemoteGATTCharacteristicInit; | |
| 21 struct WebBluetoothRemoteGATTService; | |
| 22 struct WebRequestDeviceOptions; | |
| 23 | |
| 24 // Success and failure callbacks for requestDevice. | |
| 25 using WebBluetoothRequestDeviceCallbacks = WebCallbacks< | |
| 26 std::unique_ptr<WebBluetoothDeviceInit>, | |
| 27 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | |
| 28 | |
| 29 // Success and failure callbacks for GattServer.connect(). | |
| 30 using WebBluetoothRemoteGATTServerConnectCallbacks = WebCallbacks< | |
| 31 void, | |
| 32 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | |
| 33 | |
| 34 // Success and failure callbacks for getPrimaryService(s). | |
| 35 using WebBluetoothGetPrimaryServicesCallbacks = WebCallbacks< | |
| 36 const WebVector<WebBluetoothRemoteGATTService*>&, | |
| 37 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | |
| 38 | |
| 39 // Success and failure callbacks for getCharacteristic(s). | |
| 40 using WebBluetoothGetCharacteristicsCallbacks = WebCallbacks< | |
| 41 const WebVector<WebBluetoothRemoteGATTCharacteristicInit*>&, | |
| 42 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | |
| 43 | |
| 44 // Success and failure callbacks for readValue. | |
| 45 using WebBluetoothReadValueCallbacks = WebCallbacks< | |
| 46 const WebVector<uint8_t>&, | |
| 47 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | |
| 48 | |
| 49 // Success and failure callbacks for writeValue. | |
| 50 using WebBluetoothWriteValueCallbacks = WebCallbacks< | |
| 51 const WebVector<uint8_t>&, | |
| 52 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | |
| 53 | |
| 54 // Success and failure callbacks for characteristic.startNotifications and | |
| 55 // characteristic.stopNotifications. | |
| 56 using WebBluetoothNotificationsCallbacks = WebCallbacks< | |
| 57 void, | |
| 58 int32_t /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */>; | |
| 59 | |
| 60 class WebBluetooth { | |
| 61 public: | |
| 62 virtual ~WebBluetooth() {} | |
| 63 | |
| 64 // Bluetooth Methods: | |
| 65 // See https://webbluetoothcg.github.io/web-bluetooth/#device-discovery | |
| 66 // WebBluetoothRequestDeviceCallbacks ownership transferred to the client. | |
| 67 virtual void requestDevice(const WebRequestDeviceOptions&, | |
| 68 WebBluetoothRequestDeviceCallbacks*) {} | |
| 69 | |
| 70 // BluetoothDevice methods: | |
| 71 | |
| 72 // BluetoothRemoteGATTServer methods: | |
| 73 // See | |
| 74 // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattserver | |
| 75 virtual void connect(const WebString& deviceId, | |
| 76 WebBluetoothDevice* device, | |
| 77 WebBluetoothRemoteGATTServerConnectCallbacks*) {} | |
| 78 virtual void disconnect(const WebString& deviceId) = 0; | |
| 79 virtual void getPrimaryServices( | |
| 80 const WebString& deviceId, | |
| 81 // Corresponds to WebBluetoothGATTQueryQuantity in web_bluetooth.mojom: | |
| 82 int32_t quantity, | |
| 83 const WebString& servicesUUID, | |
| 84 WebBluetoothGetPrimaryServicesCallbacks*) = 0; | |
| 85 | |
| 86 // BluetoothRemoteGATTService methods: | |
| 87 // See | |
| 88 // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattservice | |
| 89 virtual void getCharacteristics( | |
| 90 const WebString& serviceInstanceID, | |
| 91 // Corresponds to WebBluetoothGATTQueryQuantity in web_bluetooth.mojom | |
| 92 int32_t quantity, | |
| 93 const WebString& characteristicsUUID, | |
| 94 WebBluetoothGetCharacteristicsCallbacks*) = 0; | |
| 95 | |
| 96 // BluetoothRemoteGATTCharacteristic methods: | |
| 97 // See | |
| 98 // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacte
ristic | |
| 99 virtual void readValue(const WebString& characteristicInstanceID, | |
| 100 WebBluetoothReadValueCallbacks*) {} | |
| 101 virtual void writeValue(const WebString& characteristicInstanceID, | |
| 102 const WebVector<uint8_t>& value, | |
| 103 WebBluetoothWriteValueCallbacks*) {} | |
| 104 virtual void startNotifications(const WebString& characteristicInstanceID, | |
| 105 WebBluetoothNotificationsCallbacks*) {} | |
| 106 virtual void stopNotifications(const WebString& characteristicInstanceID, | |
| 107 WebBluetoothNotificationsCallbacks*) {} | |
| 108 | |
| 109 // Called when addEventListener is called on a characteristic. | |
| 110 virtual void registerCharacteristicObject( | |
| 111 const WebString& characteristicInstanceID, | |
| 112 WebBluetoothRemoteGATTCharacteristic*) = 0; | |
| 113 virtual void characteristicObjectRemoved( | |
| 114 const WebString& characteristicInstanceID, | |
| 115 WebBluetoothRemoteGATTCharacteristic*) {} | |
| 116 }; | |
| 117 | |
| 118 } // namespace blink | |
| 119 | |
| 120 #endif // WebBluetooth_h | |
| OLD | NEW |