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_SOCKET_SOCKET_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ |
6 #define EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ | 6 #define EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "extensions/browser/api/api_resource_manager.h" | 12 #include "extensions/browser/api/api_resource_manager.h" |
13 #include "extensions/browser/api/async_api_function.h" | 13 #include "extensions/browser/api/async_api_function.h" |
14 #include "extensions/browser/extension_function.h" | 14 #include "extensions/browser/extension_function.h" |
15 #include "extensions/common/api/socket.h" | 15 #include "extensions/common/api/socket.h" |
16 #include "net/base/address_list.h" | 16 #include "net/base/address_list.h" |
17 #include "net/dns/host_resolver.h" | 17 #include "net/dns/host_resolver.h" |
18 #include "net/socket/tcp_client_socket.h" | 18 #include "net/socket/tcp_client_socket.h" |
19 | 19 |
20 namespace chromeos { | |
21 class FirewallHole; | |
22 } | |
23 | |
20 namespace content { | 24 namespace content { |
21 class BrowserContext; | 25 class BrowserContext; |
22 class ResourceContext; | 26 class ResourceContext; |
23 } | 27 } |
24 | 28 |
25 namespace net { | 29 namespace net { |
26 class IOBuffer; | 30 class IOBuffer; |
27 class URLRequestContextGetter; | 31 class URLRequestContextGetter; |
28 class SSLClientSocket; | 32 class SSLClientSocket; |
29 } | 33 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 | 115 |
112 virtual scoped_ptr<SocketResourceManagerInterface> | 116 virtual scoped_ptr<SocketResourceManagerInterface> |
113 CreateSocketResourceManager(); | 117 CreateSocketResourceManager(); |
114 | 118 |
115 int AddSocket(Socket* socket); | 119 int AddSocket(Socket* socket); |
116 Socket* GetSocket(int api_resource_id); | 120 Socket* GetSocket(int api_resource_id); |
117 void ReplaceSocket(int api_resource_id, Socket* socket); | 121 void ReplaceSocket(int api_resource_id, Socket* socket); |
118 void RemoveSocket(int api_resource_id); | 122 void RemoveSocket(int api_resource_id); |
119 base::hash_set<int>* GetSocketIds(); | 123 base::hash_set<int>* GetSocketIds(); |
120 | 124 |
125 // Only implemented on Chrome OS. | |
Finnur
2015/02/27 11:23:52
Is this intended to remain a ChromeOS-only feature
Reilly Grant (use Gerrit)
2015/02/27 15:57:24
Yes, it is unnecessary on other platforms where th
| |
126 void OpenFirewallHole(const std::string& address, | |
Finnur
2015/02/27 11:23:52
Also, did this change go through API review?
Reilly Grant (use Gerrit)
2015/02/27 15:57:24
It's been signed off on by security (who did the p
| |
127 int socket_id, | |
128 Socket* socket); | |
129 | |
121 private: | 130 private: |
131 #if defined(OS_CHROMEOS) | |
132 void OnFirewallHoleOpenedOnUIThread(int socket_id, | |
133 scoped_ptr<chromeos::FirewallHole> hole); | |
134 void OnFirewallHoleOpened(int socket_id, | |
135 scoped_ptr<chromeos::FirewallHole> hole); | |
136 #endif // OS_CHROMEOS | |
137 | |
122 scoped_ptr<SocketResourceManagerInterface> manager_; | 138 scoped_ptr<SocketResourceManagerInterface> manager_; |
123 }; | 139 }; |
124 | 140 |
125 class SocketExtensionWithDnsLookupFunction : public SocketAsyncApiFunction { | 141 class SocketExtensionWithDnsLookupFunction : public SocketAsyncApiFunction { |
126 protected: | 142 protected: |
127 SocketExtensionWithDnsLookupFunction(); | 143 SocketExtensionWithDnsLookupFunction(); |
128 ~SocketExtensionWithDnsLookupFunction() override; | 144 ~SocketExtensionWithDnsLookupFunction() override; |
129 | 145 |
130 // AsyncApiFunction: | 146 // AsyncApiFunction: |
131 bool PrePrepare() override; | 147 bool PrePrepare() override; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 | 239 |
224 class SocketBindFunction : public SocketAsyncApiFunction { | 240 class SocketBindFunction : public SocketAsyncApiFunction { |
225 public: | 241 public: |
226 DECLARE_EXTENSION_FUNCTION("socket.bind", SOCKET_BIND) | 242 DECLARE_EXTENSION_FUNCTION("socket.bind", SOCKET_BIND) |
227 | 243 |
228 protected: | 244 protected: |
229 ~SocketBindFunction() override {} | 245 ~SocketBindFunction() override {} |
230 | 246 |
231 // AsyncApiFunction: | 247 // AsyncApiFunction: |
232 bool Prepare() override; | 248 bool Prepare() override; |
233 void Work() override; | 249 void AsyncWorkStart() override; |
234 | 250 |
235 private: | 251 private: |
236 int socket_id_; | 252 int socket_id_; |
237 std::string address_; | 253 std::string address_; |
238 uint16 port_; | 254 uint16 port_; |
239 }; | 255 }; |
240 | 256 |
241 class SocketListenFunction : public SocketAsyncApiFunction { | 257 class SocketListenFunction : public SocketAsyncApiFunction { |
242 public: | 258 public: |
243 DECLARE_EXTENSION_FUNCTION("socket.listen", SOCKET_LISTEN) | 259 DECLARE_EXTENSION_FUNCTION("socket.listen", SOCKET_LISTEN) |
244 | 260 |
245 SocketListenFunction(); | 261 SocketListenFunction(); |
246 | 262 |
247 protected: | 263 protected: |
248 ~SocketListenFunction() override; | 264 ~SocketListenFunction() override; |
249 | 265 |
250 // AsyncApiFunction: | 266 // AsyncApiFunction: |
251 bool Prepare() override; | 267 bool Prepare() override; |
252 void Work() override; | 268 void AsyncWorkStart() override; |
253 | 269 |
254 private: | 270 private: |
255 scoped_ptr<core_api::socket::Listen::Params> params_; | 271 scoped_ptr<core_api::socket::Listen::Params> params_; |
256 }; | 272 }; |
257 | 273 |
258 class SocketAcceptFunction : public SocketAsyncApiFunction { | 274 class SocketAcceptFunction : public SocketAsyncApiFunction { |
259 public: | 275 public: |
260 DECLARE_EXTENSION_FUNCTION("socket.accept", SOCKET_ACCEPT) | 276 DECLARE_EXTENSION_FUNCTION("socket.accept", SOCKET_ACCEPT) |
261 | 277 |
262 SocketAcceptFunction(); | 278 SocketAcceptFunction(); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
531 | 547 |
532 scoped_ptr<core_api::socket::Secure::Params> params_; | 548 scoped_ptr<core_api::socket::Secure::Params> params_; |
533 scoped_refptr<net::URLRequestContextGetter> url_request_getter_; | 549 scoped_refptr<net::URLRequestContextGetter> url_request_getter_; |
534 | 550 |
535 DISALLOW_COPY_AND_ASSIGN(SocketSecureFunction); | 551 DISALLOW_COPY_AND_ASSIGN(SocketSecureFunction); |
536 }; | 552 }; |
537 | 553 |
538 } // namespace extensions | 554 } // namespace extensions |
539 | 555 |
540 #endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ | 556 #endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ |
OLD | NEW |