Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / extensions / browser / api / sockets_udp / sockets_udp_api.h
blob16e61d43c3dd04c8b7252f86c7de450a1a3cd2cd
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_API_SOCKETS_UDP_SOCKETS_UDP_API_H_
6 #define EXTENSIONS_BROWSER_API_SOCKETS_UDP_SOCKETS_UDP_API_H_
8 #include "extensions/browser/api/socket/socket_api.h"
9 #include "extensions/common/api/sockets_udp.h"
11 namespace extensions {
12 class ResumableUDPSocket;
15 namespace extensions {
16 namespace core_api {
18 class UDPSocketEventDispatcher;
20 class UDPSocketAsyncApiFunction : public SocketAsyncApiFunction {
21 protected:
22 virtual ~UDPSocketAsyncApiFunction();
24 virtual scoped_ptr<SocketResourceManagerInterface>
25 CreateSocketResourceManager() OVERRIDE;
27 ResumableUDPSocket* GetUdpSocket(int socket_id);
30 class UDPSocketExtensionWithDnsLookupFunction
31 : public SocketExtensionWithDnsLookupFunction {
32 protected:
33 virtual ~UDPSocketExtensionWithDnsLookupFunction();
35 virtual scoped_ptr<SocketResourceManagerInterface>
36 CreateSocketResourceManager() OVERRIDE;
38 ResumableUDPSocket* GetUdpSocket(int socket_id);
41 class SocketsUdpCreateFunction : public UDPSocketAsyncApiFunction {
42 public:
43 DECLARE_EXTENSION_FUNCTION("sockets.udp.create", SOCKETS_UDP_CREATE)
45 SocketsUdpCreateFunction();
47 protected:
48 virtual ~SocketsUdpCreateFunction();
50 // AsyncApiFunction:
51 virtual bool Prepare() OVERRIDE;
52 virtual void Work() OVERRIDE;
54 private:
55 FRIEND_TEST_ALL_PREFIXES(SocketsUdpUnitTest, Create);
56 scoped_ptr<sockets_udp::Create::Params> params_;
59 class SocketsUdpUpdateFunction : public UDPSocketAsyncApiFunction {
60 public:
61 DECLARE_EXTENSION_FUNCTION("sockets.udp.update", SOCKETS_UDP_UPDATE)
63 SocketsUdpUpdateFunction();
65 protected:
66 virtual ~SocketsUdpUpdateFunction();
68 // AsyncApiFunction:
69 virtual bool Prepare() OVERRIDE;
70 virtual void Work() OVERRIDE;
72 private:
73 scoped_ptr<sockets_udp::Update::Params> params_;
76 class SocketsUdpSetPausedFunction : public UDPSocketAsyncApiFunction {
77 public:
78 DECLARE_EXTENSION_FUNCTION("sockets.udp.setPaused", SOCKETS_UDP_SETPAUSED)
80 SocketsUdpSetPausedFunction();
82 protected:
83 virtual ~SocketsUdpSetPausedFunction();
85 // AsyncApiFunction
86 virtual bool Prepare() OVERRIDE;
87 virtual void Work() OVERRIDE;
89 private:
90 scoped_ptr<sockets_udp::SetPaused::Params> params_;
91 UDPSocketEventDispatcher* socket_event_dispatcher_;
94 class SocketsUdpBindFunction : public UDPSocketAsyncApiFunction {
95 public:
96 DECLARE_EXTENSION_FUNCTION("sockets.udp.bind", SOCKETS_UDP_BIND)
98 SocketsUdpBindFunction();
100 protected:
101 virtual ~SocketsUdpBindFunction();
103 // AsyncApiFunction:
104 virtual bool Prepare() OVERRIDE;
105 virtual void Work() OVERRIDE;
107 private:
108 scoped_ptr<sockets_udp::Bind::Params> params_;
109 UDPSocketEventDispatcher* socket_event_dispatcher_;
112 class SocketsUdpSendFunction : public UDPSocketExtensionWithDnsLookupFunction {
113 public:
114 DECLARE_EXTENSION_FUNCTION("sockets.udp.send", SOCKETS_UDP_SEND)
116 SocketsUdpSendFunction();
118 protected:
119 virtual ~SocketsUdpSendFunction();
121 // AsyncApiFunction:
122 virtual bool Prepare() OVERRIDE;
123 virtual void AsyncWorkStart() OVERRIDE;
124 void OnCompleted(int net_result);
125 void SetSendResult(int net_result, int bytes_sent);
127 // SocketExtensionWithDnsLookupFunction:
128 virtual void AfterDnsLookup(int lookup_result) OVERRIDE;
130 private:
131 void StartSendTo();
133 scoped_ptr<sockets_udp::Send::Params> params_;
134 scoped_refptr<net::IOBuffer> io_buffer_;
135 size_t io_buffer_size_;
138 class SocketsUdpCloseFunction : public UDPSocketAsyncApiFunction {
139 public:
140 DECLARE_EXTENSION_FUNCTION("sockets.udp.close", SOCKETS_UDP_CLOSE)
142 SocketsUdpCloseFunction();
144 protected:
145 virtual ~SocketsUdpCloseFunction();
147 // AsyncApiFunction:
148 virtual bool Prepare() OVERRIDE;
149 virtual void Work() OVERRIDE;
151 private:
152 scoped_ptr<sockets_udp::Close::Params> params_;
155 class SocketsUdpGetInfoFunction : public UDPSocketAsyncApiFunction {
156 public:
157 DECLARE_EXTENSION_FUNCTION("sockets.udp.getInfo", SOCKETS_UDP_GETINFO)
159 SocketsUdpGetInfoFunction();
161 protected:
162 virtual ~SocketsUdpGetInfoFunction();
164 // AsyncApiFunction:
165 virtual bool Prepare() OVERRIDE;
166 virtual void Work() OVERRIDE;
168 private:
169 scoped_ptr<sockets_udp::GetInfo::Params> params_;
172 class SocketsUdpGetSocketsFunction : public UDPSocketAsyncApiFunction {
173 public:
174 DECLARE_EXTENSION_FUNCTION("sockets.udp.getSockets", SOCKETS_UDP_GETSOCKETS)
176 SocketsUdpGetSocketsFunction();
178 protected:
179 virtual ~SocketsUdpGetSocketsFunction();
181 // AsyncApiFunction:
182 virtual bool Prepare() OVERRIDE;
183 virtual void Work() OVERRIDE;
186 class SocketsUdpJoinGroupFunction : public UDPSocketAsyncApiFunction {
187 public:
188 DECLARE_EXTENSION_FUNCTION("sockets.udp.joinGroup", SOCKETS_UDP_JOINGROUP)
190 SocketsUdpJoinGroupFunction();
192 protected:
193 virtual ~SocketsUdpJoinGroupFunction();
195 // AsyncApiFunction
196 virtual bool Prepare() OVERRIDE;
197 virtual void Work() OVERRIDE;
199 private:
200 scoped_ptr<sockets_udp::JoinGroup::Params> params_;
203 class SocketsUdpLeaveGroupFunction : public UDPSocketAsyncApiFunction {
204 public:
205 DECLARE_EXTENSION_FUNCTION("sockets.udp.leaveGroup", SOCKETS_UDP_LEAVEGROUP)
207 SocketsUdpLeaveGroupFunction();
209 protected:
210 virtual ~SocketsUdpLeaveGroupFunction();
212 // AsyncApiFunction
213 virtual bool Prepare() OVERRIDE;
214 virtual void Work() OVERRIDE;
216 private:
217 scoped_ptr<sockets_udp::LeaveGroup::Params> params_;
220 class SocketsUdpSetMulticastTimeToLiveFunction
221 : public UDPSocketAsyncApiFunction {
222 public:
223 DECLARE_EXTENSION_FUNCTION("sockets.udp.setMulticastTimeToLive",
224 SOCKETS_UDP_SETMULTICASTTIMETOLIVE)
226 SocketsUdpSetMulticastTimeToLiveFunction();
228 protected:
229 virtual ~SocketsUdpSetMulticastTimeToLiveFunction();
231 // AsyncApiFunction
232 virtual bool Prepare() OVERRIDE;
233 virtual void Work() OVERRIDE;
235 private:
236 scoped_ptr<sockets_udp::SetMulticastTimeToLive::Params> params_;
239 class SocketsUdpSetMulticastLoopbackModeFunction
240 : public UDPSocketAsyncApiFunction {
241 public:
242 DECLARE_EXTENSION_FUNCTION("sockets.udp.setMulticastLoopbackMode",
243 SOCKETS_UDP_SETMULTICASTLOOPBACKMODE)
245 SocketsUdpSetMulticastLoopbackModeFunction();
247 protected:
248 virtual ~SocketsUdpSetMulticastLoopbackModeFunction();
250 // AsyncApiFunction
251 virtual bool Prepare() OVERRIDE;
252 virtual void Work() OVERRIDE;
254 private:
255 scoped_ptr<sockets_udp::SetMulticastLoopbackMode::Params> params_;
258 class SocketsUdpGetJoinedGroupsFunction : public UDPSocketAsyncApiFunction {
259 public:
260 DECLARE_EXTENSION_FUNCTION("sockets.udp.getJoinedGroups",
261 SOCKETS_UDP_GETJOINEDGROUPS)
263 SocketsUdpGetJoinedGroupsFunction();
265 protected:
266 virtual ~SocketsUdpGetJoinedGroupsFunction();
268 // AsyncApiFunction
269 virtual bool Prepare() OVERRIDE;
270 virtual void Work() OVERRIDE;
272 private:
273 scoped_ptr<sockets_udp::GetJoinedGroups::Params> params_;
276 } // namespace core_api
277 } // namespace extensions
279 #endif // EXTENSIONS_BROWSER_API_SOCKETS_UDP_SOCKETS_UDP_API_H_