| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 device.usb; | 5 module device.usb; |
| 6 | 6 |
| 7 import "device.mojom"; | 7 import "device.mojom"; |
| 8 | 8 |
| 9 struct DeviceFilter { | 9 struct DeviceFilter { |
| 10 bool has_vendor_id; | 10 bool has_vendor_id; |
| 11 uint16 vendor_id; | 11 uint16 vendor_id; |
| 12 | 12 |
| 13 bool has_product_id; | 13 bool has_product_id; |
| 14 uint16 product_id; | 14 uint16 product_id; |
| 15 | 15 |
| 16 bool has_class_code; | 16 bool has_class_code; |
| 17 uint8 class_code; | 17 uint8 class_code; |
| 18 | 18 |
| 19 bool has_subclass_code; | 19 bool has_subclass_code; |
| 20 uint8 subclass_code; | 20 uint8 subclass_code; |
| 21 | 21 |
| 22 bool has_protocol_code; | 22 bool has_protocol_code; |
| 23 uint8 protocol_code; | 23 uint8 protocol_code; |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 struct EnumerationOptions { | 26 struct EnumerationOptions { |
| 27 array<DeviceFilter>? filters; | 27 array<DeviceFilter>? filters; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 struct DeviceChangeNotification { | |
| 31 array<DeviceInfo> devices_added; | |
| 32 array<DeviceInfo> devices_removed; | |
| 33 }; | |
| 34 | |
| 35 interface DeviceManager { | 30 interface DeviceManager { |
| 36 // Retrieves information about all devices available to the DeviceManager | 31 // Retrieves information about all devices available to the DeviceManager |
| 37 // implementation. | 32 // implementation. |
| 38 GetDevices(EnumerationOptions? options) => (array<DeviceInfo> results); | 33 GetDevices(EnumerationOptions? options) => (array<DeviceInfo> results); |
| 39 | 34 |
| 40 // Retrieves information about changes to the set of devices available to the | |
| 41 // DeviceManager since the last call to this method. A device that is added | |
| 42 // and removed between calls will not be included. | |
| 43 GetDeviceChanges() => (DeviceChangeNotification changes); | |
| 44 | |
| 45 // Requests a device by guid. | 35 // Requests a device by guid. |
| 46 GetDevice(string guid, Device& device_request); | 36 GetDevice(string guid, Device& device_request); |
| 37 |
| 38 // Sets the client for this DeviceManager service. The service will notify its |
| 39 // client of device events such as connection and disconnection. |
| 40 SetClient(DeviceManagerClient client); |
| 47 }; | 41 }; |
| 42 |
| 43 interface DeviceManagerClient { |
| 44 // Called when a device is connected to the host. |
| 45 OnDeviceAdded(DeviceInfo device_info); |
| 46 |
| 47 // Called when a device is disconnected from the host. |
| 48 OnDeviceRemoved(DeviceInfo device_info); |
| 49 }; |
| OLD | NEW |