OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_HID_HID_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_HID_HID_API_H_ |
6 #define EXTENSIONS_BROWSER_API_HID_HID_API_H_ | 6 #define EXTENSIONS_BROWSER_API_HID_HID_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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "extensions/browser/api/api_resource_manager.h" | 12 #include "extensions/browser/api/api_resource_manager.h" |
13 #include "extensions/browser/api/async_api_function.h" | 13 #include "extensions/browser/api/async_api_function.h" |
14 #include "extensions/browser/api/hid/hid_connection_resource.h" | 14 #include "extensions/browser/api/hid/hid_connection_resource.h" |
15 #include "extensions/browser/api/hid/hid_device_manager.h" | 15 #include "extensions/browser/api/hid/hid_device_manager.h" |
16 #include "extensions/common/api/hid.h" | 16 #include "extensions/common/api/hid.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 class IOBuffer; | 19 class IOBuffer; |
20 } // namespace net | 20 } // namespace net |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 class HidAsyncApiFunction : public AsyncApiFunction { | 24 class HidAsyncApiFunction : public AsyncApiFunction { |
25 public: | 25 public: |
26 HidAsyncApiFunction(); | 26 HidAsyncApiFunction(); |
27 | 27 |
28 virtual bool PrePrepare() OVERRIDE; | 28 virtual bool PrePrepare() override; |
29 virtual bool Respond() OVERRIDE; | 29 virtual bool Respond() override; |
30 | 30 |
31 protected: | 31 protected: |
32 virtual ~HidAsyncApiFunction(); | 32 virtual ~HidAsyncApiFunction(); |
33 | 33 |
34 HidConnectionResource* GetHidConnectionResource(int api_resource_id); | 34 HidConnectionResource* GetHidConnectionResource(int api_resource_id); |
35 void RemoveHidConnectionResource(int api_resource_id); | 35 void RemoveHidConnectionResource(int api_resource_id); |
36 | 36 |
37 void CompleteWithError(const std::string& error); | 37 void CompleteWithError(const std::string& error); |
38 | 38 |
39 HidDeviceManager* device_manager_; | 39 HidDeviceManager* device_manager_; |
40 ApiResourceManager<HidConnectionResource>* connection_manager_; | 40 ApiResourceManager<HidConnectionResource>* connection_manager_; |
41 | 41 |
42 private: | 42 private: |
43 DISALLOW_COPY_AND_ASSIGN(HidAsyncApiFunction); | 43 DISALLOW_COPY_AND_ASSIGN(HidAsyncApiFunction); |
44 }; | 44 }; |
45 | 45 |
46 class HidGetDevicesFunction : public HidAsyncApiFunction { | 46 class HidGetDevicesFunction : public HidAsyncApiFunction { |
47 public: | 47 public: |
48 DECLARE_EXTENSION_FUNCTION("hid.getDevices", HID_GETDEVICES); | 48 DECLARE_EXTENSION_FUNCTION("hid.getDevices", HID_GETDEVICES); |
49 | 49 |
50 HidGetDevicesFunction(); | 50 HidGetDevicesFunction(); |
51 | 51 |
52 protected: | 52 protected: |
53 virtual bool Prepare() OVERRIDE; | 53 virtual bool Prepare() override; |
54 virtual void AsyncWorkStart() OVERRIDE; | 54 virtual void AsyncWorkStart() override; |
55 | 55 |
56 virtual ~HidGetDevicesFunction(); | 56 virtual ~HidGetDevicesFunction(); |
57 | 57 |
58 scoped_ptr<core_api::hid::GetDevices::Params> parameters_; | 58 scoped_ptr<core_api::hid::GetDevices::Params> parameters_; |
59 | 59 |
60 private: | 60 private: |
61 DISALLOW_COPY_AND_ASSIGN(HidGetDevicesFunction); | 61 DISALLOW_COPY_AND_ASSIGN(HidGetDevicesFunction); |
62 }; | 62 }; |
63 | 63 |
64 class HidConnectFunction : public HidAsyncApiFunction { | 64 class HidConnectFunction : public HidAsyncApiFunction { |
65 public: | 65 public: |
66 DECLARE_EXTENSION_FUNCTION("hid.connect", HID_CONNECT); | 66 DECLARE_EXTENSION_FUNCTION("hid.connect", HID_CONNECT); |
67 | 67 |
68 HidConnectFunction(); | 68 HidConnectFunction(); |
69 | 69 |
70 protected: | 70 protected: |
71 virtual bool Prepare() OVERRIDE; | 71 virtual bool Prepare() override; |
72 virtual void AsyncWorkStart() OVERRIDE; | 72 virtual void AsyncWorkStart() override; |
73 | 73 |
74 private: | 74 private: |
75 virtual ~HidConnectFunction(); | 75 virtual ~HidConnectFunction(); |
76 | 76 |
77 scoped_ptr<core_api::hid::Connect::Params> parameters_; | 77 scoped_ptr<core_api::hid::Connect::Params> parameters_; |
78 | 78 |
79 DISALLOW_COPY_AND_ASSIGN(HidConnectFunction); | 79 DISALLOW_COPY_AND_ASSIGN(HidConnectFunction); |
80 }; | 80 }; |
81 | 81 |
82 class HidDisconnectFunction : public HidAsyncApiFunction { | 82 class HidDisconnectFunction : public HidAsyncApiFunction { |
83 public: | 83 public: |
84 DECLARE_EXTENSION_FUNCTION("hid.disconnect", HID_DISCONNECT); | 84 DECLARE_EXTENSION_FUNCTION("hid.disconnect", HID_DISCONNECT); |
85 | 85 |
86 HidDisconnectFunction(); | 86 HidDisconnectFunction(); |
87 | 87 |
88 protected: | 88 protected: |
89 virtual bool Prepare() OVERRIDE; | 89 virtual bool Prepare() override; |
90 virtual void AsyncWorkStart() OVERRIDE; | 90 virtual void AsyncWorkStart() override; |
91 | 91 |
92 private: | 92 private: |
93 virtual ~HidDisconnectFunction(); | 93 virtual ~HidDisconnectFunction(); |
94 | 94 |
95 scoped_ptr<core_api::hid::Disconnect::Params> parameters_; | 95 scoped_ptr<core_api::hid::Disconnect::Params> parameters_; |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(HidDisconnectFunction); | 97 DISALLOW_COPY_AND_ASSIGN(HidDisconnectFunction); |
98 }; | 98 }; |
99 | 99 |
100 class HidReceiveFunction : public HidAsyncApiFunction { | 100 class HidReceiveFunction : public HidAsyncApiFunction { |
101 public: | 101 public: |
102 DECLARE_EXTENSION_FUNCTION("hid.receive", HID_RECEIVE); | 102 DECLARE_EXTENSION_FUNCTION("hid.receive", HID_RECEIVE); |
103 | 103 |
104 HidReceiveFunction(); | 104 HidReceiveFunction(); |
105 | 105 |
106 protected: | 106 protected: |
107 virtual bool Prepare() OVERRIDE; | 107 virtual bool Prepare() override; |
108 virtual void AsyncWorkStart() OVERRIDE; | 108 virtual void AsyncWorkStart() override; |
109 | 109 |
110 private: | 110 private: |
111 virtual ~HidReceiveFunction(); | 111 virtual ~HidReceiveFunction(); |
112 | 112 |
113 void OnFinished(bool success, | 113 void OnFinished(bool success, |
114 scoped_refptr<net::IOBuffer> buffer, | 114 scoped_refptr<net::IOBuffer> buffer, |
115 size_t size); | 115 size_t size); |
116 | 116 |
117 scoped_ptr<core_api::hid::Receive::Params> parameters_; | 117 scoped_ptr<core_api::hid::Receive::Params> parameters_; |
118 | 118 |
119 DISALLOW_COPY_AND_ASSIGN(HidReceiveFunction); | 119 DISALLOW_COPY_AND_ASSIGN(HidReceiveFunction); |
120 }; | 120 }; |
121 | 121 |
122 class HidSendFunction : public HidAsyncApiFunction { | 122 class HidSendFunction : public HidAsyncApiFunction { |
123 public: | 123 public: |
124 DECLARE_EXTENSION_FUNCTION("hid.send", HID_SEND); | 124 DECLARE_EXTENSION_FUNCTION("hid.send", HID_SEND); |
125 | 125 |
126 HidSendFunction(); | 126 HidSendFunction(); |
127 | 127 |
128 protected: | 128 protected: |
129 virtual bool Prepare() OVERRIDE; | 129 virtual bool Prepare() override; |
130 virtual void AsyncWorkStart() OVERRIDE; | 130 virtual void AsyncWorkStart() override; |
131 | 131 |
132 private: | 132 private: |
133 virtual ~HidSendFunction(); | 133 virtual ~HidSendFunction(); |
134 | 134 |
135 void OnFinished(bool success); | 135 void OnFinished(bool success); |
136 | 136 |
137 scoped_ptr<core_api::hid::Send::Params> parameters_; | 137 scoped_ptr<core_api::hid::Send::Params> parameters_; |
138 | 138 |
139 DISALLOW_COPY_AND_ASSIGN(HidSendFunction); | 139 DISALLOW_COPY_AND_ASSIGN(HidSendFunction); |
140 }; | 140 }; |
141 | 141 |
142 class HidReceiveFeatureReportFunction : public HidAsyncApiFunction { | 142 class HidReceiveFeatureReportFunction : public HidAsyncApiFunction { |
143 public: | 143 public: |
144 DECLARE_EXTENSION_FUNCTION("hid.receiveFeatureReport", | 144 DECLARE_EXTENSION_FUNCTION("hid.receiveFeatureReport", |
145 HID_RECEIVEFEATUREREPORT); | 145 HID_RECEIVEFEATUREREPORT); |
146 | 146 |
147 HidReceiveFeatureReportFunction(); | 147 HidReceiveFeatureReportFunction(); |
148 | 148 |
149 protected: | 149 protected: |
150 virtual bool Prepare() OVERRIDE; | 150 virtual bool Prepare() override; |
151 virtual void AsyncWorkStart() OVERRIDE; | 151 virtual void AsyncWorkStart() override; |
152 | 152 |
153 private: | 153 private: |
154 virtual ~HidReceiveFeatureReportFunction(); | 154 virtual ~HidReceiveFeatureReportFunction(); |
155 | 155 |
156 void OnFinished(bool success, | 156 void OnFinished(bool success, |
157 scoped_refptr<net::IOBuffer> buffer, | 157 scoped_refptr<net::IOBuffer> buffer, |
158 size_t size); | 158 size_t size); |
159 | 159 |
160 scoped_ptr<core_api::hid::ReceiveFeatureReport::Params> parameters_; | 160 scoped_ptr<core_api::hid::ReceiveFeatureReport::Params> parameters_; |
161 | 161 |
162 DISALLOW_COPY_AND_ASSIGN(HidReceiveFeatureReportFunction); | 162 DISALLOW_COPY_AND_ASSIGN(HidReceiveFeatureReportFunction); |
163 }; | 163 }; |
164 | 164 |
165 class HidSendFeatureReportFunction : public HidAsyncApiFunction { | 165 class HidSendFeatureReportFunction : public HidAsyncApiFunction { |
166 public: | 166 public: |
167 DECLARE_EXTENSION_FUNCTION("hid.sendFeatureReport", HID_SENDFEATUREREPORT); | 167 DECLARE_EXTENSION_FUNCTION("hid.sendFeatureReport", HID_SENDFEATUREREPORT); |
168 | 168 |
169 HidSendFeatureReportFunction(); | 169 HidSendFeatureReportFunction(); |
170 | 170 |
171 protected: | 171 protected: |
172 virtual bool Prepare() OVERRIDE; | 172 virtual bool Prepare() override; |
173 virtual void AsyncWorkStart() OVERRIDE; | 173 virtual void AsyncWorkStart() override; |
174 | 174 |
175 private: | 175 private: |
176 virtual ~HidSendFeatureReportFunction(); | 176 virtual ~HidSendFeatureReportFunction(); |
177 | 177 |
178 void OnFinished(bool success); | 178 void OnFinished(bool success); |
179 | 179 |
180 scoped_ptr<core_api::hid::SendFeatureReport::Params> parameters_; | 180 scoped_ptr<core_api::hid::SendFeatureReport::Params> parameters_; |
181 | 181 |
182 DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction); | 182 DISALLOW_COPY_AND_ASSIGN(HidSendFeatureReportFunction); |
183 }; | 183 }; |
184 | 184 |
185 } // namespace extensions | 185 } // namespace extensions |
186 | 186 |
187 #endif // EXTENSIONS_BROWSER_API_HID_HID_API_H_ | 187 #endif // EXTENSIONS_BROWSER_API_HID_HID_API_H_ |
OLD | NEW |