| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class ApiResourceEventNotifier; | 25 class ApiResourceEventNotifier; |
| 26 | 26 |
| 27 // A UsbDeviceResource is an ApiResource wrapper for a UsbDevice. When invoking | 27 // A UsbDeviceResource is an ApiResource wrapper for a UsbDevice. When invoking |
| 28 // transfers on the underlying device it will use the ApiResourceEventNotifier | 28 // transfers on the underlying device it will use the ApiResourceEventNotifier |
| 29 // associated with the underlying ApiResource to deliver completion messages. | 29 // associated with the underlying ApiResource to deliver completion messages. |
| 30 class UsbDeviceResource : public ApiResource { | 30 class UsbDeviceResource : public ApiResource { |
| 31 public: | 31 public: |
| 32 UsbDeviceResource(ApiResourceEventNotifier* notifier, UsbDevice* device); | 32 UsbDeviceResource(ApiResourceEventNotifier* notifier, UsbDevice* device); |
| 33 virtual ~UsbDeviceResource(); | 33 virtual ~UsbDeviceResource(); |
| 34 | 34 |
| 35 void Close(); |
| 36 |
| 35 // All of the *Transfer variants that are exposed here adapt their arguments | 37 // All of the *Transfer variants that are exposed here adapt their arguments |
| 36 // for the underlying UsbDevice's interface and invoke the corresponding | 38 // for the underlying UsbDevice's interface and invoke the corresponding |
| 37 // methods with completion callbacks that call OnTransferComplete on the event | 39 // methods with completion callbacks that call OnTransferComplete on the event |
| 38 // notifier. | 40 // notifier. |
| 39 void ControlTransfer( | 41 void ControlTransfer( |
| 40 const api::experimental_usb::ControlTransferInfo& transfer); | 42 const api::experimental_usb::ControlTransferInfo& transfer); |
| 41 void InterruptTransfer( | 43 void InterruptTransfer( |
| 42 const api::experimental_usb::GenericTransferInfo& transfer); | 44 const api::experimental_usb::GenericTransferInfo& transfer); |
| 43 void BulkTransfer(const api::experimental_usb::GenericTransferInfo& transfer); | 45 void BulkTransfer(const api::experimental_usb::GenericTransferInfo& transfer); |
| 44 void IsochronousTransfer( | 46 void IsochronousTransfer( |
| 45 const api::experimental_usb::IsochronousTransferInfo& transfer); | 47 const api::experimental_usb::IsochronousTransferInfo& transfer); |
| 46 | 48 |
| 47 private: | 49 private: |
| 48 // Invoked by the underlying device's transfer callbacks. Indicates transfer | 50 // Invoked by the underlying device's transfer callbacks. Indicates transfer |
| 49 // completion to the ApiResource's event notifier. | 51 // completion to the ApiResource's event notifier. |
| 50 void TransferComplete(net::IOBuffer* buffer, const size_t length, | 52 void TransferComplete(net::IOBuffer* buffer, const size_t length, |
| 51 UsbTransferStatus status); | 53 UsbTransferStatus status); |
| 52 | 54 |
| 53 scoped_refptr<UsbDevice> device_; | 55 scoped_refptr<UsbDevice> device_; |
| 54 | 56 |
| 55 DISALLOW_COPY_AND_ASSIGN(UsbDeviceResource); | 57 DISALLOW_COPY_AND_ASSIGN(UsbDeviceResource); |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 } // namespace extensions | 60 } // namespace extensions |
| 59 | 61 |
| 60 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_ | 62 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_DEVICE_RESOURCE_H_ |
| OLD | NEW |