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 { |
103 string instance_id; | 104 string instance_id; |
104 string uuid; | 105 string uuid; |
105 uint32 properties; | 106 uint32 properties; |
106 }; | 107 }; |
107 | 108 |
108 // TODO(ortuno): Define Bluetooth Service. | 109 // TODO(ortuno): Define Bluetooth Service. |
Jeffrey Yasskin
2016/06/03 17:22:05
OT: I think this TODO is obsolete.
ortuno
2016/06/06 22:23:00
http://crrev.com/2041143002 :)
| |
109 // https://crbug.com/508771 | 110 // https://crbug.com/508771 |
110 | 111 |
111 // Web Bluetooth Interface that Blink can use to perform | 112 // Web Bluetooth Interface that Blink can use to perform |
112 // Bluetooth GATT Operations on Bluetooth Devices. | 113 // Bluetooth GATT Operations on Bluetooth Devices. |
113 interface WebBluetoothService { | 114 interface WebBluetoothService { |
114 // Sets the client for this WebBluetoothService. The service will notify the | 115 // Sets the client for this WebBluetoothService. The service will notify the |
115 // client of device events e.g. when a Characteristic's value changes or when | 116 // client of device events e.g. when a Characteristic's value changes or when |
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); |
Jeffrey Yasskin
2016/06/03 17:22:05
I wish we had 'using' declarations in mojo.
ortuno
2016/06/06 22:23:00
Me too :(
| |
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 |