Chromium Code Reviews| Index: content/renderer/p2p/ipc_socket_factory.cc |
| diff --git a/content/renderer/p2p/ipc_socket_factory.cc b/content/renderer/p2p/ipc_socket_factory.cc |
| index 3dead8f5f0150362ddc69da33eee0aa0deff368c..3c8f4db73247df4d30d97b7bbc38bee1231e3c42 100644 |
| --- a/content/renderer/p2p/ipc_socket_factory.cc |
| +++ b/content/renderer/p2p/ipc_socket_factory.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/debug/trace_event.h" |
| #include "base/message_loop/message_loop.h" |
| #include "base/message_loop/message_loop_proxy.h" |
| +#include "base/metrics/histogram.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/threading/non_thread_safe.h" |
| #include "content/renderer/media/webrtc_logging.h" |
| @@ -114,6 +115,8 @@ class IpcPacketSocket : public rtc::AsyncPacketSocket, |
| IS_ERROR, |
| }; |
| + void IncrementEWBCounters(); |
| + |
| // Update trace of send throttling internal state. This should be called |
| // immediately after any changes to |send_bytes_available_| and/or |
| // |in_flight_packet_sizes_|. |
| @@ -161,6 +164,15 @@ class IpcPacketSocket : public rtc::AsyncPacketSocket, |
| int error_; |
| int options_[P2P_SOCKET_OPT_MAX]; |
| + // Track the maximum & current length of consecutive EWOULDBLOCK that we |
| + // return to the upper layer once the socket is in IS_OPEN state. |
| + uint32 max_ewb_sequence_; |
|
juberti2
2014/10/23 19:38:46
I would call this max_discard_sequence_ and cur_di
guoweis2
2014/10/24 06:08:55
Done. Also changed to bytes.
|
| + uint32 cur_ewb_sequence_; |
| + |
| + // Track total count of packet drops and attempt of packet sends. |
| + uint32 packets_dropped_; |
|
juberti2
2014/10/23 19:38:46
Call this packets_discarded_
guoweis2
2014/10/24 06:08:54
Done. Also changed to bytes.
|
| + uint32 total_packets_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(IpcPacketSocket); |
| }; |
| @@ -195,7 +207,11 @@ IpcPacketSocket::IpcPacketSocket() |
| state_(IS_UNINITIALIZED), |
| send_bytes_available_(kMaximumInFlightBytes), |
| writable_signal_expected_(false), |
| - error_(0) { |
| + error_(0), |
| + max_ewb_sequence_(0), |
| + cur_ewb_sequence_(0), |
| + packets_dropped_(0), |
| + total_packets_(0) { |
| COMPILE_ASSERT(kMaximumInFlightBytes > 0, would_send_at_zero_rate); |
| std::fill_n(options_, static_cast<int> (P2P_SOCKET_OPT_MAX), |
| kDefaultNonSetOptionValue); |
| @@ -206,6 +222,13 @@ IpcPacketSocket::~IpcPacketSocket() { |
| state_ == IS_ERROR) { |
| Close(); |
| } |
| + |
| + UMA_HISTOGRAM_COUNTS_100("WebRTC.MaxApplicationConsecutiveEWB", |
| + max_ewb_sequence_); |
| + |
| + UMA_HISTOGRAM_PERCENTAGE("WebRTC.PacketsDroppedByApplicationEWB", |
| + ((static_cast<double>(packets_dropped_)) / |
| + (static_cast<double>(total_packets_)) * 100.0)); |
| } |
| void IpcPacketSocket::TraceSendThrottlingState() const { |
| @@ -215,6 +238,15 @@ void IpcPacketSocket::TraceSendThrottlingState() const { |
| in_flight_packet_sizes_.size()); |
| } |
| +void IpcPacketSocket::IncrementEWBCounters() { |
| + cur_ewb_sequence_++; |
| + packets_dropped_++; |
| + |
| + if (cur_ewb_sequence_ > max_ewb_sequence_) { |
| + max_ewb_sequence_ = cur_ewb_sequence_; |
| + } |
| +} |
| + |
| bool IpcPacketSocket::Init(P2PSocketType type, |
| P2PSocketClientImpl* client, |
| const rtc::SocketAddress& local_address, |
| @@ -316,6 +348,8 @@ int IpcPacketSocket::SendTo(const void *data, size_t data_size, |
| return 0; |
| } |
| + total_packets_++; |
| + |
| if (data_size > send_bytes_available_) { |
| TRACE_EVENT_INSTANT1("p2p", "MaxPendingBytesWouldBlock", |
| TRACE_EVENT_SCOPE_THREAD, |
| @@ -330,7 +364,10 @@ int IpcPacketSocket::SendTo(const void *data, size_t data_size, |
| } |
| error_ = EWOULDBLOCK; |
| + IncrementEWBCounters(); |
| return -1; |
| + } else { |
| + cur_ewb_sequence_ = 0; |
| } |
| net::IPEndPoint address_chrome; |