OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_USB_SERVICE_USB_DEVICE_HANDLE_H_ | 5 #ifndef DEVICE_USB_USB_DEVICE_HANDLE_H_ |
6 #define COMPONENTS_USB_SERVICE_USB_DEVICE_HANDLE_H_ | 6 #define DEVICE_USB_USB_DEVICE_HANDLE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "components/usb_service/usb_interface.h" | 15 #include "device/usb/usb_interface.h" |
16 #include "components/usb_service/usb_service_export.h" | |
17 #include "net/base/io_buffer.h" | 16 #include "net/base/io_buffer.h" |
18 | 17 |
19 namespace usb_service { | 18 namespace device { |
20 | 19 |
21 class UsbDevice; | 20 class UsbDevice; |
22 | 21 |
23 enum UsbTransferStatus { | 22 enum UsbTransferStatus { |
24 USB_TRANSFER_COMPLETED = 0, | 23 USB_TRANSFER_COMPLETED = 0, |
25 USB_TRANSFER_ERROR, | 24 USB_TRANSFER_ERROR, |
26 USB_TRANSFER_TIMEOUT, | 25 USB_TRANSFER_TIMEOUT, |
27 USB_TRANSFER_CANCELLED, | 26 USB_TRANSFER_CANCELLED, |
28 USB_TRANSFER_STALLED, | 27 USB_TRANSFER_STALLED, |
29 USB_TRANSFER_DISCONNECT, | 28 USB_TRANSFER_DISCONNECT, |
30 USB_TRANSFER_OVERFLOW, | 29 USB_TRANSFER_OVERFLOW, |
31 USB_TRANSFER_LENGTH_SHORT, | 30 USB_TRANSFER_LENGTH_SHORT, |
32 }; | 31 }; |
33 | 32 |
34 typedef base::Callback< | 33 typedef base::Callback< |
35 void(UsbTransferStatus, scoped_refptr<net::IOBuffer>, size_t)> | 34 void(UsbTransferStatus, scoped_refptr<net::IOBuffer>, size_t)> |
36 UsbTransferCallback; | 35 UsbTransferCallback; |
37 | 36 |
38 // UsbDeviceHandle class provides basic I/O related functionalities. | 37 // UsbDeviceHandle class provides basic I/O related functionalities. |
39 class USB_SERVICE_EXPORT UsbDeviceHandle | 38 class UsbDeviceHandle : public base::RefCountedThreadSafe<UsbDeviceHandle> { |
40 : public base::RefCountedThreadSafe<UsbDeviceHandle> { | |
41 public: | 39 public: |
42 enum TransferRequestType { STANDARD, CLASS, VENDOR, RESERVED }; | 40 enum TransferRequestType { STANDARD, CLASS, VENDOR, RESERVED }; |
43 enum TransferRecipient { DEVICE, INTERFACE, ENDPOINT, OTHER }; | 41 enum TransferRecipient { DEVICE, INTERFACE, ENDPOINT, OTHER }; |
44 | 42 |
45 virtual scoped_refptr<UsbDevice> GetDevice() const = 0; | 43 virtual scoped_refptr<UsbDevice> GetDevice() const = 0; |
46 | 44 |
47 // Notifies UsbDevice to drop the reference of this object; cancels all the | 45 // Notifies UsbDevice to drop the reference of this object; cancels all the |
48 // flying transfers. | 46 // flying transfers. |
49 // It is possible that the object has no other reference after this call. So | 47 // It is possible that the object has no other reference after this call. So |
50 // if it is called using a raw pointer, it could be invalidated. | 48 // if it is called using a raw pointer, it could be invalidated. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 protected: | 98 protected: |
101 friend class base::RefCountedThreadSafe<UsbDeviceHandle>; | 99 friend class base::RefCountedThreadSafe<UsbDeviceHandle>; |
102 | 100 |
103 UsbDeviceHandle() {}; | 101 UsbDeviceHandle() {}; |
104 | 102 |
105 virtual ~UsbDeviceHandle() {}; | 103 virtual ~UsbDeviceHandle() {}; |
106 | 104 |
107 DISALLOW_COPY_AND_ASSIGN(UsbDeviceHandle); | 105 DISALLOW_COPY_AND_ASSIGN(UsbDeviceHandle); |
108 }; | 106 }; |
109 | 107 |
110 } // namespace usb_service | 108 } // namespace device |
111 | 109 |
112 #endif // COMPONENTS_USB_SERVICE_USB_DEVICE_HANDLE_H_ | 110 #endif // DEVICE_USB_USB_DEVICE_HANDLE_H_ |
OLD | NEW |