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

Side by Side Diff: chrome/browser/extensions/api/sockets_tcp/sockets_tcp_api.h

Issue 183893041: Move sockets APIs out of src/chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename api targets Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 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 CHROME_BROWSER_EXTENSIONS_API_SOCKETS_TCP_SOCKETS_TCP_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKETS_TCP_SOCKETS_TCP_API_H_
7
8 #include "chrome/browser/extensions/api/socket/socket_api.h"
9 #include "chrome/common/extensions/api/sockets_tcp.h"
10
11 namespace extensions {
12 class ResumableTCPSocket;
13 }
14
15 namespace extensions {
16 namespace api {
17
18 class TCPSocketAsyncApiFunction : public SocketAsyncApiFunction {
19 protected:
20 virtual ~TCPSocketAsyncApiFunction();
21
22 virtual scoped_ptr<SocketResourceManagerInterface>
23 CreateSocketResourceManager() OVERRIDE;
24
25 ResumableTCPSocket* GetTcpSocket(int socket_id);
26 };
27
28 class TCPSocketExtensionWithDnsLookupFunction
29 : public SocketExtensionWithDnsLookupFunction {
30 protected:
31 virtual ~TCPSocketExtensionWithDnsLookupFunction();
32
33 virtual scoped_ptr<SocketResourceManagerInterface>
34 CreateSocketResourceManager() OVERRIDE;
35
36 ResumableTCPSocket* GetTcpSocket(int socket_id);
37 };
38
39 class SocketsTcpCreateFunction : public TCPSocketAsyncApiFunction {
40 public:
41 DECLARE_EXTENSION_FUNCTION("sockets.tcp.create", SOCKETS_TCP_CREATE)
42
43 SocketsTcpCreateFunction();
44
45 protected:
46 virtual ~SocketsTcpCreateFunction();
47
48 // AsyncApiFunction:
49 virtual bool Prepare() OVERRIDE;
50 virtual void Work() OVERRIDE;
51
52 private:
53 FRIEND_TEST_ALL_PREFIXES(SocketsTcpUnitTest, Create);
54 scoped_ptr<sockets_tcp::Create::Params> params_;
55 };
56
57 class SocketsTcpUpdateFunction : public TCPSocketAsyncApiFunction {
58 public:
59 DECLARE_EXTENSION_FUNCTION("sockets.tcp.update", SOCKETS_TCP_UPDATE)
60
61 SocketsTcpUpdateFunction();
62
63 protected:
64 virtual ~SocketsTcpUpdateFunction();
65
66 // AsyncApiFunction:
67 virtual bool Prepare() OVERRIDE;
68 virtual void Work() OVERRIDE;
69
70 private:
71 scoped_ptr<sockets_tcp::Update::Params> params_;
72 };
73
74 class SocketsTcpSetPausedFunction
75 : public TCPSocketAsyncApiFunction {
76 public:
77 DECLARE_EXTENSION_FUNCTION("sockets.tcp.setPaused", SOCKETS_TCP_SETPAUSED)
78
79 SocketsTcpSetPausedFunction();
80
81 protected:
82 virtual ~SocketsTcpSetPausedFunction();
83
84 // AsyncApiFunction
85 virtual bool Prepare() OVERRIDE;
86 virtual void Work() OVERRIDE;
87
88 private:
89 scoped_ptr<sockets_tcp::SetPaused::Params> params_;
90 TCPSocketEventDispatcher* socket_event_dispatcher_;
91 };
92
93 class SocketsTcpSetKeepAliveFunction
94 : public TCPSocketAsyncApiFunction {
95 public:
96 DECLARE_EXTENSION_FUNCTION("sockets.tcp.setKeepAlive",
97 SOCKETS_TCP_SETKEEPALIVE)
98
99 SocketsTcpSetKeepAliveFunction();
100
101 protected:
102 virtual ~SocketsTcpSetKeepAliveFunction();
103
104 // AsyncApiFunction
105 virtual bool Prepare() OVERRIDE;
106 virtual void Work() OVERRIDE;
107
108 private:
109 scoped_ptr<sockets_tcp::SetKeepAlive::Params> params_;
110 };
111
112 class SocketsTcpSetNoDelayFunction
113 : public TCPSocketAsyncApiFunction {
114 public:
115 DECLARE_EXTENSION_FUNCTION("sockets.tcp.setNoDelay", SOCKETS_TCP_SETNODELAY)
116
117 SocketsTcpSetNoDelayFunction();
118
119 protected:
120 virtual ~SocketsTcpSetNoDelayFunction();
121
122 // AsyncApiFunction
123 virtual bool Prepare() OVERRIDE;
124 virtual void Work() OVERRIDE;
125
126 private:
127 scoped_ptr<sockets_tcp::SetNoDelay::Params> params_;
128 };
129
130 class SocketsTcpConnectFunction
131 : public TCPSocketExtensionWithDnsLookupFunction {
132 public:
133 DECLARE_EXTENSION_FUNCTION("sockets.tcp.connect", SOCKETS_TCP_CONNECT)
134
135 SocketsTcpConnectFunction();
136
137 protected:
138 virtual ~SocketsTcpConnectFunction();
139
140 // AsyncApiFunction:
141 virtual bool Prepare() OVERRIDE;
142 virtual void AsyncWorkStart() OVERRIDE;
143
144 // SocketExtensionWithDnsLookupFunction:
145 virtual void AfterDnsLookup(int lookup_result) OVERRIDE;
146
147 private:
148 void StartConnect();
149 void OnCompleted(int net_result);
150
151 scoped_ptr<sockets_tcp::Connect::Params> params_;
152 TCPSocketEventDispatcher* socket_event_dispatcher_;
153 };
154
155 class SocketsTcpDisconnectFunction : public TCPSocketAsyncApiFunction {
156 public:
157 DECLARE_EXTENSION_FUNCTION("sockets.tcp.disconnect", SOCKETS_TCP_DISCONNECT)
158
159 SocketsTcpDisconnectFunction();
160
161 protected:
162 virtual ~SocketsTcpDisconnectFunction();
163
164 // AsyncApiFunction:
165 virtual bool Prepare() OVERRIDE;
166 virtual void Work() OVERRIDE;
167
168 private:
169 scoped_ptr<sockets_tcp::Disconnect::Params> params_;
170 };
171
172 class SocketsTcpSendFunction : public TCPSocketAsyncApiFunction {
173 public:
174 DECLARE_EXTENSION_FUNCTION("sockets.tcp.send", SOCKETS_TCP_SEND)
175
176 SocketsTcpSendFunction();
177
178 protected:
179 virtual ~SocketsTcpSendFunction();
180
181 // AsyncApiFunction:
182 virtual bool Prepare() OVERRIDE;
183 virtual void AsyncWorkStart() OVERRIDE;
184
185 private:
186 void OnCompleted(int net_result);
187 void SetSendResult(int net_result, int bytes_sent);
188
189 scoped_ptr<sockets_tcp::Send::Params> params_;
190 scoped_refptr<net::IOBuffer> io_buffer_;
191 size_t io_buffer_size_;
192 };
193
194 class SocketsTcpCloseFunction : public TCPSocketAsyncApiFunction {
195 public:
196 DECLARE_EXTENSION_FUNCTION("sockets.tcp.close", SOCKETS_TCP_CLOSE)
197
198 SocketsTcpCloseFunction();
199
200 protected:
201 virtual ~SocketsTcpCloseFunction();
202
203 // AsyncApiFunction:
204 virtual bool Prepare() OVERRIDE;
205 virtual void Work() OVERRIDE;
206
207 private:
208 scoped_ptr<sockets_tcp::Close::Params> params_;
209 };
210
211 class SocketsTcpGetInfoFunction : public TCPSocketAsyncApiFunction {
212 public:
213 DECLARE_EXTENSION_FUNCTION("sockets.tcp.getInfo", SOCKETS_TCP_GETINFO)
214
215 SocketsTcpGetInfoFunction();
216
217 protected:
218 virtual ~SocketsTcpGetInfoFunction();
219
220 // AsyncApiFunction:
221 virtual bool Prepare() OVERRIDE;
222 virtual void Work() OVERRIDE;
223
224 private:
225 scoped_ptr<sockets_tcp::GetInfo::Params> params_;
226 };
227
228 class SocketsTcpGetSocketsFunction : public TCPSocketAsyncApiFunction {
229 public:
230 DECLARE_EXTENSION_FUNCTION("sockets.tcp.getSockets", SOCKETS_TCP_GETSOCKETS)
231
232 SocketsTcpGetSocketsFunction();
233
234 protected:
235 virtual ~SocketsTcpGetSocketsFunction();
236
237 // AsyncApiFunction:
238 virtual bool Prepare() OVERRIDE;
239 virtual void Work() OVERRIDE;
240 };
241
242 } // namespace api
243 } // namespace extensions
244
245 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKETS_TCP_SOCKETS_TCP_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/sockets_tcp/OWNERS ('k') | chrome/browser/extensions/api/sockets_tcp/sockets_tcp_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698