| 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 "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "content/browser/renderer_host/p2p/socket_host_throttler.h" | 10 #include "content/browser/renderer_host/p2p/socket_host_throttler.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 P2PSocketHost::StunMessageType type = P2PSocketHost::StunMessageType(); | 178 P2PSocketHost::StunMessageType type = P2PSocketHost::StunMessageType(); |
| 179 bool stun = GetStunPacketType(&*data.begin(), data.size(), &type); | 179 bool stun = GetStunPacketType(&*data.begin(), data.size(), &type); |
| 180 if (!stun || type == STUN_DATA_INDICATION) { | 180 if (!stun || type == STUN_DATA_INDICATION) { |
| 181 LOG(ERROR) << "Page tried to send a data packet to " << to.ToString() | 181 LOG(ERROR) << "Page tried to send a data packet to " << to.ToString() |
| 182 << " before STUN binding is finished."; | 182 << " before STUN binding is finished."; |
| 183 OnError(); | 183 OnError(); |
| 184 return; | 184 return; |
| 185 } | 185 } |
| 186 | 186 |
| 187 if (throttler_->DropNextPacket(data.size())) { | 187 if (throttler_->DropNextPacket(data.size())) { |
| 188 LOG(INFO) << "STUN message is dropped due to high volume."; | 188 VLOG(0) << "STUN message is dropped due to high volume."; |
| 189 // Do not reset socket. | 189 // Do not reset socket. |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 if (send_pending_) { | 194 if (send_pending_) { |
| 195 send_queue_.push_back(PendingPacket(to, data, dscp, packet_id)); | 195 send_queue_.push_back(PendingPacket(to, data, dscp, packet_id)); |
| 196 } else { | 196 } else { |
| 197 PendingPacket packet(to, data, dscp, packet_id); | 197 PendingPacket packet(to, data, dscp, packet_id); |
| 198 DoSend(packet); | 198 DoSend(packet); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 send_queue_.pop_front(); | 257 send_queue_.pop_front(); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| 261 void P2PSocketHostUdp::HandleSendResult(uint64 packet_id, int result) { | 261 void P2PSocketHostUdp::HandleSendResult(uint64 packet_id, int result) { |
| 262 TRACE_EVENT_ASYNC_END1("p2p", "Send", packet_id, | 262 TRACE_EVENT_ASYNC_END1("p2p", "Send", packet_id, |
| 263 "result", result); | 263 "result", result); |
| 264 if (result > 0) { | 264 if (result > 0) { |
| 265 message_sender_->Send(new P2PMsg_OnSendComplete(id_)); | 265 message_sender_->Send(new P2PMsg_OnSendComplete(id_)); |
| 266 } else if (IsTransientError(result)) { | 266 } else if (IsTransientError(result)) { |
| 267 LOG(INFO) << "sendto() has failed twice returning a " | 267 VLOG(0) << "sendto() has failed twice returning a " |
| 268 " transient error. Dropping the packet."; | 268 " transient error. Dropping the packet."; |
| 269 } else if (result < 0) { | 269 } else if (result < 0) { |
| 270 LOG(ERROR) << "Error when sending data in UDP socket: " << result; | 270 LOG(ERROR) << "Error when sending data in UDP socket: " << result; |
| 271 OnError(); | 271 OnError(); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 P2PSocketHost* P2PSocketHostUdp::AcceptIncomingTcpConnection( | 275 P2PSocketHost* P2PSocketHostUdp::AcceptIncomingTcpConnection( |
| 276 const net::IPEndPoint& remote_address, int id) { | 276 const net::IPEndPoint& remote_address, int id) { |
| 277 NOTREACHED(); | 277 NOTREACHED(); |
| 278 OnError(); | 278 OnError(); |
| 279 return NULL; | 279 return NULL; |
| 280 } | 280 } |
| 281 | 281 |
| 282 } // namespace content | 282 } // namespace content |
| OLD | NEW |