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..0a85e393323da55714e11b890c25c55f1afa3379 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,11 @@ class IpcPacketSocket : public rtc::AsyncPacketSocket, |
IS_ERROR, |
}; |
+ // Keep track of the max discarded byte sequence in the IpcPacketSocket |
+ // session. If |bytesDiscarded| is 0, it'll restart the |
+ // cur_discard_bytes_sequence_ counting. |
+ void IncrementDiscardCounters(uint32 bytesDiscarded); |
Alexei Svitkine (slow)
2014/10/27 18:10:05
Nit: bytes_discarded.
Update .cc file and comment
guoweis2
2014/10/27 22:53:18
Done.
|
+ |
// 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 +167,15 @@ class IpcPacketSocket : public rtc::AsyncPacketSocket, |
int error_; |
int options_[P2P_SOCKET_OPT_MAX]; |
+ // Track the maximum & current consecutive bytes discarded due to not enough |
+ // send_bytes_available_. |
+ uint32 max_discard_bytes_sequence_; |
+ uint32 cur_discard_bytes_sequence_; |
+ |
+ // Track total count of packet drops and attempt of packet sends. |
+ uint32 packets_discarded_; |
+ uint32 total_packets_; |
+ |
DISALLOW_COPY_AND_ASSIGN(IpcPacketSocket); |
}; |
@@ -195,7 +210,11 @@ IpcPacketSocket::IpcPacketSocket() |
state_(IS_UNINITIALIZED), |
send_bytes_available_(kMaximumInFlightBytes), |
writable_signal_expected_(false), |
- error_(0) { |
+ error_(0), |
+ max_discard_bytes_sequence_(0), |
+ cur_discard_bytes_sequence_(0), |
+ packets_discarded_(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 +225,14 @@ IpcPacketSocket::~IpcPacketSocket() { |
state_ == IS_ERROR) { |
Close(); |
} |
+ |
+ UMA_HISTOGRAM_COUNTS_10000("WebRTC.MaxApplicationConsecutiveBytesDiscard", |
+ max_discard_bytes_sequence_); |
+ |
+ if (total_packets_ > 0) { |
+ UMA_HISTOGRAM_PERCENTAGE("WebRTC.PacketDiscardByApplication", |
+ (packets_discarded_ * 100) / total_packets_); |
+ } |
} |
void IpcPacketSocket::TraceSendThrottlingState() const { |
@@ -215,6 +242,19 @@ void IpcPacketSocket::TraceSendThrottlingState() const { |
in_flight_packet_sizes_.size()); |
} |
+void IpcPacketSocket::IncrementDiscardCounters(uint32 bytesDiscarded) { |
+ if (bytesDiscarded == 0) { |
+ cur_discard_bytes_sequence_ = 0; |
+ } else { |
+ cur_discard_bytes_sequence_ += bytesDiscarded; |
+ packets_discarded_++; |
+ |
+ if (cur_discard_bytes_sequence_ > max_discard_bytes_sequence_) { |
+ max_discard_bytes_sequence_ = cur_discard_bytes_sequence_; |
+ } |
+ } |
+} |
+ |
bool IpcPacketSocket::Init(P2PSocketType type, |
P2PSocketClientImpl* client, |
const rtc::SocketAddress& local_address, |
@@ -316,6 +356,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 +372,11 @@ int IpcPacketSocket::SendTo(const void *data, size_t data_size, |
} |
error_ = EWOULDBLOCK; |
+ IncrementDiscardCounters(data_size); |
return -1; |
+ } else { |
+ // Passing 0 to IncrementDiscardCounters will restart the sequence counting. |
+ IncrementDiscardCounters(0); |
} |
net::IPEndPoint address_chrome; |