Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom

Issue 2635473004: bluetooth: web: web_bluetooth.mojom comments and UUID type fix. (Closed)
Patch Set: bluetooth.mojom.UUID type used; Comments updated. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/bluetooth/web_bluetooth_service_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/uuid.mojom"; 7 import "device/bluetooth/public/interfaces/uuid.mojom";
8 8
9 // Result codes that can occur during Web Bluetooth execution, which are 9 // Bluetooth Terminology:
10 // transformed to a DOMException in Source/modules/bluetooth/BluetoothError.cpp. 10 //
11 // https://en.wikipedia.org/wiki/Bluetooth_low_energy is a good resource
12 // describing the Bluetooth concepts used in this file:
13 // Generic Attribute Profile (GATT), device, services, characteristics,
14 // descriptors, and UUIDs.
15
16 // Instance ID Note:
17 //
18 // Structs and parameters use 'instance_id' string values as unique identifiers
19 // for Bluetooth GATT object instances. UUIDs are used to refer to e.g. a type
20 // of service (such as a battery service), while the instance ID refers to the
21 // unique instance of that service (there may be more than one).
22 //
23 // Subsequent calls from and to the client code use the ids to refer to
24 // previously disclosed objects.
25 //
26 // Device IDs are exposed to web content, valid to persist, and have a dedicated
27 // type, WebBluetoothDeviceId. See comments on that struct.
28 //
29 // Service, characteristic, and descriptor IDs are simply strings not exposed to
30 // web content and use platform specific values. They are only used for
31 // comparison and not intended to be parsed by code, serialized, or exposed to
32 // web content.
33 //
34 // For example:
35 // RemoteServerGetPrimaryServices() may return a struct of type
36 // WebBluetoothRemoteGATTService with an instance_id of "service1".
37 // To retrieve characteristics of that service use that id when calling
38 // RemoteServiceGetCharacteristics("service1", ...).
39
40 // Result codes that can occur during Web Bluetooth execution.
41 // Transformed to a DOMException in Source/modules/bluetooth/BluetoothError.cpp.
11 // 42 //
12 // These errors all produce constant message strings. If a particular message 43 // 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 44 // needs a dynamic component, we should add a separate enum so type-checking the
14 // IPC ensures the dynamic component is passed. 45 // IPC ensures the dynamic component is passed.
15 enum WebBluetoothResult { 46 enum WebBluetoothResult {
16 SUCCESS, 47 SUCCESS,
17 // AbortError: 48 // AbortError:
18 // InvalidModificationError: 49 // InvalidModificationError:
19 GATT_INVALID_ATTRIBUTE_LENGTH, 50 GATT_INVALID_ATTRIBUTE_LENGTH,
20 // InvalidStateError: 51 // InvalidStateError:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 bool accept_all_devices; 117 bool accept_all_devices;
87 }; 118 };
88 119
89 // Indicates if the function will return a single or multiple 120 // Indicates if the function will return a single or multiple
90 // GATT objects. 121 // GATT objects.
91 enum WebBluetoothGATTQueryQuantity { 122 enum WebBluetoothGATTQueryQuantity {
92 SINGLE, 123 SINGLE,
93 MULTIPLE 124 MULTIPLE
94 }; 125 };
95 126
127 // An identifier uniquely identifying a Bluetooth device. This identifier is
128 // safe to provide to web content and is unique per origin, even if referring
129 // to a common device. Web content may persist this identifier for future
130 // sessions to identify the same device.
96 struct WebBluetoothDeviceId { 131 struct WebBluetoothDeviceId {
97 string device_id; 132 string device_id;
98 }; 133 };
99 134
100 struct WebBluetoothDevice { 135 struct WebBluetoothDevice {
101 WebBluetoothDeviceId id; 136 WebBluetoothDeviceId id;
102 string? name; 137 string? name;
103 }; 138 };
104 139
105 struct WebBluetoothRemoteGATTService { 140 struct WebBluetoothRemoteGATTService {
106 string instance_id; 141 string instance_id; // See Instance ID Note above.
107 string uuid; 142 bluetooth.mojom.UUID uuid;
108 }; 143 };
109 144
110 struct WebBluetoothRemoteGATTCharacteristic { 145 struct WebBluetoothRemoteGATTCharacteristic {
111 string instance_id; 146 string instance_id; // See Instance ID Note above.
112 string uuid; 147 bluetooth.mojom.UUID uuid;
113 uint32 properties; 148 uint32 properties;
114 }; 149 };
115 150
116 struct WebBluetoothRemoteGATTDescriptor { 151 struct WebBluetoothRemoteGATTDescriptor {
117 string instance_id; 152 string instance_id; // See Instance ID Note above.
118 string uuid; 153 bluetooth.mojom.UUID uuid;
119 }; 154 };
120 155
121 // Web Bluetooth Interface that Blink can use to perform 156 // Web Bluetooth Interface that Blink can use to perform
122 // Bluetooth GATT Operations on Bluetooth Devices. 157 // Bluetooth GATT Operations on Bluetooth Devices.
123 interface WebBluetoothService { 158 interface WebBluetoothService {
124 // Sets the client for this WebBluetoothService. The service will notify the 159 // Sets the client for this WebBluetoothService. The service will notify the
125 // client of device events e.g. when a Characteristic's value changes or when 160 // client of device events e.g. when a Characteristic's value changes or when
126 // a device disconnects. 161 // a device disconnects.
127 SetClient(associated WebBluetoothServiceClient client); 162 SetClient(associated WebBluetoothServiceClient client);
128 163
129 RequestDevice(WebBluetoothRequestDeviceOptions options) 164 RequestDevice(WebBluetoothRequestDeviceOptions options)
130 => (WebBluetoothResult result, WebBluetoothDevice? device); 165 => (WebBluetoothResult result, WebBluetoothDevice? device);
131 166
132 // Creates a GATT Connection to a Bluetooth Device with |device_id| if a 167 // Creates a GATT Connection to a Bluetooth Device identified by |device_id|
133 // connection to the device didn't exist already. If a GATT connection existed 168 // if a connection to the device didn't exist already. If a GATT connection
134 // already then this function increases the ref count to keep that connection 169 // existed already then this function increases the ref count to keep that
135 // alive. 170 // connection alive.
136 RemoteServerConnect(WebBluetoothDeviceId device_id) => (WebBluetoothResult res ult); 171 RemoteServerConnect(WebBluetoothDeviceId device_id) => (WebBluetoothResult res ult);
137 172
138 // If a GATT connection exists for Device with |device_id| then decreases 173 // If a GATT connection exists for Device identified by |device_id| then
139 // the ref count for that connection. 174 // decreases the ref count for that connection.
140 RemoteServerDisconnect(WebBluetoothDeviceId device_id); 175 RemoteServerDisconnect(WebBluetoothDeviceId device_id);
141 176
142 // If |services_uuid| is present, returns services with |services_uuid|. 177 // Returns the Services of a GATT Device identified by |device_id|.
178 // If |services_uuid| is present, filters services by |services_uuid|.
143 // Otherwise returns all non-blocklisted services. 179 // Otherwise returns all non-blocklisted services.
144 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, only one 180 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, at most one
145 // service will be returned. 181 // service will be returned.
146 RemoteServerGetPrimaryServices( 182 RemoteServerGetPrimaryServices(
147 WebBluetoothDeviceId device_id, 183 WebBluetoothDeviceId device_id,
148 WebBluetoothGATTQueryQuantity quantity, 184 WebBluetoothGATTQueryQuantity quantity,
149 bluetooth.mojom.UUID? services_uuid) => ( 185 bluetooth.mojom.UUID? services_uuid) => (
150 WebBluetoothResult result, 186 WebBluetoothResult result,
151 array<WebBluetoothRemoteGATTService>? services); 187 array<WebBluetoothRemoteGATTService>? services);
152 188
153 // Returns the Characteristics of a GATT Service with |service_instance_id|. 189 // Returns the Characteristics of a GATT Service identified by
154 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, only one 190 // |service_instance_id|.
191 // If |characteristics_uuid| is present, filters characteristics by
192 // |characteristics_uuid|. Otherwise returns all non-blocklisted services.
193 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, at most one
155 // characteristic will be returned. 194 // characteristic will be returned.
156 RemoteServiceGetCharacteristics( 195 RemoteServiceGetCharacteristics(
157 string service_instance_id, 196 string service_instance_id,
158 WebBluetoothGATTQueryQuantity quantity, 197 WebBluetoothGATTQueryQuantity quantity,
159 bluetooth.mojom.UUID? characteristics_uuid) => ( 198 bluetooth.mojom.UUID? characteristics_uuid) => (
160 WebBluetoothResult result, 199 WebBluetoothResult result,
161 array<WebBluetoothRemoteGATTCharacteristic>? characteristics); 200 array<WebBluetoothRemoteGATTCharacteristic>? characteristics);
162 201
163 // Reads the value for characteristic with 202 // Reads the value for the characteristic identified by
164 // |characteristic_instance_id|. If the value is successfully read the 203 // |characteristic_instance_id|. If the value is successfully read the
165 // callback will be run with WebBluetoothResult::SUCCESS and the 204 // callback will be run with WebBluetoothResult::SUCCESS and the
166 // characteristic's value. If the value is not successfully read the 205 // characteristic's value. If the value is not successfully read the
167 // callback with be run with the corresponding error and nullptr for value. 206 // callback with be run with the corresponding error and nullptr for value.
168 RemoteCharacteristicReadValue( 207 RemoteCharacteristicReadValue(
169 string characteristic_instance_id) => ( 208 string characteristic_instance_id) => (
170 WebBluetoothResult result, 209 WebBluetoothResult result,
171 array<uint8>? value); 210 array<uint8>? value);
172 211
173 // Writes a value to the characteristic with 212 // Writes a value to the characteristic identified by
174 // |characteristic_instance_id|. The callback is run with 213 // |characteristic_instance_id|. The callback is run with
175 // WebBluetoothResult::SUCCESS if the value was successfully 214 // WebBluetoothResult::SUCCESS if the value was successfully
176 // written. 215 // written.
177 RemoteCharacteristicWriteValue( 216 RemoteCharacteristicWriteValue(
178 string characteristic_instance_id, 217 string characteristic_instance_id,
179 array<uint8> value) => (WebBluetoothResult result); 218 array<uint8> value) => (WebBluetoothResult result);
180 219
181 // Starts notifications for the characteristic with 220 // Starts notifications for the characteristic identified by
182 // |characteristic_instance_id|. 221 // |characteristic_instance_id|.
183 RemoteCharacteristicStartNotifications( 222 RemoteCharacteristicStartNotifications(
184 string characteristic_instance_id) => (WebBluetoothResult result); 223 string characteristic_instance_id) => (WebBluetoothResult result);
185 224
186 // Stops notifications for the characteristic with 225 // Stops notifications for the characteristic identified by
187 // |characteristic_instance_id|. 226 // |characteristic_instance_id|.
188 RemoteCharacteristicStopNotifications( 227 RemoteCharacteristicStopNotifications(
189 string characteristic_instance_id) => (); 228 string characteristic_instance_id) => ();
190 229
191 // Returns the Descriptors of a GATT Characteristic with 230 // Returns the Descriptors of a GATT Characteristic identified by
192 // |characteristics_instance_id|. 231 // |characteristics_instance_id|.
193 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, only one descriptor 232 // If |descriptor_uuid| is present, filters descriptors by
194 // will be returned. 233 // |descriptor_uuid|. Otherwise returns all non-blocklisted descriptors.
234 // If |quantity| == WebBluetoothGATTQueryQuantity::SINGLE, at most one
235 // characteristic will be returned.
195 RemoteCharacteristicGetDescriptors( 236 RemoteCharacteristicGetDescriptors(
196 string characteristics_instance_id, 237 string characteristics_instance_id,
197 WebBluetoothGATTQueryQuantity quantity, 238 WebBluetoothGATTQueryQuantity quantity,
198 bluetooth.mojom.UUID? descriptor_uuid) => ( 239 bluetooth.mojom.UUID? descriptor_uuid) => (
199 WebBluetoothResult result, 240 WebBluetoothResult result,
200 array<WebBluetoothRemoteGATTDescriptor>? descriptors); 241 array<WebBluetoothRemoteGATTDescriptor>? descriptors);
201 }; 242 };
202 243
203 // Classes should implement this interface and pass an associated pointer 244 // Classes should implement this interface and pass an associated pointer
204 // bound to them to the WebBluetoothService by using SetClient. Classes 245 // bound to them to the WebBluetoothService by using SetClient. Classes
205 // that do this will be notified of device events e.g. device disconnection. 246 // that do this will be notified of device events e.g. device disconnection.
206 interface WebBluetoothServiceClient { 247 interface WebBluetoothServiceClient {
248 // The characteristic identified by |characteristic_instance_id| has received
249 // a notification of value change.
207 RemoteCharacteristicValueChanged(string characteristic_instance_id, 250 RemoteCharacteristicValueChanged(string characteristic_instance_id,
208 array<uint8> value); 251 array<uint8> value);
252
253 // The device identified by |device_id| has been disconnected.
209 GattServerDisconnected(WebBluetoothDeviceId device_id); 254 GattServerDisconnected(WebBluetoothDeviceId device_id);
210 }; 255 };
OLDNEW
« no previous file with comments | « content/browser/bluetooth/web_bluetooth_service_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698