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

Side by Side Diff: content/browser/renderer_host/p2p/socket_host_udp.cc

Issue 677473002: Implement UMA and internal data structure for tracking EWOULDBLOCK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 P2PSocketHostUdp::P2PSocketHostUdp(IPC::Sender* message_sender, 68 P2PSocketHostUdp::P2PSocketHostUdp(IPC::Sender* message_sender,
69 int socket_id, 69 int socket_id,
70 P2PMessageThrottler* throttler) 70 P2PMessageThrottler* throttler)
71 : P2PSocketHost(message_sender, socket_id), 71 : P2PSocketHost(message_sender, socket_id),
72 socket_( 72 socket_(
73 new net::UDPServerSocket(GetContentClient()->browser()->GetNetLog(), 73 new net::UDPServerSocket(GetContentClient()->browser()->GetNetLog(),
74 net::NetLog::Source())), 74 net::NetLog::Source())),
75 send_pending_(false), 75 send_pending_(false),
76 last_dscp_(net::DSCP_CS0), 76 last_dscp_(net::DSCP_CS0),
77 throttler_(throttler) { 77 throttler_(throttler) {
78 protocol_type_ = P2PSocketHost::UDP;
78 } 79 }
79 80
80 P2PSocketHostUdp::~P2PSocketHostUdp() { 81 P2PSocketHostUdp::~P2PSocketHostUdp() {
81 if (state_ == STATE_OPEN) { 82 if (state_ == STATE_OPEN) {
82 DCHECK(socket_.get()); 83 DCHECK(socket_.get());
83 socket_.reset(); 84 socket_.reset();
84 } 85 }
85 } 86 }
86 87
87 bool P2PSocketHostUdp::Init(const net::IPEndPoint& local_address, 88 bool P2PSocketHostUdp::Init(const net::IPEndPoint& local_address,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return; 205 return;
205 } 206 }
206 207
207 if (throttler_->DropNextPacket(data.size())) { 208 if (throttler_->DropNextPacket(data.size())) {
208 VLOG(0) << "STUN message is dropped due to high volume."; 209 VLOG(0) << "STUN message is dropped due to high volume.";
209 // Do not reset socket. 210 // Do not reset socket.
210 return; 211 return;
211 } 212 }
212 } 213 }
213 214
215 IncrementTotalSentPackets();
216
214 if (send_pending_) { 217 if (send_pending_) {
215 send_queue_.push_back(PendingPacket(to, data, options, packet_id)); 218 send_queue_.push_back(PendingPacket(to, data, options, packet_id));
219 IncrementDelayedBytes(data.size());
220 IncrementDelayedPackets();
216 } else { 221 } else {
217 // TODO(mallinath: Remove unnecessary memcpy in this case. 222 // TODO(mallinath: Remove unnecessary memcpy in this case.
218 PendingPacket packet(to, data, options, packet_id); 223 PendingPacket packet(to, data, options, packet_id);
219 DoSend(packet); 224 DoSend(packet);
220 } 225 }
221 } 226 }
222 227
223 void P2PSocketHostUdp::DoSend(const PendingPacket& packet) { 228 void P2PSocketHostUdp::DoSend(const PendingPacket& packet) {
224 TRACE_EVENT_ASYNC_STEP_INTO1("p2p", "Send", packet.id, "UdpAsyncSendTo", 229 TRACE_EVENT_ASYNC_STEP_INTO1("p2p", "Send", packet.id, "UdpAsyncSendTo",
225 "size", packet.size); 230 "size", packet.size);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 void P2PSocketHostUdp::OnSend(uint64 packet_id, int result) { 279 void P2PSocketHostUdp::OnSend(uint64 packet_id, int result) {
275 DCHECK(send_pending_); 280 DCHECK(send_pending_);
276 DCHECK_NE(result, net::ERR_IO_PENDING); 281 DCHECK_NE(result, net::ERR_IO_PENDING);
277 282
278 send_pending_ = false; 283 send_pending_ = false;
279 284
280 HandleSendResult(packet_id, result); 285 HandleSendResult(packet_id, result);
281 286
282 // Send next packets if we have them waiting in the buffer. 287 // Send next packets if we have them waiting in the buffer.
283 while (state_ == STATE_OPEN && !send_queue_.empty() && !send_pending_) { 288 while (state_ == STATE_OPEN && !send_queue_.empty() && !send_pending_) {
284 DoSend(send_queue_.front()); 289 PendingPacket packet = send_queue_.front();
290 DoSend(packet);
285 send_queue_.pop_front(); 291 send_queue_.pop_front();
292 DecrementDelayedBytes(packet.size);
286 } 293 }
287 } 294 }
288 295
289 void P2PSocketHostUdp::HandleSendResult(uint64 packet_id, int result) { 296 void P2PSocketHostUdp::HandleSendResult(uint64 packet_id, int result) {
290 TRACE_EVENT_ASYNC_END1("p2p", "Send", packet_id, 297 TRACE_EVENT_ASYNC_END1("p2p", "Send", packet_id,
291 "result", result); 298 "result", result);
292 if (result < 0) { 299 if (result < 0) {
293 if (!IsTransientError(result)) { 300 if (!IsTransientError(result)) {
294 LOG(ERROR) << "Error when sending data in UDP socket: " << result; 301 LOG(ERROR) << "Error when sending data in UDP socket: " << result;
295 OnError(); 302 OnError();
(...skipping 22 matching lines...) Expand all
318 case P2P_SOCKET_OPT_DSCP: 325 case P2P_SOCKET_OPT_DSCP:
319 return (net::OK == socket_->SetDiffServCodePoint( 326 return (net::OK == socket_->SetDiffServCodePoint(
320 static_cast<net::DiffServCodePoint>(value))) ? true : false; 327 static_cast<net::DiffServCodePoint>(value))) ? true : false;
321 default: 328 default:
322 NOTREACHED(); 329 NOTREACHED();
323 return false; 330 return false;
324 } 331 }
325 } 332 }
326 333
327 } // namespace content 334 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698