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

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

Issue 22914023: Introducing chrome.usb.getDevices/openDevice API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-interface
Patch Set: Fix IDL Created 7 years, 3 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
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 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/extensions/api/api_function.h" 13 #include "chrome/browser/extensions/api/api_function.h"
13 #include "chrome/browser/extensions/api/api_resource_manager.h" 14 #include "chrome/browser/extensions/api/api_resource_manager.h"
14 #include "chrome/browser/usb/usb_device.h" 15 #include "chrome/browser/usb/usb_device.h"
15 #include "chrome/browser/usb/usb_device_handle.h" 16 #include "chrome/browser/usb/usb_device_handle.h"
16 #include "chrome/common/extensions/api/usb.h" 17 #include "chrome/common/extensions/api/usb.h"
17 #include "net/base/io_buffer.h" 18 #include "net/base/io_buffer.h"
18 19
19 class UsbDeviceHandle; 20 class UsbDeviceHandle;
20 class UsbService; 21 class UsbService;
21 22
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 scoped_refptr<net::IOBuffer> data, 58 scoped_refptr<net::IOBuffer> data,
58 size_t length); 59 size_t length);
59 }; 60 };
60 61
61 class UsbFindDevicesFunction : public UsbAsyncApiFunction { 62 class UsbFindDevicesFunction : public UsbAsyncApiFunction {
62 public: 63 public:
63 DECLARE_EXTENSION_FUNCTION("usb.findDevices", USB_FINDDEVICES) 64 DECLARE_EXTENSION_FUNCTION("usb.findDevices", USB_FINDDEVICES)
64 65
65 UsbFindDevicesFunction(); 66 UsbFindDevicesFunction();
66 67
67 static void SetDeviceForTest(UsbDevice* device);
68
69 protected: 68 protected:
70 virtual ~UsbFindDevicesFunction(); 69 virtual ~UsbFindDevicesFunction();
71 70
72 virtual bool Prepare() OVERRIDE; 71 virtual bool Prepare() OVERRIDE;
73 virtual void AsyncWorkStart() OVERRIDE; 72 virtual void AsyncWorkStart() OVERRIDE;
74 73
75 private: 74 private:
76 void EnumerationCompletedFileThread( 75 void EnumerationCompletedFileThread(
77 scoped_ptr<std::vector<scoped_refptr<UsbDevice> > > devices); 76 scoped_ptr<std::vector<scoped_refptr<UsbDevice> > > devices);
78 77
79 scoped_ptr<base::ListValue> result_; 78 scoped_ptr<base::ListValue> result_;
80 std::vector<scoped_refptr<UsbDeviceHandle> > device_handles_; 79 std::vector<scoped_refptr<UsbDeviceHandle> > device_handles_;
81 scoped_ptr<extensions::api::usb::FindDevices::Params> parameters_; 80 scoped_ptr<extensions::api::usb::FindDevices::Params> parameters_;
82 }; 81 };
83 82
83 class UsbGetDevicesFunction : public UsbAsyncApiFunction {
84 public:
85 DECLARE_EXTENSION_FUNCTION("usb.getDevices", USB_GETDEVICES)
86
87 UsbGetDevicesFunction();
88
89 static void SetDeviceForTest(UsbDevice* device);
90
91 virtual bool Prepare() OVERRIDE;
92 virtual void AsyncWorkStart() OVERRIDE;
93
94 protected:
95 virtual ~UsbGetDevicesFunction();
96
97 private:
98 void EnumerationCompletedFileThread(
99 scoped_ptr<std::vector<scoped_refptr<UsbDevice> > > devices);
100
101 scoped_ptr<base::ListValue> result_;
102 scoped_ptr<extensions::api::usb::GetDevices::Params> parameters_;
103 };
104
105 class UsbOpenDeviceFunction : public UsbAsyncApiFunction {
106 public:
107 DECLARE_EXTENSION_FUNCTION("usb.openDevice", USB_OPENDEVICE)
108
109 UsbOpenDeviceFunction();
110
111 virtual bool Prepare() OVERRIDE;
112 virtual void AsyncWorkStart() OVERRIDE;
113
114 protected:
115 virtual ~UsbOpenDeviceFunction();
116
117 private:
118 scoped_refptr<UsbDeviceHandle> handle_;
119 scoped_ptr<extensions::api::usb::OpenDevice::Params> parameters_;
120 };
121
84 class UsbListInterfacesFunction : public UsbAsyncApiFunction { 122 class UsbListInterfacesFunction : public UsbAsyncApiFunction {
85 public: 123 public:
86 DECLARE_EXTENSION_FUNCTION("usb.listInterfaces", USB_LISTINTERFACES) 124 DECLARE_EXTENSION_FUNCTION("usb.listInterfaces", USB_LISTINTERFACES)
87 125
88 UsbListInterfacesFunction(); 126 UsbListInterfacesFunction();
89 127
90 protected: 128 protected:
91 virtual ~UsbListInterfacesFunction(); 129 virtual ~UsbListInterfacesFunction();
92 130
93 virtual bool Prepare() OVERRIDE; 131 virtual bool Prepare() OVERRIDE;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 287
250 virtual bool Prepare() OVERRIDE; 288 virtual bool Prepare() OVERRIDE;
251 virtual void AsyncWorkStart() OVERRIDE; 289 virtual void AsyncWorkStart() OVERRIDE;
252 290
253 private: 291 private:
254 scoped_ptr<extensions::api::usb::ResetDevice::Params> parameters_; 292 scoped_ptr<extensions::api::usb::ResetDevice::Params> parameters_;
255 }; 293 };
256 } // namespace extensions 294 } // namespace extensions
257 295
258 #endif // CHROME_BROWSER_EXTENSIONS_API_USB_USB_API_H_ 296 #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/common/extensions/api/usb.idl » ('J')

Powered by Google App Engine
This is Rietveld 408576698