OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 scoped_refptr<net::IOBuffer> data, | 57 scoped_refptr<net::IOBuffer> data, |
58 size_t length); | 58 size_t length); |
59 }; | 59 }; |
60 | 60 |
61 class UsbFindDevicesFunction : public UsbAsyncApiFunction { | 61 class UsbFindDevicesFunction : public UsbAsyncApiFunction { |
62 public: | 62 public: |
63 DECLARE_EXTENSION_FUNCTION("usb.findDevices", USB_FINDDEVICES) | 63 DECLARE_EXTENSION_FUNCTION("usb.findDevices", USB_FINDDEVICES) |
64 | 64 |
65 UsbFindDevicesFunction(); | 65 UsbFindDevicesFunction(); |
66 | 66 |
67 static void SetDeviceForTest(UsbDevice* device); | |
68 | |
69 protected: | 67 protected: |
70 virtual ~UsbFindDevicesFunction(); | 68 virtual ~UsbFindDevicesFunction(); |
71 | 69 |
72 virtual bool Prepare() OVERRIDE; | 70 virtual bool Prepare() OVERRIDE; |
73 virtual void AsyncWorkStart() OVERRIDE; | 71 virtual void AsyncWorkStart() OVERRIDE; |
74 | 72 |
75 private: | 73 private: |
76 void EnumerationCompletedFileThread( | 74 void EnumerationCompletedFileThread( |
77 scoped_ptr<std::vector<scoped_refptr<UsbDevice> > > devices); | 75 scoped_ptr<std::vector<scoped_refptr<UsbDevice> > > devices); |
78 | 76 |
79 // This should be run on the IO thread. | 77 // This should be run on the IO thread. |
80 // Create ApiResources and reply. | 78 // Create ApiResources and reply. |
81 void OnCompleted(); | 79 void OnCompleted(); |
82 | 80 |
83 scoped_ptr<base::ListValue> result_; | 81 scoped_ptr<base::ListValue> result_; |
84 std::vector<scoped_refptr<UsbDeviceHandle> > device_handles_; | 82 std::vector<scoped_refptr<UsbDeviceHandle> > device_handles_; |
85 scoped_ptr<extensions::api::usb::FindDevices::Params> parameters_; | 83 scoped_ptr<extensions::api::usb::FindDevices::Params> parameters_; |
86 }; | 84 }; |
87 | 85 |
86 class UsbGetDevicesFunction : public UsbAsyncApiFunction { | |
87 public: | |
88 DECLARE_EXTENSION_FUNCTION("usb.getDevices", USB_GETDEVICES) | |
89 | |
90 UsbGetDevicesFunction(); | |
91 | |
92 static void SetDeviceForTest(UsbDevice* device); | |
93 | |
94 virtual bool Prepare() OVERRIDE; | |
95 virtual void AsyncWorkStart() OVERRIDE; | |
96 | |
97 protected: | |
98 virtual ~UsbGetDevicesFunction(); | |
99 | |
100 private: | |
101 void EnumerationCompletedFileThread( | |
102 scoped_ptr<std::vector<scoped_refptr<UsbDevice> > > devices); | |
103 | |
104 scoped_ptr<base::ListValue> result_; | |
105 scoped_ptr<extensions::api::usb::GetDevices::Params> parameters_; | |
106 }; | |
107 | |
108 class UsbOpenDeviceFunction : public UsbAsyncApiFunction { | |
109 public: | |
110 DECLARE_EXTENSION_FUNCTION("usb.openDevice", USB_OPENDEVICE) | |
111 | |
112 UsbOpenDeviceFunction(); | |
113 | |
114 virtual bool Prepare() OVERRIDE; | |
115 virtual void AsyncWorkStart() OVERRIDE; | |
116 | |
117 protected: | |
118 virtual ~UsbOpenDeviceFunction(); | |
119 | |
120 private: | |
121 void OpenDeviceOnFile(); | |
122 | |
123 // This should be run on the IO thread. | |
124 // Create ApiResources and reply. | |
asargent_no_longer_on_chrome
2013/08/22 21:06:13
Does it actually create a UsbDeviceResource or som
Bei Zhang
2013/08/23 22:52:00
This is not needed since we simplified the threadi
| |
125 void OnCompleted(); | |
126 | |
127 scoped_refptr<UsbDeviceHandle> handle_; | |
128 scoped_ptr<extensions::api::usb::OpenDevice::Params> parameters_; | |
129 }; | |
130 | |
88 class UsbListInterfacesFunction : public UsbAsyncApiFunction { | 131 class UsbListInterfacesFunction : public UsbAsyncApiFunction { |
89 public: | 132 public: |
90 DECLARE_EXTENSION_FUNCTION("usb.listInterfaces", USB_LISTINTERFACES) | 133 DECLARE_EXTENSION_FUNCTION("usb.listInterfaces", USB_LISTINTERFACES) |
91 | 134 |
92 UsbListInterfacesFunction(); | 135 UsbListInterfacesFunction(); |
93 | 136 |
94 protected: | 137 protected: |
95 virtual ~UsbListInterfacesFunction(); | 138 virtual ~UsbListInterfacesFunction(); |
96 | 139 |
97 virtual bool Prepare() OVERRIDE; | 140 virtual bool Prepare() OVERRIDE; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 | 314 |
272 // This should be run on the IO thread. | 315 // This should be run on the IO thread. |
273 void OnCompleted(bool success); | 316 void OnCompleted(bool success); |
274 void OnError(); | 317 void OnError(); |
275 | 318 |
276 scoped_ptr<extensions::api::usb::ResetDevice::Params> parameters_; | 319 scoped_ptr<extensions::api::usb::ResetDevice::Params> parameters_; |
277 }; | 320 }; |
278 } // namespace extensions | 321 } // namespace extensions |
279 | 322 |
280 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_ | 323 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_ |
OLD | NEW |