Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1066)

Unified Diff: content/browser/renderer_host/p2p/socket_host_udp.cc

Issue 2300983003: Fix P2PSocketHostUdp to handle dropped packets properly. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698