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) { |
243 if (LookupSocket(socket_id)) { | 245 if (LookupSocket(socket_id)) { |
244 LOG(ERROR) << "Received P2PHostMsg_CreateSocket for socket " | 246 LOG(ERROR) << "Received P2PHostMsg_CreateSocket for socket " |
245 "that already exists."; | 247 "that already exists."; |
246 return; | 248 return; |
247 } | 249 } |
248 | 250 |
249 std::unique_ptr<P2PSocketHost> socket(P2PSocketHost::Create( | 251 std::unique_ptr<P2PSocketHost> socket(P2PSocketHost::Create( |
250 this, socket_id, type, url_context_.get(), &throttler_)); | 252 this, socket_id, type, url_context_.get(), &throttler_)); |
251 | 253 |
252 if (!socket) { | 254 if (!socket) { |
253 Send(new P2PMsg_OnError(socket_id)); | 255 Send(new P2PMsg_OnError(socket_id)); |
254 return; | 256 return; |
255 } | 257 } |
256 | 258 |
257 if (socket->Init(local_address, remote_address)) { | 259 if (socket->Init(local_address, port_range.min_port, port_range.max_port, |
| 260 remote_address)) { |
258 sockets_[socket_id] = socket.release(); | 261 sockets_[socket_id] = socket.release(); |
259 | 262 |
260 if (dump_incoming_rtp_packet_ || dump_outgoing_rtp_packet_) { | 263 if (dump_incoming_rtp_packet_ || dump_outgoing_rtp_packet_) { |
261 sockets_[socket_id]->StartRtpDump(dump_incoming_rtp_packet_, | 264 sockets_[socket_id]->StartRtpDump(dump_incoming_rtp_packet_, |
262 dump_outgoing_rtp_packet_, | 265 dump_outgoing_rtp_packet_, |
263 packet_callback_); | 266 packet_callback_); |
264 } | 267 } |
265 } | 268 } |
266 } | 269 } |
267 | 270 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 407 |
405 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_) | 408 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_) |
406 packet_callback_.Reset(); | 409 packet_callback_.Reset(); |
407 | 410 |
408 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it) | 411 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it) |
409 it->second->StopRtpDump(incoming, outgoing); | 412 it->second->StopRtpDump(incoming, outgoing); |
410 } | 413 } |
411 } | 414 } |
412 | 415 |
413 } // namespace content | 416 } // namespace content |
OLD | NEW |