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> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 public: | 32 public: |
33 // UsbDevice implementation: | 33 // UsbDevice implementation: |
34 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
35 virtual void RequestUsbAccess( | 35 virtual void RequestUsbAccess( |
36 int interface_id, | 36 int interface_id, |
37 const base::Callback<void(bool success)>& callback) OVERRIDE; | 37 const base::Callback<void(bool success)>& callback) OVERRIDE; |
38 #endif // OS_CHROMEOS | 38 #endif // OS_CHROMEOS |
39 virtual scoped_refptr<UsbDeviceHandle> Open() OVERRIDE; | 39 virtual scoped_refptr<UsbDeviceHandle> Open() OVERRIDE; |
40 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) OVERRIDE; | 40 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) OVERRIDE; |
41 virtual const UsbConfigDescriptor& GetConfiguration() OVERRIDE; | 41 virtual const UsbConfigDescriptor& GetConfiguration() OVERRIDE; |
| 42 virtual bool GetManufacturer(base::string16* manufacturer) OVERRIDE; |
| 43 virtual bool GetProduct(base::string16* product) OVERRIDE; |
| 44 virtual bool GetSerialNumber(base::string16* serial_number) OVERRIDE; |
42 | 45 |
43 protected: | 46 protected: |
44 friend class UsbServiceImpl; | 47 friend class UsbServiceImpl; |
45 | 48 |
46 // Called by UsbServiceImpl only; | 49 // Called by UsbServiceImpl only; |
47 UsbDeviceImpl(scoped_refptr<UsbContext> context, | 50 UsbDeviceImpl(scoped_refptr<UsbContext> context, |
48 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 51 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
49 PlatformUsbDevice platform_device, | 52 PlatformUsbDevice platform_device, |
50 uint16 vendor_id, | 53 uint16 vendor_id, |
51 uint16 product_id, | 54 uint16 product_id, |
52 uint32 unique_id); | 55 uint32 unique_id); |
53 | 56 |
54 virtual ~UsbDeviceImpl(); | 57 virtual ~UsbDeviceImpl(); |
55 | 58 |
56 // Called only be UsbService. | 59 // Called only be UsbService. |
57 void OnDisconnect(); | 60 void OnDisconnect(); |
58 | 61 |
59 private: | 62 private: |
60 base::ThreadChecker thread_checker_; | 63 base::ThreadChecker thread_checker_; |
61 PlatformUsbDevice platform_device_; | 64 PlatformUsbDevice platform_device_; |
62 | 65 |
| 66 #if defined(OS_LINUX) |
| 67 // On Linux these properties are read from sysfs when the device is enumerated |
| 68 // to avoid hitting the permission broker on Chrome OS for a real string |
| 69 // descriptor request. |
| 70 std::string manufacturer_; |
| 71 std::string product_; |
| 72 std::string serial_number_; |
| 73 #endif |
| 74 |
63 // The active configuration descriptor is not read immediately but cached for | 75 // The active configuration descriptor is not read immediately but cached for |
64 // later use. | 76 // later use. |
65 bool current_configuration_cached_; | 77 bool current_configuration_cached_; |
66 UsbConfigDescriptor current_configuration_; | 78 UsbConfigDescriptor current_configuration_; |
67 | 79 |
68 // Retain the context so that it will not be released before UsbDevice. | 80 // Retain the context so that it will not be released before UsbDevice. |
69 scoped_refptr<UsbContext> context_; | 81 scoped_refptr<UsbContext> context_; |
70 | 82 |
71 // Opened handles. | 83 // Opened handles. |
72 typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector; | 84 typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector; |
73 HandlesVector handles_; | 85 HandlesVector handles_; |
74 | 86 |
75 // Reference to the UI thread for permission-broker calls. | 87 // Reference to the UI thread for permission-broker calls. |
76 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 88 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
77 | 89 |
78 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl); | 90 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl); |
79 }; | 91 }; |
80 | 92 |
81 } // namespace device | 93 } // namespace device |
82 | 94 |
83 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_ | 95 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_ |
OLD | NEW |