| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 module blink.mojom; | 5 module blink.mojom; |
| 6 | 6 |
| 7 import "device/bluetooth/public/interfaces/bluetooth_uuid.mojom"; | 7 import "device/bluetooth/public/interfaces/bluetooth_uuid.mojom"; |
| 8 import "content/common/bluetooth/bluetooth_device_id.mojom"; |
| 8 | 9 |
| 9 // Errors that can occur during Web Bluetooth execution, which are transformed | 10 // Errors that can occur during Web Bluetooth execution, which are transformed |
| 10 // to a DOMException in Source/modules/bluetooth/BluetoothError.cpp. | 11 // to a DOMException in Source/modules/bluetooth/BluetoothError.cpp. |
| 11 // | 12 // |
| 12 // These errors all produce constant message strings. If a particular message | 13 // These errors all produce constant message strings. If a particular message |
| 13 // needs a dynamic component, we should add a separate enum so type-checking the | 14 // needs a dynamic component, we should add a separate enum so type-checking the |
| 14 // IPC ensures the dynamic component is passed. | 15 // IPC ensures the dynamic component is passed. |
| 15 enum WebBluetoothError { | 16 enum WebBluetoothError { |
| 16 SUCCESS, | 17 SUCCESS, |
| 17 // AbortError: | 18 // AbortError: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 // Indicates if the function will return a single or multiple | 85 // Indicates if the function will return a single or multiple |
| 85 // GATT objects. | 86 // GATT objects. |
| 86 enum WebBluetoothGATTQueryQuantity { | 87 enum WebBluetoothGATTQueryQuantity { |
| 87 SINGLE, | 88 SINGLE, |
| 88 MULTIPLE | 89 MULTIPLE |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 struct WebBluetoothDevice { | 92 struct WebBluetoothDevice { |
| 92 string id; | 93 content.mojom.BluetoothDeviceId id; |
| 93 string name; | 94 string name; |
| 94 array<string> uuids; | 95 array<string> uuids; |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 struct WebBluetoothRemoteGATTService { | 98 struct WebBluetoothRemoteGATTService { |
| 98 string instance_id; | 99 string instance_id; |
| 99 string uuid; | 100 string uuid; |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 struct WebBluetoothRemoteGATTCharacteristic { | 103 struct WebBluetoothRemoteGATTCharacteristic { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 116 // a device disconnects. | 117 // a device disconnects. |
| 117 SetClient(associated WebBluetoothServiceClient client); | 118 SetClient(associated WebBluetoothServiceClient client); |
| 118 | 119 |
| 119 RequestDevice(WebBluetoothRequestDeviceOptions options) | 120 RequestDevice(WebBluetoothRequestDeviceOptions options) |
| 120 => (WebBluetoothError error, WebBluetoothDevice? device); | 121 => (WebBluetoothError error, WebBluetoothDevice? device); |
| 121 | 122 |
| 122 // Creates a GATT Connection to a Bluetooth Device with |device_id| if a | 123 // Creates a GATT Connection to a Bluetooth Device with |device_id| if a |
| 123 // connection to the device didn't exist already. If a GATT connection existed | 124 // connection to the device didn't exist already. If a GATT connection existed |
| 124 // already then this function increases the ref count to keep that connection | 125 // already then this function increases the ref count to keep that connection |
| 125 // alive. | 126 // alive. |
| 126 RemoteServerConnect(string device_id) => (WebBluetoothError error); | 127 RemoteServerConnect(content.mojom.BluetoothDeviceId device_id) => (WebBluetoot
hError error); |
| 127 | 128 |
| 128 // If a GATT connection exists for Device with |device_id| then decreases | 129 // If a GATT connection exists for Device with |device_id| then decreases |
| 129 // the ref count for that connection. | 130 // the ref count for that connection. |
| 130 RemoteServerDisconnect(string device_id); | 131 RemoteServerDisconnect(content.mojom.BluetoothDeviceId device_id); |
| 131 | 132 |
| 132 // Returns the first GATT Service with |service_uuid| of a Bluetooth Device | 133 // Returns the first GATT Service with |service_uuid| of a Bluetooth Device |
| 133 // with |device_id|. | 134 // with |device_id|. |
| 134 RemoteServerGetPrimaryService( | 135 RemoteServerGetPrimaryService( |
| 135 string device_id, | 136 content.mojom.BluetoothDeviceId device_id, |
| 136 device.mojom.BluetoothUUID service_uuid) => ( | 137 device.mojom.BluetoothUUID service_uuid) => ( |
| 137 WebBluetoothError error, | 138 WebBluetoothError error, |
| 138 WebBluetoothRemoteGATTService? service); | 139 WebBluetoothRemoteGATTService? service); |
| 139 | 140 |
| 140 // Returns the Characteristics of a GATT Service with |service_instance_id|. | 141 // Returns the Characteristics of a GATT Service with |service_instance_id|. |
| 141 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, only one | 142 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, only one |
| 142 // characteristic will be returned. | 143 // characteristic will be returned. |
| 143 RemoteServiceGetCharacteristics( | 144 RemoteServiceGetCharacteristics( |
| 144 string service_instance_id, | 145 string service_instance_id, |
| 145 WebBluetoothGATTQueryQuantity quantity, | 146 WebBluetoothGATTQueryQuantity quantity, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 175 RemoteCharacteristicStopNotifications( | 176 RemoteCharacteristicStopNotifications( |
| 176 string characteristic_instance_id) => (); | 177 string characteristic_instance_id) => (); |
| 177 }; | 178 }; |
| 178 | 179 |
| 179 // Classes should implement this interface and pass an associated pointer | 180 // Classes should implement this interface and pass an associated pointer |
| 180 // bound to them to the WebBluetoothService by using SetClient. Classes | 181 // bound to them to the WebBluetoothService by using SetClient. Classes |
| 181 // that do this will be notified of device events e.g. device disconnection. | 182 // that do this will be notified of device events e.g. device disconnection. |
| 182 interface WebBluetoothServiceClient { | 183 interface WebBluetoothServiceClient { |
| 183 RemoteCharacteristicValueChanged(string characteristic_instance_id, | 184 RemoteCharacteristicValueChanged(string characteristic_instance_id, |
| 184 array<uint8> value); | 185 array<uint8> value); |
| 185 GattServerDisconnected(string device_id); | 186 GattServerDisconnected(content.mojom.BluetoothDeviceId device_id); |
| 186 }; | 187 }; |
| OLD | NEW |