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

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: Fixed bug found with manual test Created 7 years, 7 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 UsbEndpointDirection* output);
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
58 class UsbFindDevicesFunction : public UsbAsyncApiFunction { 58 class UsbFindDevicesFunction : public UsbAsyncApiFunction {
59 public: 59 public:
(...skipping 10 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 protected:
87 virtual ~UsbListInterfacesFunction();
88
89 virtual bool Prepare() OVERRIDE;
90 virtual void AsyncWorkStart() OVERRIDE;
91
92 private:
93 void OnCompleted(bool success);
94
95 bool ConvertDirectionSafely(const UsbEndpointDirection& input,
96 extensions::api::usb::Direction* output);
97 bool ConvertSynchronizationTypeSafely(
98 const UsbSynchronizationType& input,
99 extensions::api::usb::SynchronizationType* output);
100 bool ConvertTransferTypeSafely(const UsbTransferType& input,
101 extensions::api::usb::TransferType* output);
102 bool ConvertUsageTypeSafely(const UsbUsageType& input,
103 extensions::api::usb::UsageType* output);
104
105 scoped_ptr<base::ListValue> result_;
106 scoped_refptr<UsbConfigDescriptor> config_;
107 scoped_ptr<extensions::api::usb::ListInterfaces::Params> parameters_;
108 };
109
80 class UsbCloseDeviceFunction : public UsbAsyncApiFunction { 110 class UsbCloseDeviceFunction : public UsbAsyncApiFunction {
81 public: 111 public:
82 DECLARE_EXTENSION_FUNCTION("usb.closeDevice", USB_CLOSEDEVICE) 112 DECLARE_EXTENSION_FUNCTION("usb.closeDevice", USB_CLOSEDEVICE)
83 113
84 UsbCloseDeviceFunction(); 114 UsbCloseDeviceFunction();
85 115
86 protected: 116 protected:
87 virtual ~UsbCloseDeviceFunction(); 117 virtual ~UsbCloseDeviceFunction();
88 118
89 virtual bool Prepare() OVERRIDE; 119 virtual bool Prepare() OVERRIDE;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 264
235 // IO thread. 265 // IO thread.
236 void OnCompleted(bool success); 266 void OnCompleted(bool success);
237 void OnError(); 267 void OnError();
238 268
239 scoped_ptr<extensions::api::usb::ResetDevice::Params> parameters_; 269 scoped_ptr<extensions::api::usb::ResetDevice::Params> parameters_;
240 }; 270 };
241 } // namespace extensions 271 } // namespace extensions
242 272
243 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_ 273 #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