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

Side by Side Diff: chrome/browser/extensions/api/usb/usb_api.h

Issue 12471013: Add chrome.usb.listInterfaces API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
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 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 26 matching lines...) Expand all
37 37
38 ApiResourceManager<UsbDeviceResource>* manager_; 38 ApiResourceManager<UsbDeviceResource>* manager_;
39 }; 39 };
40 40
41 class UsbAsyncApiTransferFunction : public UsbAsyncApiFunction { 41 class UsbAsyncApiTransferFunction : public UsbAsyncApiFunction {
42 protected: 42 protected:
43 UsbAsyncApiTransferFunction(); 43 UsbAsyncApiTransferFunction();
44 virtual ~UsbAsyncApiTransferFunction(); 44 virtual ~UsbAsyncApiTransferFunction();
45 45
46 bool ConvertDirectionSafely(const extensions::api::usb::Direction& input, 46 bool ConvertDirectionSafely(const extensions::api::usb::Direction& input,
47 UsbDevice::TransferDirection* output); 47 UsbInterfaceDirection* output);
Bei Zhang 2013/04/26 22:38:01 I think direction is not a property of USB interfa
Kenny Root (Google) 2013/05/08 01:15:08 Done.
48 bool ConvertRequestTypeSafely(const extensions::api::usb::RequestType& input, 48 bool ConvertRequestTypeSafely(const extensions::api::usb::RequestType& input,
49 UsbDevice::TransferRequestType* output); 49 UsbDevice::TransferRequestType* output);
50 bool ConvertRecipientSafely(const extensions::api::usb::Recipient& input, 50 bool ConvertRecipientSafely(const extensions::api::usb::Recipient& input,
51 UsbDevice::TransferRecipient* output); 51 UsbDevice::TransferRecipient* output);
52 52
53 void OnCompleted(UsbTransferStatus status, 53 void OnCompleted(UsbTransferStatus status,
54 scoped_refptr<net::IOBuffer> data, 54 scoped_refptr<net::IOBuffer> data,
55 size_t length); 55 size_t length);
56 }; 56 };
57 57
(...skipping 12 matching lines...) Expand all
70 virtual void AsyncWorkStart() OVERRIDE; 70 virtual void AsyncWorkStart() OVERRIDE;
71 71
72 private: 72 private:
73 void OnCompleted(); 73 void OnCompleted();
74 74
75 scoped_ptr<base::ListValue> result_; 75 scoped_ptr<base::ListValue> result_;
76 std::vector<scoped_refptr<UsbDevice> > devices_; 76 std::vector<scoped_refptr<UsbDevice> > devices_;
77 scoped_ptr<extensions::api::usb::FindDevices::Params> parameters_; 77 scoped_ptr<extensions::api::usb::FindDevices::Params> parameters_;
78 }; 78 };
79 79
80 class UsbListInterfacesFunction : public UsbAsyncApiFunction {
81 public:
82 DECLARE_EXTENSION_FUNCTION("usb.listInterfaces", USB_LISTINTERFACES)
83
84 UsbListInterfacesFunction();
85
86 static void SetDeviceForTest(UsbDevice* device);
87
88 protected:
89 virtual ~UsbListInterfacesFunction();
90
91 virtual bool Prepare() OVERRIDE;
92 virtual void AsyncWorkStart() OVERRIDE;
93
94 private:
95 void OnCompleted(bool success);
96
97 bool ConvertDirectionSafely(const UsbInterfaceDirection& input,
98 extensions::api::usb::Direction* output);
99 bool ConvertEndpointTypeSafely(const UsbEndpointType& input,
100 extensions::api::usb::EndpointType* output);
101 bool ConvertSynchronizationTypeSafely(
102 const UsbSynchronizationType& input,
103 extensions::api::usb::SynchronizationType* output);
104 bool ConvertUsageTypeSafely(const UsbUsageType& input,
105 extensions::api::usb::UsageType* output);
106
107 scoped_ptr<base::ListValue> result_;
108 scoped_refptr<UsbConfigDescriptor> config_;
109 scoped_ptr<extensions::api::usb::ListInterfaces::Params> parameters_;
110 };
111
80 class UsbCloseDeviceFunction : public UsbAsyncApiFunction { 112 class UsbCloseDeviceFunction : public UsbAsyncApiFunction {
81 public: 113 public:
82 DECLARE_EXTENSION_FUNCTION("usb.closeDevice", USB_CLOSEDEVICE) 114 DECLARE_EXTENSION_FUNCTION("usb.closeDevice", USB_CLOSEDEVICE)
83 115
84 UsbCloseDeviceFunction(); 116 UsbCloseDeviceFunction();
85 117
86 protected: 118 protected:
87 virtual ~UsbCloseDeviceFunction(); 119 virtual ~UsbCloseDeviceFunction();
88 120
89 virtual bool Prepare() OVERRIDE; 121 virtual bool Prepare() OVERRIDE;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 virtual bool Prepare() OVERRIDE; 243 virtual bool Prepare() OVERRIDE;
212 virtual void AsyncWorkStart() OVERRIDE; 244 virtual void AsyncWorkStart() OVERRIDE;
213 245
214 private: 246 private:
215 scoped_ptr<extensions::api::usb::IsochronousTransfer::Params> parameters_; 247 scoped_ptr<extensions::api::usb::IsochronousTransfer::Params> parameters_;
216 }; 248 };
217 249
218 } // namespace extensions 250 } // namespace extensions
219 251
220 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_ 252 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/usb/usb_api.cc » ('j') | chrome/browser/extensions/api/usb/usb_api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698