Chromium Code Reviews| Index: content/browser/renderer_host/p2p/socket_host_udp.cc |
| diff --git a/content/browser/renderer_host/p2p/socket_host_udp.cc b/content/browser/renderer_host/p2p/socket_host_udp.cc |
| index 7d511c88fec2c53fda620b794dae94d42b91b7da..03435f8e9d8a0b9f2ebc4e3d80250af48c73e738 100644 |
| --- a/content/browser/renderer_host/p2p/socket_host_udp.cc |
| +++ b/content/browser/renderer_host/p2p/socket_host_udp.cc |
| @@ -270,23 +270,6 @@ void P2PSocketHostUdp::Send(const net::IPEndPoint& to, |
| return; |
| } |
| - if (!base::ContainsKey(connected_peers_, to)) { |
| - P2PSocketHost::StunMessageType type = P2PSocketHost::StunMessageType(); |
| - bool stun = GetStunPacketType(&*data.begin(), data.size(), &type); |
| - if (!stun || type == STUN_DATA_INDICATION) { |
| - LOG(ERROR) << "Page tried to send a data packet to " << to.ToString() |
| - << " before STUN binding is finished."; |
| - OnError(); |
| - return; |
| - } |
| - |
| - if (throttler_->DropNextPacket(data.size())) { |
| - VLOG(0) << "STUN message is dropped due to high volume."; |
| - // Do not reset socket. |
| - return; |
| - } |
| - } |
| - |
| IncrementTotalSentPackets(); |
| if (send_pending_) { |
| @@ -301,6 +284,28 @@ void P2PSocketHostUdp::Send(const net::IPEndPoint& to, |
| } |
| void P2PSocketHostUdp::DoSend(const PendingPacket& packet) { |
| + base::TimeTicks send_time = base::TimeTicks::Now(); |
| + |
| + if (!base::ContainsKey(connected_peers_, packet.to)) { |
| + P2PSocketHost::StunMessageType type = P2PSocketHost::StunMessageType(); |
| + bool stun = GetStunPacketType(packet.data->data(), packet.size, &type); |
| + if (!stun || type == STUN_DATA_INDICATION) { |
| + LOG(ERROR) << "Page tried to send a data packet to " |
| + << packet.to.ToString() << " before STUN binding is finished."; |
| + OnError(); |
| + return; |
| + } |
| + |
| + if (throttler_->DropNextPacket(packet.size)) { |
| + VLOG(0) << "STUN message is dropped due to high volume."; |
| + message_sender_->Send(new P2PMsg_OnSendComplete( |
| + id_, P2PSendPacketMetrics(packet.id, packet.packet_options.packet_id, |
| + send_time))); |
|
pthatcher2
2016/09/02 05:21:19
We should leave a comment about how important it i
Sergey Ulanov
2016/09/02 17:00:46
Done.
|
| + // Do not reset socket. |
| + return; |
| + } |
| + } |
| + |
| TRACE_EVENT_ASYNC_STEP_INTO1("p2p", "Send", packet.id, "UdpAsyncSendTo", |
| "size", packet.size); |
| // Don't try to set DSCP in following conditions, |
| @@ -322,7 +327,6 @@ void P2PSocketHostUdp::DoSend(const PendingPacket& packet) { |
| } |
| } |
| - base::TimeTicks send_time = base::TimeTicks::Now(); |
| cricket::ApplyPacketOptions(reinterpret_cast<uint8_t*>(packet.data->data()), |
| packet.size, |
| packet.packet_options.packet_time_params, |