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

Side by Side Diff: content/browser/renderer_host/p2p/socket_host.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.h" 5 #include "content/browser/renderer_host/p2p/socket_host.h"
6 6
7 #include "base/metrics/histogram.h"
7 #include "base/sys_byteorder.h" 8 #include "base/sys_byteorder.h"
8 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" 9 #include "content/browser/renderer_host/p2p/socket_host_tcp.h"
9 #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h" 10 #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h"
10 #include "content/browser/renderer_host/p2p/socket_host_udp.h" 11 #include "content/browser/renderer_host/p2p/socket_host_udp.h"
11 #include "content/browser/renderer_host/render_process_host_impl.h" 12 #include "content/browser/renderer_host/render_process_host_impl.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 #include "crypto/hmac.h" 14 #include "crypto/hmac.h"
14 #include "third_party/libjingle/source/talk/p2p/base/stun.h" 15 #include "third_party/libjingle/source/talk/p2p/base/stun.h"
15 #include "third_party/webrtc/base/asyncpacketsocket.h" 16 #include "third_party/webrtc/base/asyncpacketsocket.h"
16 #include "third_party/webrtc/base/byteorder.h" 17 #include "third_party/webrtc/base/byteorder.h"
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 454 }
454 455
455 } // packet_processing_helpers 456 } // packet_processing_helpers
456 457
457 P2PSocketHost::P2PSocketHost(IPC::Sender* message_sender, int socket_id) 458 P2PSocketHost::P2PSocketHost(IPC::Sender* message_sender, int socket_id)
458 : message_sender_(message_sender), 459 : message_sender_(message_sender),
459 id_(socket_id), 460 id_(socket_id),
460 state_(STATE_UNINITIALIZED), 461 state_(STATE_UNINITIALIZED),
461 dump_incoming_rtp_packet_(false), 462 dump_incoming_rtp_packet_(false),
462 dump_outgoing_rtp_packet_(false), 463 dump_outgoing_rtp_packet_(false),
463 weak_ptr_factory_(this) { 464 weak_ptr_factory_(this),
465 protocol_type_(P2PSocketHost::UNKNOWN),
466 send_packets_delayed_total_(0),
467 send_packets_total_(0),
468 send_bytes_delayed_max_(0),
469 send_bytes_delayed_cur_(0) {
464 } 470 }
465 471
466 P2PSocketHost::~P2PSocketHost() { } 472 P2PSocketHost::~P2PSocketHost() {
473 DCHECK(protocol_type_ != P2PSocketHost::UNKNOWN);
474
475 if (protocol_type_ == P2PSocketHost::UDP) {
476 UMA_HISTOGRAM_COUNTS_10000("WebRTC.MaxSystemConsecutiveDelayedBytes_UDP",
477 send_bytes_delayed_max_);
478 } else {
479 UMA_HISTOGRAM_COUNTS_10000("WebRTC.MaxSystemConsecutiveDelayedBytes_TCP",
480 send_bytes_delayed_max_);
481 }
482
483 if (send_packets_total_ > 0) {
484 int loss_rate = ((static_cast<double>(send_packets_delayed_total_)) /
485 (static_cast<double>(send_packets_total_)) * 100.0);
486 if (protocol_type_ == P2PSocketHost::UDP) {
487 UMA_HISTOGRAM_PERCENTAGE("WebRTC.SystemDelayedPackets_UDP", loss_rate);
488 } else {
489 UMA_HISTOGRAM_PERCENTAGE("WebRTC.SystemDelayedPackets_TCP", loss_rate);
490 }
491 }
492 }
467 493
468 // Verifies that the packet |data| has a valid STUN header. 494 // Verifies that the packet |data| has a valid STUN header.
469 // static 495 // static
470 bool P2PSocketHost::GetStunPacketType( 496 bool P2PSocketHost::GetStunPacketType(
471 const char* data, int data_size, StunMessageType* type) { 497 const char* data, int data_size, StunMessageType* type) {
472 498
473 if (data_size < kStunHeaderSize) { 499 if (data_size < kStunHeaderSize) {
474 return false; 500 return false;
475 } 501 }
476 502
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 // |packet_dump_callback_| must be called on the UI thread. 663 // |packet_dump_callback_| must be called on the UI thread.
638 BrowserThread::PostTask(BrowserThread::UI, 664 BrowserThread::PostTask(BrowserThread::UI,
639 FROM_HERE, 665 FROM_HERE,
640 base::Bind(packet_dump_callback_, 666 base::Bind(packet_dump_callback_,
641 Passed(&packet_header), 667 Passed(&packet_header),
642 header_length, 668 header_length,
643 packet_length, 669 packet_length,
644 incoming)); 670 incoming));
645 } 671 }
646 672
673 void P2PSocketHost::IncrementDelayedPackets() {
674 send_packets_delayed_total_++;
675 }
Alexei Svitkine (slow) 2014/10/27 17:45:21 Nit: Add an empty line between methods.
guoweis2 2014/10/27 18:07:07 Done.
676 void P2PSocketHost::IncrementTotalSentPackets() {
677 send_packets_total_++;
678 }
679 void P2PSocketHost::IncrementDelayedBytes(uint32 size) {
680 send_bytes_delayed_cur_ += size;
681 if (send_bytes_delayed_cur_ > send_bytes_delayed_max_) {
682 send_bytes_delayed_max_ = send_bytes_delayed_cur_;
683 }
684 }
685
686 void P2PSocketHost::DecrementDelayedBytes(uint32 size) {
687 send_bytes_delayed_cur_ -= size;
688 DCHECK(send_bytes_delayed_cur_ >= 0);
Alexei Svitkine (slow) 2014/10/27 17:45:21 Nit: Can you use a DCHECK_GE?
guoweis2 2014/10/27 18:07:07 Done.
689 }
690
647 } // namespace content 691 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698