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_udp.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_udp.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.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 "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 message_sender_->Send(new P2PMsg_OnDataReceived(id_, recv_address_, data)); | 134 message_sender_->Send(new P2PMsg_OnDataReceived(id_, recv_address_, data)); |
135 } else if (result < 0 && !IsTransientError(result)) { | 135 } else if (result < 0 && !IsTransientError(result)) { |
136 LOG(ERROR) << "Error when reading from UDP socket: " << result; | 136 LOG(ERROR) << "Error when reading from UDP socket: " << result; |
137 OnError(); | 137 OnError(); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 void P2PSocketHostUdp::Send(const net::IPEndPoint& to, | 141 void P2PSocketHostUdp::Send(const net::IPEndPoint& to, |
142 const std::vector<char>& data) { | 142 const std::vector<char>& data) { |
143 if (!socket_.get()) { | 143 if (!socket_) { |
144 // The Send message may be sent after the an OnError message was | 144 // The Send message may be sent after the an OnError message was |
145 // sent by hasn't been processed the renderer. | 145 // sent by hasn't been processed the renderer. |
146 return; | 146 return; |
147 } | 147 } |
148 | 148 |
149 if (connected_peers_.find(to) == connected_peers_.end()) { | 149 if (connected_peers_.find(to) == connected_peers_.end()) { |
150 P2PSocketHost::StunMessageType type; | 150 P2PSocketHost::StunMessageType type; |
151 bool stun = GetStunPacketType(&*data.begin(), data.size(), &type); | 151 bool stun = GetStunPacketType(&*data.begin(), data.size(), &type); |
152 if (!stun || type == STUN_DATA_INDICATION) { | 152 if (!stun || type == STUN_DATA_INDICATION) { |
153 LOG(ERROR) << "Page tried to send a data packet to " << to.ToString() | 153 LOG(ERROR) << "Page tried to send a data packet to " << to.ToString() |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 | 215 |
216 P2PSocketHost* P2PSocketHostUdp::AcceptIncomingTcpConnection( | 216 P2PSocketHost* P2PSocketHostUdp::AcceptIncomingTcpConnection( |
217 const net::IPEndPoint& remote_address, int id) { | 217 const net::IPEndPoint& remote_address, int id) { |
218 NOTREACHED(); | 218 NOTREACHED(); |
219 OnError(); | 219 OnError(); |
220 return NULL; | 220 return NULL; |
221 } | 221 } |
222 | 222 |
223 } // namespace content | 223 } // namespace content |
OLD | NEW |