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

Side by Side Diff: content/browser/renderer_host/p2p/socket_host_tcp_server.h

Issue 17132012: Proxy support for P2P TCP Socket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 6 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "content/browser/renderer_host/p2p/socket_host.h" 14 #include "content/browser/renderer_host/p2p/socket_host.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "content/common/p2p_sockets.h" 16 #include "content/common/p2p_sockets.h"
17 #include "ipc/ipc_sender.h" 17 #include "ipc/ipc_sender.h"
18 #include "net/base/completion_callback.h" 18 #include "net/base/completion_callback.h"
19 #include "net/socket/tcp_server_socket.h" 19 #include "net/socket/tcp_server_socket.h"
20 20
21 namespace net { 21 namespace net {
22 class StreamSocket; 22 class StreamSocket;
23 class URLRequestContextGetter;
23 } // namespace net 24 } // namespace net
24 25
25 namespace content { 26 namespace content {
26 27
27 class CONTENT_EXPORT P2PSocketHostTcpServer : public P2PSocketHost { 28 class CONTENT_EXPORT P2PSocketHostTcpServer : public P2PSocketHost {
28 public: 29 public:
29 typedef std::map<net::IPEndPoint, net::StreamSocket*> AcceptedSocketsMap; 30 typedef std::map<net::IPEndPoint, net::StreamSocket*> AcceptedSocketsMap;
30 31
31 P2PSocketHostTcpServer(IPC::Sender* message_sender, int id, 32 P2PSocketHostTcpServer(IPC::Sender* message_sender, int id,
32 P2PSocketType client_type); 33 P2PSocketType client_type,
34 net::URLRequestContextGetter* getter);
33 virtual ~P2PSocketHostTcpServer(); 35 virtual ~P2PSocketHostTcpServer();
34 36
35 // P2PSocketHost overrides. 37 // P2PSocketHost overrides.
36 virtual bool Init(const net::IPEndPoint& local_address, 38 virtual bool Init(const net::IPEndPoint& local_address,
37 const net::IPEndPoint& remote_address) OVERRIDE; 39 const net::IPEndPoint& remote_address) OVERRIDE;
38 virtual void Send(const net::IPEndPoint& to, 40 virtual void Send(const net::IPEndPoint& to,
39 const std::vector<char>& data) OVERRIDE; 41 const std::vector<char>& data) OVERRIDE;
40 virtual P2PSocketHost* AcceptIncomingTcpConnection( 42 virtual P2PSocketHost* AcceptIncomingTcpConnection(
41 const net::IPEndPoint& remote_address, int id) OVERRIDE; 43 const net::IPEndPoint& remote_address, int id) OVERRIDE;
42 44
43 private: 45 private:
44 friend class P2PSocketHostTcpServerTest; 46 friend class P2PSocketHostTcpServerTest;
45 47
46 void OnError(); 48 void OnError();
47 49
48 void DoAccept(); 50 void DoAccept();
49 void HandleAcceptResult(int result); 51 void HandleAcceptResult(int result);
50 52
51 // Callback for Accept(). 53 // Callback for Accept().
52 void OnAccepted(int result); 54 void OnAccepted(int result);
53 55
54 const P2PSocketType client_type_; 56 const P2PSocketType client_type_;
57 scoped_refptr<net::URLRequestContextGetter> context_getter_;
55 scoped_ptr<net::ServerSocket> socket_; 58 scoped_ptr<net::ServerSocket> socket_;
56 net::IPEndPoint local_address_; 59 net::IPEndPoint local_address_;
57 60
58 scoped_ptr<net::StreamSocket> accept_socket_; 61 scoped_ptr<net::StreamSocket> accept_socket_;
59 AcceptedSocketsMap accepted_sockets_; 62 AcceptedSocketsMap accepted_sockets_;
60 63
61 net::CompletionCallback accept_callback_; 64 net::CompletionCallback accept_callback_;
62 65
63 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostTcpServer); 66 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostTcpServer);
64 }; 67 };
65 68
66 } // namespace content 69 } // namespace content
67 70
68 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_ 71 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698