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 scoped_ptr<base::ListValue> result_; | 77 scoped_ptr<base::ListValue> result_; |
80 std::vector<scoped_refptr<UsbDeviceHandle> > device_handles_; | 78 std::vector<scoped_refptr<UsbDeviceHandle> > device_handles_; |
81 scoped_ptr<extensions::api::usb::FindDevices::Params> parameters_; | 79 scoped_ptr<extensions::api::usb::FindDevices::Params> parameters_; |
82 }; | 80 }; |
83 | 81 |
| 82 class UsbGetDevicesFunction : public UsbAsyncApiFunction { |
| 83 public: |
| 84 DECLARE_EXTENSION_FUNCTION("usb.getDevices", USB_GETDEVICES) |
| 85 |
| 86 UsbGetDevicesFunction(); |
| 87 |
| 88 static void SetDeviceForTest(UsbDevice* device); |
| 89 |
| 90 virtual bool Prepare() OVERRIDE; |
| 91 virtual void AsyncWorkStart() OVERRIDE; |
| 92 |
| 93 protected: |
| 94 virtual ~UsbGetDevicesFunction(); |
| 95 |
| 96 private: |
| 97 void EnumerationCompletedFileThread( |
| 98 scoped_ptr<std::vector<scoped_refptr<UsbDevice> > > devices); |
| 99 |
| 100 scoped_ptr<base::ListValue> result_; |
| 101 scoped_ptr<extensions::api::usb::GetDevices::Params> parameters_; |
| 102 }; |
| 103 |
| 104 class UsbOpenDeviceFunction : public UsbAsyncApiFunction { |
| 105 public: |
| 106 DECLARE_EXTENSION_FUNCTION("usb.openDevice", USB_OPENDEVICE) |
| 107 |
| 108 UsbOpenDeviceFunction(); |
| 109 |
| 110 virtual bool Prepare() OVERRIDE; |
| 111 virtual void AsyncWorkStart() OVERRIDE; |
| 112 |
| 113 protected: |
| 114 virtual ~UsbOpenDeviceFunction(); |
| 115 |
| 116 private: |
| 117 scoped_refptr<UsbDeviceHandle> handle_; |
| 118 scoped_ptr<extensions::api::usb::OpenDevice::Params> parameters_; |
| 119 }; |
| 120 |
84 class UsbListInterfacesFunction : public UsbAsyncApiFunction { | 121 class UsbListInterfacesFunction : public UsbAsyncApiFunction { |
85 public: | 122 public: |
86 DECLARE_EXTENSION_FUNCTION("usb.listInterfaces", USB_LISTINTERFACES) | 123 DECLARE_EXTENSION_FUNCTION("usb.listInterfaces", USB_LISTINTERFACES) |
87 | 124 |
88 UsbListInterfacesFunction(); | 125 UsbListInterfacesFunction(); |
89 | 126 |
90 protected: | 127 protected: |
91 virtual ~UsbListInterfacesFunction(); | 128 virtual ~UsbListInterfacesFunction(); |
92 | 129 |
93 virtual bool Prepare() OVERRIDE; | 130 virtual bool Prepare() OVERRIDE; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 286 |
250 virtual bool Prepare() OVERRIDE; | 287 virtual bool Prepare() OVERRIDE; |
251 virtual void AsyncWorkStart() OVERRIDE; | 288 virtual void AsyncWorkStart() OVERRIDE; |
252 | 289 |
253 private: | 290 private: |
254 scoped_ptr<extensions::api::usb::ResetDevice::Params> parameters_; | 291 scoped_ptr<extensions::api::usb::ResetDevice::Params> parameters_; |
255 }; | 292 }; |
256 } // namespace extensions | 293 } // namespace extensions |
257 | 294 |
258 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_ | 295 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_ |
OLD | NEW |