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 <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "content/browser/bad_message.h" | 13 #include "content/browser/bad_message.h" |
14 #include "content/browser/renderer_host/p2p/socket_host.h" | 14 #include "content/browser/renderer_host/p2p/socket_host.h" |
15 #include "content/common/p2p_messages.h" | 15 #include "content/common/p2p_messages.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/resource_context.h" | 17 #include "content/public/browser/resource_context.h" |
18 #include "net/base/address_list.h" | 18 #include "net/base/address_list.h" |
19 #include "net/base/completion_callback.h" | 19 #include "net/base/completion_callback.h" |
20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
21 #include "net/base/network_interfaces.h" | 21 #include "net/base/network_interfaces.h" |
22 #include "net/base/sys_addrinfo.h" | 22 #include "net/base/sys_addrinfo.h" |
23 #include "net/dns/host_resolver.h" | 23 #include "net/dns/host_resolver.h" |
24 #include "net/log/net_log.h" | 24 #include "net/log/net_log_source.h" |
| 25 #include "net/log/net_log_with_source.h" |
25 #include "net/socket/client_socket_factory.h" | 26 #include "net/socket/client_socket_factory.h" |
26 #include "net/udp/datagram_client_socket.h" | 27 #include "net/udp/datagram_client_socket.h" |
27 #include "net/url_request/url_request_context_getter.h" | 28 #include "net/url_request/url_request_context_getter.h" |
28 | 29 |
29 using content::BrowserMessageFilter; | 30 using content::BrowserMessageFilter; |
30 using content::BrowserThread; | 31 using content::BrowserThread; |
31 | 32 |
32 namespace content { | 33 namespace content { |
33 | 34 |
34 namespace { | 35 namespace { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 365 |
365 net::IPAddress P2PSocketDispatcherHost::GetDefaultLocalAddress(int family) { | 366 net::IPAddress P2PSocketDispatcherHost::GetDefaultLocalAddress(int family) { |
366 DCHECK(family == AF_INET || family == AF_INET6); | 367 DCHECK(family == AF_INET || family == AF_INET6); |
367 | 368 |
368 // Creation and connection of a UDP socket might be janky. | 369 // Creation and connection of a UDP socket might be janky. |
369 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 370 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
370 | 371 |
371 std::unique_ptr<net::DatagramClientSocket> socket( | 372 std::unique_ptr<net::DatagramClientSocket> socket( |
372 net::ClientSocketFactory::GetDefaultFactory()->CreateDatagramClientSocket( | 373 net::ClientSocketFactory::GetDefaultFactory()->CreateDatagramClientSocket( |
373 net::DatagramSocket::DEFAULT_BIND, net::RandIntCallback(), nullptr, | 374 net::DatagramSocket::DEFAULT_BIND, net::RandIntCallback(), nullptr, |
374 net::NetLog::Source())); | 375 net::NetLogSource())); |
375 | 376 |
376 net::IPAddress ip_address; | 377 net::IPAddress ip_address; |
377 if (family == AF_INET) { | 378 if (family == AF_INET) { |
378 ip_address = net::IPAddress(kPublicIPv4Host); | 379 ip_address = net::IPAddress(kPublicIPv4Host); |
379 } else { | 380 } else { |
380 ip_address = net::IPAddress(kPublicIPv6Host); | 381 ip_address = net::IPAddress(kPublicIPv6Host); |
381 } | 382 } |
382 | 383 |
383 if (socket->Connect(net::IPEndPoint(ip_address, kPublicPort)) != net::OK) { | 384 if (socket->Connect(net::IPEndPoint(ip_address, kPublicPort)) != net::OK) { |
384 return net::IPAddress(); | 385 return net::IPAddress(); |
(...skipping 30 matching lines...) Expand all Loading... |
415 | 416 |
416 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_) | 417 if (!dump_incoming_rtp_packet_ && !dump_outgoing_rtp_packet_) |
417 packet_callback_.Reset(); | 418 packet_callback_.Reset(); |
418 | 419 |
419 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it) | 420 for (SocketsMap::iterator it = sockets_.begin(); it != sockets_.end(); ++it) |
420 it->second->StopRtpDump(incoming, outgoing); | 421 it->second->StopRtpDump(incoming, outgoing); |
421 } | 422 } |
422 } | 423 } |
423 | 424 |
424 } // namespace content | 425 } // namespace content |
OLD | NEW |