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_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_
6 #define EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_
8 #include "extensions/browser/api/socket/socket_api.h"
9 #include "extensions/common/api/sockets_tcp_server.h"
11 namespace extensions
{
12 class ResumableTCPServerSocket
;
15 namespace extensions
{
18 class TCPServerSocketAsyncApiFunction
: public SocketAsyncApiFunction
{
20 virtual ~TCPServerSocketAsyncApiFunction();
22 virtual scoped_ptr
<SocketResourceManagerInterface
>
23 CreateSocketResourceManager() OVERRIDE
;
25 ResumableTCPServerSocket
* GetTcpSocket(int socket_id
);
28 class SocketsTcpServerCreateFunction
: public TCPServerSocketAsyncApiFunction
{
30 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.create",
31 SOCKETS_TCP_SERVER_CREATE
)
33 SocketsTcpServerCreateFunction();
36 virtual ~SocketsTcpServerCreateFunction();
39 virtual bool Prepare() OVERRIDE
;
40 virtual void Work() OVERRIDE
;
43 FRIEND_TEST_ALL_PREFIXES(SocketsTcpServerUnitTest
, Create
);
44 scoped_ptr
<sockets_tcp_server::Create::Params
> params_
;
47 class SocketsTcpServerUpdateFunction
: public TCPServerSocketAsyncApiFunction
{
49 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.update",
50 SOCKETS_TCP_SERVER_UPDATE
)
52 SocketsTcpServerUpdateFunction();
55 virtual ~SocketsTcpServerUpdateFunction();
58 virtual bool Prepare() OVERRIDE
;
59 virtual void Work() OVERRIDE
;
62 scoped_ptr
<sockets_tcp_server::Update::Params
> params_
;
65 class SocketsTcpServerSetPausedFunction
66 : public TCPServerSocketAsyncApiFunction
{
68 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.setPaused",
69 SOCKETS_TCP_SERVER_SETPAUSED
)
71 SocketsTcpServerSetPausedFunction();
74 virtual ~SocketsTcpServerSetPausedFunction();
77 virtual bool Prepare() OVERRIDE
;
78 virtual void Work() OVERRIDE
;
81 scoped_ptr
<sockets_tcp_server::SetPaused::Params
> params_
;
82 TCPServerSocketEventDispatcher
* socket_event_dispatcher_
;
85 class SocketsTcpServerListenFunction
: public TCPServerSocketAsyncApiFunction
{
87 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.listen",
88 SOCKETS_TCP_SERVER_LISTEN
)
90 SocketsTcpServerListenFunction();
93 virtual ~SocketsTcpServerListenFunction();
96 virtual bool Prepare() OVERRIDE
;
97 virtual void Work() OVERRIDE
;
100 scoped_ptr
<sockets_tcp_server::Listen::Params
> params_
;
101 TCPServerSocketEventDispatcher
* socket_event_dispatcher_
;
104 class SocketsTcpServerDisconnectFunction
105 : public TCPServerSocketAsyncApiFunction
{
107 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.disconnect",
108 SOCKETS_TCP_SERVER_DISCONNECT
)
110 SocketsTcpServerDisconnectFunction();
113 virtual ~SocketsTcpServerDisconnectFunction();
116 virtual bool Prepare() OVERRIDE
;
117 virtual void Work() OVERRIDE
;
120 scoped_ptr
<sockets_tcp_server::Disconnect::Params
> params_
;
123 class SocketsTcpServerCloseFunction
: public TCPServerSocketAsyncApiFunction
{
125 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.close",
126 SOCKETS_TCP_SERVER_CLOSE
)
128 SocketsTcpServerCloseFunction();
131 virtual ~SocketsTcpServerCloseFunction();
134 virtual bool Prepare() OVERRIDE
;
135 virtual void Work() OVERRIDE
;
138 scoped_ptr
<sockets_tcp_server::Close::Params
> params_
;
141 class SocketsTcpServerGetInfoFunction
: public TCPServerSocketAsyncApiFunction
{
143 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.getInfo",
144 SOCKETS_TCP_SERVER_GETINFO
)
146 SocketsTcpServerGetInfoFunction();
149 virtual ~SocketsTcpServerGetInfoFunction();
152 virtual bool Prepare() OVERRIDE
;
153 virtual void Work() OVERRIDE
;
156 scoped_ptr
<sockets_tcp_server::GetInfo::Params
> params_
;
159 class SocketsTcpServerGetSocketsFunction
160 : public TCPServerSocketAsyncApiFunction
{
162 DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.getSockets",
163 SOCKETS_TCP_SERVER_GETSOCKETS
)
165 SocketsTcpServerGetSocketsFunction();
168 virtual ~SocketsTcpServerGetSocketsFunction();
171 virtual bool Prepare() OVERRIDE
;
172 virtual void Work() OVERRIDE
;
175 } // namespace core_api
176 } // namespace extensions
178 #endif // EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_