Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / extensions / browser / api / sockets_tcp_server / sockets_tcp_server_api.h
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.
4
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_
7
8 #include "extensions/browser/api/socket/socket_api.h"
9 #include "extensions/common/api/sockets_tcp_server.h"
10
11 namespace extensions {
12 class ResumableTCPServerSocket;
13 }
14
15 namespace extensions {
16 namespace core_api {
17
18 class TCPServerSocketAsyncApiFunction : public SocketAsyncApiFunction {
19  protected:
20   ~TCPServerSocketAsyncApiFunction() override;
21
22   scoped_ptr<SocketResourceManagerInterface> CreateSocketResourceManager()
23       override;
24
25   ResumableTCPServerSocket* GetTcpSocket(int socket_id);
26 };
27
28 class SocketsTcpServerCreateFunction : public TCPServerSocketAsyncApiFunction {
29  public:
30   DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.create",
31                              SOCKETS_TCP_SERVER_CREATE)
32
33   SocketsTcpServerCreateFunction();
34
35  protected:
36   ~SocketsTcpServerCreateFunction() override;
37
38   // AsyncApiFunction:
39   bool Prepare() override;
40   void Work() override;
41
42  private:
43   FRIEND_TEST_ALL_PREFIXES(SocketsTcpServerUnitTest, Create);
44   scoped_ptr<sockets_tcp_server::Create::Params> params_;
45 };
46
47 class SocketsTcpServerUpdateFunction : public TCPServerSocketAsyncApiFunction {
48  public:
49   DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.update",
50                              SOCKETS_TCP_SERVER_UPDATE)
51
52   SocketsTcpServerUpdateFunction();
53
54  protected:
55   ~SocketsTcpServerUpdateFunction() override;
56
57   // AsyncApiFunction:
58   bool Prepare() override;
59   void Work() override;
60
61  private:
62   scoped_ptr<sockets_tcp_server::Update::Params> params_;
63 };
64
65 class SocketsTcpServerSetPausedFunction
66     : public TCPServerSocketAsyncApiFunction {
67  public:
68   DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.setPaused",
69                              SOCKETS_TCP_SERVER_SETPAUSED)
70
71   SocketsTcpServerSetPausedFunction();
72
73  protected:
74   ~SocketsTcpServerSetPausedFunction() override;
75
76   // AsyncApiFunction
77   bool Prepare() override;
78   void Work() override;
79
80  private:
81   scoped_ptr<sockets_tcp_server::SetPaused::Params> params_;
82   TCPServerSocketEventDispatcher* socket_event_dispatcher_;
83 };
84
85 class SocketsTcpServerListenFunction : public TCPServerSocketAsyncApiFunction {
86  public:
87   DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.listen",
88                              SOCKETS_TCP_SERVER_LISTEN)
89
90   SocketsTcpServerListenFunction();
91
92  protected:
93   ~SocketsTcpServerListenFunction() override;
94
95   // AsyncApiFunction:
96   bool Prepare() override;
97   void Work() override;
98
99  private:
100   scoped_ptr<sockets_tcp_server::Listen::Params> params_;
101   TCPServerSocketEventDispatcher* socket_event_dispatcher_;
102 };
103
104 class SocketsTcpServerDisconnectFunction
105     : public TCPServerSocketAsyncApiFunction {
106  public:
107   DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.disconnect",
108                              SOCKETS_TCP_SERVER_DISCONNECT)
109
110   SocketsTcpServerDisconnectFunction();
111
112  protected:
113   ~SocketsTcpServerDisconnectFunction() override;
114
115   // AsyncApiFunction:
116   bool Prepare() override;
117   void Work() override;
118
119  private:
120   scoped_ptr<sockets_tcp_server::Disconnect::Params> params_;
121 };
122
123 class SocketsTcpServerCloseFunction : public TCPServerSocketAsyncApiFunction {
124  public:
125   DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.close",
126                              SOCKETS_TCP_SERVER_CLOSE)
127
128   SocketsTcpServerCloseFunction();
129
130  protected:
131   ~SocketsTcpServerCloseFunction() override;
132
133   // AsyncApiFunction:
134   bool Prepare() override;
135   void Work() override;
136
137  private:
138   scoped_ptr<sockets_tcp_server::Close::Params> params_;
139 };
140
141 class SocketsTcpServerGetInfoFunction : public TCPServerSocketAsyncApiFunction {
142  public:
143   DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.getInfo",
144                              SOCKETS_TCP_SERVER_GETINFO)
145
146   SocketsTcpServerGetInfoFunction();
147
148  protected:
149   ~SocketsTcpServerGetInfoFunction() override;
150
151   // AsyncApiFunction:
152   bool Prepare() override;
153   void Work() override;
154
155  private:
156   scoped_ptr<sockets_tcp_server::GetInfo::Params> params_;
157 };
158
159 class SocketsTcpServerGetSocketsFunction
160     : public TCPServerSocketAsyncApiFunction {
161  public:
162   DECLARE_EXTENSION_FUNCTION("sockets.tcpServer.getSockets",
163                              SOCKETS_TCP_SERVER_GETSOCKETS)
164
165   SocketsTcpServerGetSocketsFunction();
166
167  protected:
168   ~SocketsTcpServerGetSocketsFunction() override;
169
170   // AsyncApiFunction:
171   bool Prepare() override;
172   void Work() override;
173 };
174
175 }  // namespace core_api
176 }  // namespace extensions
177
178 #endif  // EXTENSIONS_BROWSER_API_SOCKETS_TCP_SERVER_SOCKETS_TCP_SERVER_API_H_