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