Chromium Code Reviews| Index: content/browser/renderer_host/p2p/socket_host.cc |
| diff --git a/content/browser/renderer_host/p2p/socket_host.cc b/content/browser/renderer_host/p2p/socket_host.cc |
| index 1693918bd32854572a8b085efa8b434cb61a3238..94bf3b08d9e51248b270335bdc77f1fe8f5121f5 100644 |
| --- a/content/browser/renderer_host/p2p/socket_host.cc |
| +++ b/content/browser/renderer_host/p2p/socket_host.cc |
| @@ -4,6 +4,7 @@ |
| #include "content/browser/renderer_host/p2p/socket_host.h" |
| +#include "base/metrics/histogram.h" |
| #include "base/sys_byteorder.h" |
| #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
| #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h" |
| @@ -460,10 +461,35 @@ P2PSocketHost::P2PSocketHost(IPC::Sender* message_sender, int socket_id) |
| state_(STATE_UNINITIALIZED), |
| dump_incoming_rtp_packet_(false), |
| dump_outgoing_rtp_packet_(false), |
| - weak_ptr_factory_(this) { |
| + weak_ptr_factory_(this), |
| + protocol_type_(P2PSocketHost::UNKNOWN), |
| + send_packets_delayed_total_(0), |
| + send_packets_total_(0), |
| + send_bytes_delayed_max_(0), |
| + send_bytes_delayed_cur_(0) { |
| } |
| -P2PSocketHost::~P2PSocketHost() { } |
| +P2PSocketHost::~P2PSocketHost() { |
| + DCHECK(protocol_type_ != P2PSocketHost::UNKNOWN); |
| + |
| + if (protocol_type_ == P2PSocketHost::UDP) { |
| + UMA_HISTOGRAM_COUNTS_10000("WebRTC.MaxSystemConsecutiveDelayedBytes_UDP", |
| + send_bytes_delayed_max_); |
| + } else { |
| + UMA_HISTOGRAM_COUNTS_10000("WebRTC.MaxSystemConsecutiveDelayedBytes_TCP", |
| + send_bytes_delayed_max_); |
| + } |
| + |
| + if (send_packets_total_ > 0) { |
| + int loss_rate = ((static_cast<double>(send_packets_delayed_total_)) / |
| + (static_cast<double>(send_packets_total_)) * 100.0); |
| + if (protocol_type_ == P2PSocketHost::UDP) { |
| + UMA_HISTOGRAM_PERCENTAGE("WebRTC.SystemDelayedPackets_UDP", loss_rate); |
| + } else { |
| + UMA_HISTOGRAM_PERCENTAGE("WebRTC.SystemDelayedPackets_TCP", loss_rate); |
| + } |
| + } |
| +} |
| // Verifies that the packet |data| has a valid STUN header. |
| // static |
| @@ -644,4 +670,22 @@ void P2PSocketHost::DumpRtpPacketOnIOThread(scoped_ptr<uint8[]> packet_header, |
| incoming)); |
| } |
| +void P2PSocketHost::IncrementDelayedPackets() { |
| + send_packets_delayed_total_++; |
| +} |
|
Alexei Svitkine (slow)
2014/10/27 17:45:21
Nit: Add an empty line between methods.
guoweis2
2014/10/27 18:07:07
Done.
|
| +void P2PSocketHost::IncrementTotalSentPackets() { |
| + send_packets_total_++; |
| +} |
| +void P2PSocketHost::IncrementDelayedBytes(uint32 size) { |
| + send_bytes_delayed_cur_ += size; |
| + if (send_bytes_delayed_cur_ > send_bytes_delayed_max_) { |
| + send_bytes_delayed_max_ = send_bytes_delayed_cur_; |
| + } |
| +} |
| + |
| +void P2PSocketHost::DecrementDelayedBytes(uint32 size) { |
| + send_bytes_delayed_cur_ -= size; |
| + 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.
|
| +} |
| + |
| } // namespace content |