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 DEVICE_USB_USB_DEVICE_IMPL_H_ | 5 #ifndef DEVICE_USB_USB_DEVICE_IMPL_H_ |
6 #define DEVICE_USB_USB_DEVICE_IMPL_H_ | 6 #define DEVICE_USB_USB_DEVICE_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | |
10 #include <string> | |
11 #include <utility> | 9 #include <utility> |
12 #include <vector> | 10 #include <vector> |
13 | 11 |
14 #include "base/callback.h" | 12 #include "base/callback.h" |
15 #include "base/macros.h" | 13 #include "base/macros.h" |
16 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
17 #include "build/build_config.h" | 15 #include "build/build_config.h" |
18 #include "device/usb/usb_descriptors.h" | 16 #include "device/usb/usb_descriptors.h" |
19 #include "device/usb/usb_device.h" | 17 #include "device/usb/usb_device.h" |
20 #include "device/usb/webusb_descriptors.h" | 18 #include "device/usb/webusb_descriptors.h" |
(...skipping 19 matching lines...) Expand all Loading... |
40 typedef struct libusb_config_descriptor* PlatformUsbConfigDescriptor; | 38 typedef struct libusb_config_descriptor* PlatformUsbConfigDescriptor; |
41 typedef struct libusb_device_handle* PlatformUsbDeviceHandle; | 39 typedef struct libusb_device_handle* PlatformUsbDeviceHandle; |
42 | 40 |
43 class UsbDeviceImpl : public UsbDevice { | 41 class UsbDeviceImpl : public UsbDevice { |
44 public: | 42 public: |
45 // UsbDevice implementation: | 43 // UsbDevice implementation: |
46 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
47 void CheckUsbAccess(const ResultCallback& callback) override; | 45 void CheckUsbAccess(const ResultCallback& callback) override; |
48 #endif // OS_CHROMEOS | 46 #endif // OS_CHROMEOS |
49 void Open(const OpenCallback& callback) override; | 47 void Open(const OpenCallback& callback) override; |
| 48 bool Close(scoped_refptr<UsbDeviceHandle> handle) override; |
50 const UsbConfigDescriptor* GetActiveConfiguration() override; | 49 const UsbConfigDescriptor* GetActiveConfiguration() override; |
51 | 50 |
52 // These functions are used during enumeration only. The values must not | 51 // These functions are used during enumeration only. The values must not |
53 // change during the object's lifetime. | 52 // change during the object's lifetime. |
54 void set_manufacturer_string(const base::string16& value) { | 53 void set_manufacturer_string(const base::string16& value) { |
55 manufacturer_string_ = value; | 54 manufacturer_string_ = value; |
56 } | 55 } |
57 void set_product_string(const base::string16& value) { | 56 void set_product_string(const base::string16& value) { |
58 product_string_ = value; | 57 product_string_ = value; |
59 } | 58 } |
(...skipping 21 matching lines...) Expand all Loading... |
81 | 80 |
82 ~UsbDeviceImpl() override; | 81 ~UsbDeviceImpl() override; |
83 | 82 |
84 // Called only by UsbServiceImpl. | 83 // Called only by UsbServiceImpl. |
85 void set_visited(bool visited) { visited_ = visited; } | 84 void set_visited(bool visited) { visited_ = visited; } |
86 bool was_visited() const { return visited_; } | 85 bool was_visited() const { return visited_; } |
87 void OnDisconnect(); | 86 void OnDisconnect(); |
88 void ReadAllConfigurations(); | 87 void ReadAllConfigurations(); |
89 | 88 |
90 // Called by UsbDeviceHandleImpl. | 89 // Called by UsbDeviceHandleImpl. |
91 void Close(scoped_refptr<UsbDeviceHandle> handle); | |
92 void RefreshActiveConfiguration(); | 90 void RefreshActiveConfiguration(); |
93 | 91 |
94 private: | 92 private: |
95 void GetAllConfigurations(); | 93 void GetAllConfigurations(); |
96 #if defined(OS_CHROMEOS) | 94 #if defined(OS_CHROMEOS) |
97 void OnOpenRequestComplete(const OpenCallback& callback, | 95 void OnOpenRequestComplete(const OpenCallback& callback, |
98 dbus::FileDescriptor fd); | 96 dbus::FileDescriptor fd); |
99 void OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd, | 97 void OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd, |
100 const OpenCallback& callback); | 98 const OpenCallback& callback); |
101 #endif | 99 #endif |
(...skipping 23 matching lines...) Expand all Loading... |
125 | 123 |
126 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 124 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
127 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 125 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
128 | 126 |
129 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl); | 127 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl); |
130 }; | 128 }; |
131 | 129 |
132 } // namespace device | 130 } // namespace device |
133 | 131 |
134 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_ | 132 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_ |
OLD | NEW |