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

Side by Side Diff: extensions/browser/api/socket/socket_api.h

Issue 1022663003: Bind open firewall ports to visible application windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actually fix the GN build. Created 5 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
« no previous file with comments | « extensions/browser/api/socket/socket.h ('k') | extensions/browser/api/socket/socket_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 { 20 #if defined(OS_CHROMEOS)
21 class FirewallHole; 21 #include "extensions/browser/api/socket/app_firewall_hole_manager.h"
22 } 22 #endif // OS_CHROMEOS
23 23
24 namespace content { 24 namespace content {
25 class BrowserContext; 25 class BrowserContext;
26 class ResourceContext; 26 class ResourceContext;
27 } 27 }
28 28
29 namespace net { 29 namespace net {
30 class IOBuffer; 30 class IOBuffer;
31 class URLRequestContextGetter; 31 class URLRequestContextGetter;
32 class SSLClientSocket; 32 class SSLClientSocket;
33 } 33 }
34 34
35 namespace extensions { 35 namespace extensions {
36 class Socket;
36 class TLSSocket; 37 class TLSSocket;
37 class Socket;
38 38
39 // A simple interface to ApiResourceManager<Socket> or derived class. The goal 39 // A simple interface to ApiResourceManager<Socket> or derived class. The goal
40 // of this interface is to allow Socket API functions to use distinct instances 40 // of this interface is to allow Socket API functions to use distinct instances
41 // of ApiResourceManager<> depending on the type of socket (old version in 41 // of ApiResourceManager<> depending on the type of socket (old version in
42 // "socket" namespace vs new version in "socket.xxx" namespaces). 42 // "socket" namespace vs new version in "socket.xxx" namespaces).
43 class SocketResourceManagerInterface { 43 class SocketResourceManagerInterface {
44 public: 44 public:
45 virtual ~SocketResourceManagerInterface() {} 45 virtual ~SocketResourceManagerInterface() {}
46 46
47 virtual bool SetBrowserContext(content::BrowserContext* context) = 0; 47 virtual bool SetBrowserContext(content::BrowserContext* context) = 0;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 virtual scoped_ptr<SocketResourceManagerInterface> 116 virtual scoped_ptr<SocketResourceManagerInterface>
117 CreateSocketResourceManager(); 117 CreateSocketResourceManager();
118 118
119 int AddSocket(Socket* socket); 119 int AddSocket(Socket* socket);
120 Socket* GetSocket(int api_resource_id); 120 Socket* GetSocket(int api_resource_id);
121 void ReplaceSocket(int api_resource_id, Socket* socket); 121 void ReplaceSocket(int api_resource_id, Socket* socket);
122 void RemoveSocket(int api_resource_id); 122 void RemoveSocket(int api_resource_id);
123 base::hash_set<int>* GetSocketIds(); 123 base::hash_set<int>* GetSocketIds();
124 124
125 // Only implemented on Chrome OS. 125 // A no-op outside of Chrome OS.
126 void OpenFirewallHole(const std::string& address, 126 void OpenFirewallHole(const std::string& address,
127 int socket_id, 127 int socket_id,
128 Socket* socket); 128 Socket* socket);
129 129
130 private: 130 private:
131 #if defined(OS_CHROMEOS) 131 #if defined(OS_CHROMEOS)
132 void OnFirewallHoleOpenedOnUIThread(int socket_id, 132 void OpenFirewallHoleOnUIThread(AppFirewallHole::PortType type,
133 scoped_ptr<chromeos::FirewallHole> hole); 133 uint16_t port,
134 void OnFirewallHoleOpened(int socket_id, 134 int socket_id);
135 scoped_ptr<chromeos::FirewallHole> hole); 135 void OnFirewallHoleOpened(
136 int socket_id,
137 scoped_ptr<AppFirewallHole, content::BrowserThread::DeleteOnUIThread>
138 hole);
136 #endif // OS_CHROMEOS 139 #endif // OS_CHROMEOS
137 140
138 scoped_ptr<SocketResourceManagerInterface> manager_; 141 scoped_ptr<SocketResourceManagerInterface> manager_;
139 }; 142 };
140 143
141 class SocketExtensionWithDnsLookupFunction : public SocketAsyncApiFunction { 144 class SocketExtensionWithDnsLookupFunction : public SocketAsyncApiFunction {
142 protected: 145 protected:
143 SocketExtensionWithDnsLookupFunction(); 146 SocketExtensionWithDnsLookupFunction();
144 ~SocketExtensionWithDnsLookupFunction() override; 147 ~SocketExtensionWithDnsLookupFunction() override;
145 148
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 550
548 scoped_ptr<core_api::socket::Secure::Params> params_; 551 scoped_ptr<core_api::socket::Secure::Params> params_;
549 scoped_refptr<net::URLRequestContextGetter> url_request_getter_; 552 scoped_refptr<net::URLRequestContextGetter> url_request_getter_;
550 553
551 DISALLOW_COPY_AND_ASSIGN(SocketSecureFunction); 554 DISALLOW_COPY_AND_ASSIGN(SocketSecureFunction);
552 }; 555 };
553 556
554 } // namespace extensions 557 } // namespace extensions
555 558
556 #endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_ 559 #endif // EXTENSIONS_BROWSER_API_SOCKET_SOCKET_API_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/socket/socket.h ('k') | extensions/browser/api/socket/socket_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698