| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 int32_t request_id) { | 230 int32_t request_id) { |
| 231 DnsRequest* request = new DnsRequest(request_id, | 231 DnsRequest* request = new DnsRequest(request_id, |
| 232 resource_context_->GetHostResolver()); | 232 resource_context_->GetHostResolver()); |
| 233 dns_requests_.insert(request); | 233 dns_requests_.insert(request); |
| 234 request->Resolve(host_name, base::Bind( | 234 request->Resolve(host_name, base::Bind( |
| 235 &P2PSocketDispatcherHost::OnAddressResolved, | 235 &P2PSocketDispatcherHost::OnAddressResolved, |
| 236 base::Unretained(this), request)); | 236 base::Unretained(this), request)); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void P2PSocketDispatcherHost::OnCreateSocket( | 239 void P2PSocketDispatcherHost::OnCreateSocket( |
| 240 P2PSocketType type, int socket_id, | 240 P2PSocketType type, |
| 241 int socket_id, |
| 241 const net::IPEndPoint& local_address, | 242 const net::IPEndPoint& local_address, |
| 243 const P2PPortRange& port_range, |
| 242 const P2PHostAndIPEndPoint& remote_address) { | 244 const P2PHostAndIPEndPoint& remote_address) { |
| 245 DCHECK(local_address.port() == 0 || port_range.min_port == 0); |
| 243 if (LookupSocket(socket_id)) { | 246 if (LookupSocket(socket_id)) { |
| 244 LOG(ERROR) << "Received P2PHostMsg_CreateSocket for socket " | 247 LOG(ERROR) << "Received P2PHostMsg_CreateSocket for socket " |
| 245 "that already exists."; | 248 "that already exists."; |
| 246 return; | 249 return; |
| 247 } | 250 } |
| 248 | 251 |
| 249 std::unique_ptr<P2PSocketHost> socket(P2PSocketHost::Create( | 252 std::unique_ptr<P2PSocketHost> socket(P2PSocketHost::Create( |
| 250 this, socket_id, type, url_context_.get(), &throttler_)); | 253 this, socket_id, type, url_context_.get(), &throttler_)); |
| 251 | 254 |
| 252 if (!socket) { | 255 if (!socket) { |
| 253 Send(new P2PMsg_OnError(socket_id)); | 256 Send(new P2PMsg_OnError(socket_id)); |
| 254 return; | 257 return; |
| 255 } | 258 } |
| 256 | 259 |
| 257 if (socket->Init(local_address, remote_address)) { | 260 if (socket->Init(local_address, port_range.min_port, port_range.max_port, |
| 261 remote_address)) { |
| 258 sockets_[socket_id] = socket.release(); | 262 sockets_[socket_id] = socket.release(); |
| 259 | 263 |
| 260 if (dump_incoming_rtp_packet_ || dump_outgoing_rtp_packet_) { | 264 if (dump_incoming_rtp_packet_ || dump_outgoing_rtp_packet_) { |
| 261 sockets_[socket_id]->StartRtpDump(dump_incoming_rtp_packet_, | 265 sockets_[socket_id]->StartRtpDump(dump_incoming_rtp_packet_, |
| 262 dump_outgoing_rtp_packet_, | 266 dump_outgoing_rtp_packet_, |
| 263 packet_callback_); | 267 packet_callback_); |
| 264 } | 268 } |
| 265 } | 269 } |
| 266 } | 270 } |
| 267 | 271 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 408 |
| 405 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_) | 409 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_) |
| 406 packet_callback_.Reset(); | 410 packet_callback_.Reset(); |
| 407 | 411 |
| 408 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it) | 412 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it) |
| 409 it->second->StopRtpDump(incoming, outgoing); | 413 it->second->StopRtpDump(incoming, outgoing); |
| 410 } | 414 } |
| 411 } | 415 } |
| 412 | 416 |
| 413 } // namespace content | 417 } // namespace content |
| OLD | NEW |