Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: device/usb/usb_device_impl.h

Issue 826283002: Add support for sending a USB SET_CONFIGURATION request. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/usb/usb_device_handle_impl.cc ('k') | device/usb/usb_device_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 20 matching lines...) Expand all
31 class UsbDeviceImpl : public UsbDevice { 31 class UsbDeviceImpl : public UsbDevice {
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 scoped_refptr<UsbDeviceHandle> Open() override; 39 scoped_refptr<UsbDeviceHandle> Open() override;
40 bool Close(scoped_refptr<UsbDeviceHandle> handle) override; 40 bool Close(scoped_refptr<UsbDeviceHandle> handle) override;
41 const UsbConfigDescriptor& GetConfiguration() override; 41 const UsbConfigDescriptor* GetConfiguration() override;
42 bool GetManufacturer(base::string16* manufacturer) override; 42 bool GetManufacturer(base::string16* manufacturer) override;
43 bool GetProduct(base::string16* product) override; 43 bool GetProduct(base::string16* product) override;
44 bool GetSerialNumber(base::string16* serial_number) override; 44 bool GetSerialNumber(base::string16* serial_number) override;
45 45
46 protected: 46 protected:
47 friend class UsbServiceImpl; 47 friend class UsbServiceImpl;
48 friend class UsbDeviceHandleImpl;
48 49
49 // Called by UsbServiceImpl only; 50 // Called by UsbServiceImpl only;
50 UsbDeviceImpl(scoped_refptr<UsbContext> context, 51 UsbDeviceImpl(scoped_refptr<UsbContext> context,
51 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 52 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
52 PlatformUsbDevice platform_device, 53 PlatformUsbDevice platform_device,
53 uint16 vendor_id, 54 uint16 vendor_id,
54 uint16 product_id, 55 uint16 product_id,
55 uint32 unique_id); 56 uint32 unique_id);
56 57
57 ~UsbDeviceImpl() override; 58 ~UsbDeviceImpl() override;
58 59
59 // Called only by UsbService. 60 // Called only by UsbServiceImpl.
60 void OnDisconnect(); 61 void OnDisconnect();
61 62
63 // Called by UsbDeviceHandleImpl.
64 void RefreshConfiguration();
65
62 private: 66 private:
63 base::ThreadChecker thread_checker_; 67 base::ThreadChecker thread_checker_;
64 PlatformUsbDevice platform_device_; 68 PlatformUsbDevice platform_device_;
65 69
66 // On Linux these properties are read from sysfs when the device is enumerated 70 // On Linux these properties are read from sysfs when the device is enumerated
67 // to avoid hitting the permission broker on Chrome OS for a real string 71 // to avoid hitting the permission broker on Chrome OS for a real string
68 // descriptor request. 72 // descriptor request.
69 base::string16 manufacturer_; 73 base::string16 manufacturer_;
70 base::string16 product_; 74 base::string16 product_;
71 base::string16 serial_number_; 75 base::string16 serial_number_;
72 #if !defined(USE_UDEV) 76 #if !defined(USE_UDEV)
73 // On other platforms the device must be opened in order to cache them. This 77 // On other platforms the device must be opened in order to cache them. This
74 // should be delayed until the strings are needed to avoid poor interactions 78 // should be delayed until the strings are needed to avoid poor interactions
75 // with other applications. 79 // with other applications.
76 void CacheStrings(); 80 void CacheStrings();
77 bool strings_cached_; 81 bool strings_cached_;
78 #endif 82 #endif
79 #if defined(OS_CHROMEOS) 83 #if defined(OS_CHROMEOS)
80 // On Chrome OS save the devnode string for requesting path access from 84 // On Chrome OS save the devnode string for requesting path access from
81 // permission broker. 85 // permission broker.
82 std::string devnode_; 86 std::string devnode_;
83 #endif 87 #endif
84 88
85 // The active configuration descriptor is not read immediately but cached for 89 // The current device configuration descriptor. May be null if the device is
86 // later use. 90 // in an unconfigured state.
87 bool current_configuration_cached_; 91 scoped_ptr<UsbConfigDescriptor> configuration_;
88 UsbConfigDescriptor current_configuration_;
89 92
90 // Retain the context so that it will not be released before UsbDevice. 93 // Retain the context so that it will not be released before UsbDevice.
91 scoped_refptr<UsbContext> context_; 94 scoped_refptr<UsbContext> context_;
92 95
93 // Opened handles. 96 // Opened handles.
94 typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector; 97 typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector;
95 HandlesVector handles_; 98 HandlesVector handles_;
96 99
97 // Reference to the UI thread for permission-broker calls. 100 // Reference to the UI thread for permission-broker calls.
98 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 101 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
99 102
100 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl); 103 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl);
101 }; 104 };
102 105
103 } // namespace device 106 } // namespace device
104 107
105 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_ 108 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_
OLDNEW
« no previous file with comments | « device/usb/usb_device_handle_impl.cc ('k') | device/usb/usb_device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698