| 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_dispatcher_host.h" | 5 #include "content/browser/renderer_host/p2p/socket_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "content/browser/renderer_host/p2p/socket_host.h" | 9 #include "content/browser/renderer_host/p2p/socket_host.h" |
| 10 #include "content/common/p2p_messages.h" | 10 #include "content/common/p2p_messages.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 P2PSocketHost* accepted_connection = | 217 P2PSocketHost* accepted_connection = |
| 218 socket->AcceptIncomingTcpConnection(remote_address, connected_socket_id); | 218 socket->AcceptIncomingTcpConnection(remote_address, connected_socket_id); |
| 219 if (accepted_connection) { | 219 if (accepted_connection) { |
| 220 sockets_[connected_socket_id] = accepted_connection; | 220 sockets_[connected_socket_id] = accepted_connection; |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 | 223 |
| 224 void P2PSocketDispatcherHost::OnSend(int socket_id, | 224 void P2PSocketDispatcherHost::OnSend(int socket_id, |
| 225 const net::IPEndPoint& socket_address, | 225 const net::IPEndPoint& socket_address, |
| 226 const std::vector<char>& data, | 226 const std::vector<char>& data, |
| 227 net::DiffServCodePoint dscp, |
| 227 uint64 packet_id) { | 228 uint64 packet_id) { |
| 228 P2PSocketHost* socket = LookupSocket(socket_id); | 229 P2PSocketHost* socket = LookupSocket(socket_id); |
| 229 if (!socket) { | 230 if (!socket) { |
| 230 LOG(ERROR) << "Received P2PHostMsg_Send for invalid socket_id."; | 231 LOG(ERROR) << "Received P2PHostMsg_Send for invalid socket_id."; |
| 231 return; | 232 return; |
| 232 } | 233 } |
| 233 | 234 |
| 234 if (data.size() > kMaximumPacketSize) { | 235 if (data.size() > kMaximumPacketSize) { |
| 235 LOG(ERROR) << "Received P2PHostMsg_Send with a packet that is too big: " | 236 LOG(ERROR) << "Received P2PHostMsg_Send with a packet that is too big: " |
| 236 << data.size(); | 237 << data.size(); |
| 237 Send(new P2PMsg_OnError(socket_id)); | 238 Send(new P2PMsg_OnError(socket_id)); |
| 238 delete socket; | 239 delete socket; |
| 239 sockets_.erase(socket_id); | 240 sockets_.erase(socket_id); |
| 240 return; | 241 return; |
| 241 } | 242 } |
| 242 | 243 |
| 243 socket->Send(socket_address, data, packet_id); | 244 socket->Send(socket_address, data, dscp, packet_id); |
| 244 } | 245 } |
| 245 | 246 |
| 246 void P2PSocketDispatcherHost::OnDestroySocket(int socket_id) { | 247 void P2PSocketDispatcherHost::OnDestroySocket(int socket_id) { |
| 247 SocketsMap::iterator it = sockets_.find(socket_id); | 248 SocketsMap::iterator it = sockets_.find(socket_id); |
| 248 if (it != sockets_.end()) { | 249 if (it != sockets_.end()) { |
| 249 delete it->second; | 250 delete it->second; |
| 250 sockets_.erase(it); | 251 sockets_.erase(it); |
| 251 } else { | 252 } else { |
| 252 LOG(ERROR) << "Received P2PHostMsg_DestroySocket for invalid socket_id."; | 253 LOG(ERROR) << "Received P2PHostMsg_DestroySocket for invalid socket_id."; |
| 253 } | 254 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 269 void P2PSocketDispatcherHost::OnAddressResolved( | 270 void P2PSocketDispatcherHost::OnAddressResolved( |
| 270 DnsRequest* request, | 271 DnsRequest* request, |
| 271 const net::IPAddressNumber& result) { | 272 const net::IPAddressNumber& result) { |
| 272 Send(new P2PMsg_GetHostAddressResult(request->request_id(), result)); | 273 Send(new P2PMsg_GetHostAddressResult(request->request_id(), result)); |
| 273 | 274 |
| 274 dns_requests_.erase(request); | 275 dns_requests_.erase(request); |
| 275 delete request; | 276 delete request; |
| 276 } | 277 } |
| 277 | 278 |
| 278 } // namespace content | 279 } // namespace content |
| OLD | NEW |