| OLD | NEW |
| 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 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "content/browser/renderer_host/p2p/socket_host.h" | 13 #include "content/browser/renderer_host/p2p/socket_host.h" |
| 14 #include "content/common/p2p_sockets.h" | 14 #include "content/common/p2p_sockets.h" |
| 15 #include "net/socket/tcp_server_socket.h" | 15 #include "net/socket/tcp_server_socket.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 class ClientSocket; | 18 class StreamSocket; |
| 19 } // namespace net | 19 } // namespace net |
| 20 | 20 |
| 21 class P2PSocketHostTcpServer : public P2PSocketHost { | 21 class P2PSocketHostTcpServer : public P2PSocketHost { |
| 22 public: | 22 public: |
| 23 P2PSocketHostTcpServer(IPC::Message::Sender* message_sender, | 23 P2PSocketHostTcpServer(IPC::Message::Sender* message_sender, |
| 24 int routing_id, int id); | 24 int routing_id, int id); |
| 25 virtual ~P2PSocketHostTcpServer(); | 25 virtual ~P2PSocketHostTcpServer(); |
| 26 | 26 |
| 27 // P2PSocketHost overrides. | 27 // P2PSocketHost overrides. |
| 28 virtual bool Init(const net::IPEndPoint& local_address, | 28 virtual bool Init(const net::IPEndPoint& local_address, |
| 29 const net::IPEndPoint& remote_address) OVERRIDE; | 29 const net::IPEndPoint& remote_address) OVERRIDE; |
| 30 virtual void Send(const net::IPEndPoint& to, | 30 virtual void Send(const net::IPEndPoint& to, |
| 31 const std::vector<char>& data) OVERRIDE; | 31 const std::vector<char>& data) OVERRIDE; |
| 32 virtual P2PSocketHost* AcceptIncomingTcpConnection( | 32 virtual P2PSocketHost* AcceptIncomingTcpConnection( |
| 33 const net::IPEndPoint& remote_address, int id) OVERRIDE; | 33 const net::IPEndPoint& remote_address, int id) OVERRIDE; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 friend class P2PSocketHostTcpServerTest; | 36 friend class P2PSocketHostTcpServerTest; |
| 37 | 37 |
| 38 typedef std::map<net::IPEndPoint, net::ClientSocket*> AcceptedSocketsMap; | 38 typedef std::map<net::IPEndPoint, net::StreamSocket*> AcceptedSocketsMap; |
| 39 | 39 |
| 40 void OnError(); | 40 void OnError(); |
| 41 | 41 |
| 42 void DoAccept(); | 42 void DoAccept(); |
| 43 void HandleAcceptResult(int result); | 43 void HandleAcceptResult(int result); |
| 44 | 44 |
| 45 // Callback for Accept(). | 45 // Callback for Accept(). |
| 46 void OnAccepted(int result); | 46 void OnAccepted(int result); |
| 47 | 47 |
| 48 scoped_ptr<net::ServerSocket> socket_; | 48 scoped_ptr<net::ServerSocket> socket_; |
| 49 net::IPEndPoint local_address_; | 49 net::IPEndPoint local_address_; |
| 50 | 50 |
| 51 scoped_ptr<net::ClientSocket> accept_socket_; | 51 scoped_ptr<net::StreamSocket> accept_socket_; |
| 52 AcceptedSocketsMap accepted_sockets_; | 52 AcceptedSocketsMap accepted_sockets_; |
| 53 | 53 |
| 54 net::CompletionCallbackImpl<P2PSocketHostTcpServer> accept_callback_; | 54 net::CompletionCallbackImpl<P2PSocketHostTcpServer> accept_callback_; |
| 55 | 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostTcpServer); | 56 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostTcpServer); |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_ | 59 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_TCP_SERVER_H_ |
| OLD | NEW |