| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" | 10 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 new P2PMsg_OnIncomingTcpConnection(id_, address)); | 108 new P2PMsg_OnIncomingTcpConnection(id_, address)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void P2PSocketHostTcpServer::OnAccepted(int result) { | 111 void P2PSocketHostTcpServer::OnAccepted(int result) { |
| 112 HandleAcceptResult(result); | 112 HandleAcceptResult(result); |
| 113 if (result == net::OK) | 113 if (result == net::OK) |
| 114 DoAccept(); | 114 DoAccept(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void P2PSocketHostTcpServer::Send(const net::IPEndPoint& to, | 117 void P2PSocketHostTcpServer::Send(const net::IPEndPoint& to, |
| 118 const std::vector<char>& data) { | 118 const std::vector<char>& data, |
| 119 net::DiffServCodePoint dscp) { |
| 119 NOTREACHED(); | 120 NOTREACHED(); |
| 120 OnError(); | 121 OnError(); |
| 121 } | 122 } |
| 122 | 123 |
| 123 P2PSocketHost* P2PSocketHostTcpServer::AcceptIncomingTcpConnection( | 124 P2PSocketHost* P2PSocketHostTcpServer::AcceptIncomingTcpConnection( |
| 124 const net::IPEndPoint& remote_address, int id) { | 125 const net::IPEndPoint& remote_address, int id) { |
| 125 AcceptedSocketsMap::iterator it = accepted_sockets_.find(remote_address); | 126 AcceptedSocketsMap::iterator it = accepted_sockets_.find(remote_address); |
| 126 if (it == accepted_sockets_.end()) | 127 if (it == accepted_sockets_.end()) |
| 127 return NULL; | 128 return NULL; |
| 128 | 129 |
| 129 net::StreamSocket* socket = it->second; | 130 net::StreamSocket* socket = it->second; |
| 130 accepted_sockets_.erase(it); | 131 accepted_sockets_.erase(it); |
| 131 | 132 |
| 132 scoped_ptr<P2PSocketHostTcpBase> result; | 133 scoped_ptr<P2PSocketHostTcpBase> result; |
| 133 if (client_type_ == P2P_SOCKET_TCP_CLIENT) { | 134 if (client_type_ == P2P_SOCKET_TCP_CLIENT) { |
| 134 result.reset(new P2PSocketHostTcp(message_sender_, id, client_type_, NULL)); | 135 result.reset(new P2PSocketHostTcp(message_sender_, id, client_type_, NULL)); |
| 135 } else { | 136 } else { |
| 136 result.reset(new P2PSocketHostStunTcp( | 137 result.reset(new P2PSocketHostStunTcp( |
| 137 message_sender_, id, client_type_, NULL)); | 138 message_sender_, id, client_type_, NULL)); |
| 138 } | 139 } |
| 139 if (!result->InitAccepted(remote_address, socket)) | 140 if (!result->InitAccepted(remote_address, socket)) |
| 140 return NULL; | 141 return NULL; |
| 141 return result.release(); | 142 return result.release(); |
| 142 } | 143 } |
| 143 | 144 |
| 144 } // namespace content | 145 } // namespace content |
| OLD | NEW |