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.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
6 | 6 |
7 #include "base/sys_byteorder.h" | 7 #include "base/sys_byteorder.h" |
8 #include "content/common/p2p_messages.h" | 8 #include "content/common/p2p_messages.h" |
9 #include "ipc/ipc_sender.h" | 9 #include "ipc/ipc_sender.h" |
10 #include "jingle/glue/fake_ssl_client_socket.h" | 10 #include "jingle/glue/fake_ssl_client_socket.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return state_ != STATE_ERROR; | 76 return state_ != STATE_ERROR; |
77 } | 77 } |
78 | 78 |
79 bool P2PSocketHostTcpBase::Init(const net::IPEndPoint& local_address, | 79 bool P2PSocketHostTcpBase::Init(const net::IPEndPoint& local_address, |
80 const P2PHostAndIPEndPoint& remote_address) { | 80 const P2PHostAndIPEndPoint& remote_address) { |
81 DCHECK_EQ(state_, STATE_UNINITIALIZED); | 81 DCHECK_EQ(state_, STATE_UNINITIALIZED); |
82 | 82 |
83 remote_address_ = remote_address; | 83 remote_address_ = remote_address; |
84 state_ = STATE_CONNECTING; | 84 state_ = STATE_CONNECTING; |
85 | 85 |
86 net::HostPortPair dest_host_port_pair = | 86 net::HostPortPair dest_host_port_pair; |
87 net::HostPortPair::FromIPEndPoint(remote_address.ip_address); | |
88 // If there is no resolved address, let's try with domain name, assuming | 87 // If there is no resolved address, let's try with domain name, assuming |
89 // socket layer will do the DNS resolve. | 88 // socket layer will do the DNS resolve. |
90 if (remote_address.ip_address.address().empty()) { | 89 if (remote_address.ip_address.address().empty()) { |
91 DCHECK(!remote_address.hostname.empty()); | 90 DCHECK(!remote_address.hostname.empty()); |
92 dest_host_port_pair = net::HostPortPair( | 91 dest_host_port_pair = net::HostPortPair::FromString( |
93 remote_address.hostname, remote_address.ip_address.port()); | 92 remote_address.hostname); |
| 93 } else { |
| 94 dest_host_port_pair = net::HostPortPair::FromIPEndPoint( |
| 95 remote_address.ip_address); |
94 } | 96 } |
95 | 97 |
96 // TODO(mallinath) - We are ignoring local_address altogether. We should | 98 // TODO(mallinath) - We are ignoring local_address altogether. We should |
97 // find a way to inject this into ProxyResolvingClientSocket. This could be | 99 // find a way to inject this into ProxyResolvingClientSocket. This could be |
98 // a problem on multi-homed host. | 100 // a problem on multi-homed host. |
99 | 101 |
100 // The default SSLConfig is good enough for us for now. | 102 // The default SSLConfig is good enough for us for now. |
101 const net::SSLConfig ssl_config; | 103 const net::SSLConfig ssl_config; |
102 socket_.reset(new jingle_glue::ProxyResolvingClientSocket( | 104 socket_.reset(new jingle_glue::ProxyResolvingClientSocket( |
103 NULL, // Default socket pool provided by the net::Proxy. | 105 NULL, // Default socket pool provided by the net::Proxy. |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 } else { | 594 } else { |
593 packet_size += kTurnChannelDataHeaderSize; | 595 packet_size += kTurnChannelDataHeaderSize; |
594 // Calculate any padding if present. | 596 // Calculate any padding if present. |
595 if (packet_size % 4) | 597 if (packet_size % 4) |
596 *pad_bytes = 4 - packet_size % 4; | 598 *pad_bytes = 4 - packet_size % 4; |
597 } | 599 } |
598 return packet_size; | 600 return packet_size; |
599 } | 601 } |
600 | 602 |
601 } // namespace content | 603 } // namespace content |
OLD | NEW |