Chromium Code Reviews| 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 <vector> | |
|
Reilly Grant (use Gerrit)
2015/08/03 18:04:04
Don't remove these includes just because usb_devic
juncai
2015/08/03 21:56:25
Done.
| |
| 9 | |
| 10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 9 #include "base/callback.h" |
| 12 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 13 #include "device/usb/usb_descriptors.h" | |
| 14 #include "device/usb/usb_device.h" | 11 #include "device/usb/usb_device.h" |
| 15 | 12 |
| 16 struct libusb_device; | 13 struct libusb_device; |
| 17 struct libusb_config_descriptor; | 14 struct libusb_config_descriptor; |
| 18 struct libusb_device_handle; | 15 struct libusb_device_handle; |
| 19 | 16 |
| 20 namespace base { | 17 namespace base { |
| 21 class SequencedTaskRunner; | 18 class SequencedTaskRunner; |
| 22 } | 19 } |
| 23 | 20 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 35 typedef struct libusb_device_handle* PlatformUsbDeviceHandle; | 32 typedef struct libusb_device_handle* PlatformUsbDeviceHandle; |
| 36 | 33 |
| 37 class UsbDeviceImpl : public UsbDevice { | 34 class UsbDeviceImpl : public UsbDevice { |
| 38 public: | 35 public: |
| 39 // UsbDevice implementation: | 36 // UsbDevice implementation: |
| 40 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 41 void CheckUsbAccess(const ResultCallback& callback) override; | 38 void CheckUsbAccess(const ResultCallback& callback) override; |
| 42 #endif // OS_CHROMEOS | 39 #endif // OS_CHROMEOS |
| 43 void Open(const OpenCallback& callback) override; | 40 void Open(const OpenCallback& callback) override; |
| 44 bool Close(scoped_refptr<UsbDeviceHandle> handle) override; | 41 bool Close(scoped_refptr<UsbDeviceHandle> handle) override; |
| 45 const UsbConfigDescriptor* GetConfiguration() override; | 42 const UsbConfigDescriptor* GetActiveConfiguration() override; |
| 46 | 43 |
| 47 // These functions are used during enumeration only. The values must not | 44 // These functions are used during enumeration only. The values must not |
| 48 // change during the object's lifetime. | 45 // change during the object's lifetime. |
| 49 void set_manufacturer_string(const base::string16& value) { | 46 void set_manufacturer_string(const base::string16& value) { |
| 50 manufacturer_string_ = value; | 47 manufacturer_string_ = value; |
| 51 } | 48 } |
| 52 void set_product_string(const base::string16& value) { | 49 void set_product_string(const base::string16& value) { |
| 53 product_string_ = value; | 50 product_string_ = value; |
| 54 } | 51 } |
| 55 void set_serial_number(const base::string16& value) { | 52 void set_serial_number(const base::string16& value) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 69 uint16 vendor_id, | 66 uint16 vendor_id, |
| 70 uint16 product_id, | 67 uint16 product_id, |
| 71 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); | 68 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); |
| 72 | 69 |
| 73 ~UsbDeviceImpl() override; | 70 ~UsbDeviceImpl() override; |
| 74 | 71 |
| 75 // Called only by UsbServiceImpl. | 72 // Called only by UsbServiceImpl. |
| 76 void set_visited(bool visited) { visited_ = visited; } | 73 void set_visited(bool visited) { visited_ = visited; } |
| 77 bool was_visited() const { return visited_; } | 74 bool was_visited() const { return visited_; } |
| 78 void OnDisconnect(); | 75 void OnDisconnect(); |
| 76 void set_configurations(); | |
| 79 | 77 |
| 80 // Called by UsbDeviceHandleImpl. | 78 // Called by UsbDeviceHandleImpl. |
| 81 void RefreshConfiguration(); | 79 void RefreshConfiguration(); |
| 82 | 80 |
| 83 private: | 81 private: |
| 82 void GetAllConfigurations(); | |
| 84 #if defined(OS_CHROMEOS) | 83 #if defined(OS_CHROMEOS) |
| 85 void OnOpenRequestComplete(const OpenCallback& callback, | 84 void OnOpenRequestComplete(const OpenCallback& callback, |
| 86 dbus::FileDescriptor fd); | 85 dbus::FileDescriptor fd); |
| 87 void OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd, | 86 void OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd, |
| 88 const OpenCallback& callback); | 87 const OpenCallback& callback); |
| 89 #endif | 88 #endif |
| 90 void OpenOnBlockingThread(const OpenCallback& callback); | 89 void OpenOnBlockingThread(const OpenCallback& callback); |
| 91 void Opened(PlatformUsbDeviceHandle platform_handle, | 90 void Opened(PlatformUsbDeviceHandle platform_handle, |
| 92 const OpenCallback& callback); | 91 const OpenCallback& callback); |
| 93 | 92 |
| 94 base::ThreadChecker thread_checker_; | 93 base::ThreadChecker thread_checker_; |
| 95 PlatformUsbDevice platform_device_; | 94 PlatformUsbDevice platform_device_; |
| 96 bool visited_ = false; | 95 bool visited_ = false; |
| 97 | 96 |
| 98 // On Chrome OS device path is necessary to request access from the permission | 97 // On Chrome OS device path is necessary to request access from the permission |
| 99 // broker. | 98 // broker. |
| 100 std::string device_path_; | 99 std::string device_path_; |
| 101 | 100 |
| 102 // The current device configuration descriptor. May be null if the device is | 101 // The current device configuration descriptor. May be null if the device is |
| 103 // in an unconfigured state. | 102 // in an unconfigured state. |
| 104 scoped_ptr<UsbConfigDescriptor> configuration_; | 103 const UsbConfigDescriptor* configuration_; |
|
Reilly Grant (use Gerrit)
2015/08/03 18:04:04
Maybe call this "active_configuration_" and docume
juncai
2015/08/03 21:56:25
Done.
| |
| 105 | 104 |
| 106 // Retain the context so that it will not be released before UsbDevice. | 105 // Retain the context so that it will not be released before UsbDevice. |
| 107 scoped_refptr<UsbContext> context_; | 106 scoped_refptr<UsbContext> context_; |
| 108 | 107 |
| 109 // Opened handles. | 108 // Opened handles. |
| 110 typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector; | 109 typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector; |
| 111 HandlesVector handles_; | 110 HandlesVector handles_; |
| 112 | 111 |
| 113 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 112 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 114 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 113 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| 115 | 114 |
| 116 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl); | 115 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl); |
| 117 }; | 116 }; |
| 118 | 117 |
| 119 } // namespace device | 118 } // namespace device |
| 120 | 119 |
| 121 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_ | 120 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_ |
| OLD | NEW |