summaryrefslogtreecommitdiffstats
path: root/content/renderer
diff options
context:
space:
mode:
authorguoweis <guoweis@chromium.org>2014-09-26 10:07:58 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-26 17:08:14 +0000
commit8fb8b1b7ffa66807f5313ccb367a9d4891dab404 (patch)
tree6c6cbd47a03d0dcbb22e78f3f2a98d163a3986ee /content/renderer
parenta8af5943653de9ebabbca1ba6378ac4ac3017e2c (diff)
downloadchromium_src-8fb8b1b7ffa66807f5313ccb367a9d4891dab404.zip
chromium_src-8fb8b1b7ffa66807f5313ccb367a9d4891dab404.tar.gz
chromium_src-8fb8b1b7ffa66807f5313ccb367a9d4891dab404.tar.bz2
Add two UMA counters for IPv4 and IPv6 local candidates gathered in WebRTC PeerConnection.
Counter will be accumulated for each OnIceCandidate callback and report once the IceGathering is completed. BUG=411086 Review URL: https://codereview.chromium.org/600163004 Cr-Commit-Position: refs/heads/master@{#296965}
Diffstat (limited to 'content/renderer')
-rw-r--r--content/renderer/media/rtc_peer_connection_handler.cc28
-rw-r--r--content/renderer/media/rtc_peer_connection_handler.h4
-rw-r--r--content/renderer/media/webrtc/mock_peer_connection_dependency_factory.cc9
3 files changed, 35 insertions, 6 deletions
diff --git a/content/renderer/media/rtc_peer_connection_handler.cc b/content/renderer/media/rtc_peer_connection_handler.cc
index c5c68e4..7f1b85a 100644
--- a/content/renderer/media/rtc_peer_connection_handler.cc
+++ b/content/renderer/media/rtc_peer_connection_handler.cc
@@ -390,7 +390,9 @@ RTCPeerConnectionHandler::RTCPeerConnectionHandler(
dependency_factory_(dependency_factory),
frame_(NULL),
peer_connection_tracker_(NULL),
- num_data_channels_created_(0) {
+ num_data_channels_created_(0),
+ num_local_candidates_ipv4_(0),
+ num_local_candidates_ipv6_(0) {
g_peer_connection_handlers.Get().insert(this);
}
@@ -894,6 +896,18 @@ void RTCPeerConnectionHandler::OnIceGatheringChange(
// to signal end of candidates.
blink::WebRTCICECandidate null_candidate;
client_->didGenerateICECandidate(null_candidate);
+
+ UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4LocalCandidates",
+ num_local_candidates_ipv4_);
+
+ UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6LocalCandidates",
+ num_local_candidates_ipv6_);
+ } else if (new_state ==
+ webrtc::PeerConnectionInterface::kIceGatheringGathering) {
+ // ICE restarts will change gathering state back to "gathering",
+ // reset the counter.
+ num_local_candidates_ipv6_ = 0;
+ num_local_candidates_ipv4_ = 0;
}
blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state =
@@ -968,6 +982,18 @@ void RTCPeerConnectionHandler::OnIceCandidate(
peer_connection_tracker_->TrackAddIceCandidate(
this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL, true);
+ // Only the first m line's first component is tracked to avoid
+ // miscounting when doing BUNDLE or rtcp mux.
+ if (candidate->sdp_mline_index() == 0 &&
+ candidate->candidate().component() == 1) {
+ if (candidate->candidate().address().family() == AF_INET) {
+ num_local_candidates_ipv4_++;
+ } else if (candidate->candidate().address().family() == AF_INET6) {
+ num_local_candidates_ipv6_++;
+ } else {
+ NOTREACHED();
+ }
+ }
client_->didGenerateICECandidate(web_candidate);
}
diff --git a/content/renderer/media/rtc_peer_connection_handler.h b/content/renderer/media/rtc_peer_connection_handler.h
index 2a440f1..81be1ac 100644
--- a/content/renderer/media/rtc_peer_connection_handler.h
+++ b/content/renderer/media/rtc_peer_connection_handler.h
@@ -218,6 +218,10 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
// Counter for a UMA stat reported at destruction time.
int num_data_channels_created_;
+ // Counter for number of IPv4 and IPv6 local candidates.
+ int num_local_candidates_ipv4_;
+ int num_local_candidates_ipv6_;
+
// |native_peer_connection_| is the libjingle native PeerConnection object.
scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection_;
diff --git a/content/renderer/media/webrtc/mock_peer_connection_dependency_factory.cc b/content/renderer/media/webrtc/mock_peer_connection_dependency_factory.cc
index 6d64c4c..d059fc9 100644
--- a/content/renderer/media/webrtc/mock_peer_connection_dependency_factory.cc
+++ b/content/renderer/media/webrtc/mock_peer_connection_dependency_factory.cc
@@ -404,6 +404,8 @@ class MockIceCandidate : public IceCandidateInterface {
: sdp_mid_(sdp_mid),
sdp_mline_index_(sdp_mline_index),
sdp_(sdp) {
+ // Assign an valid address to |candidate_| to pass assert in code.
+ candidate_.set_address(rtc::SocketAddress("127.0.0.1", 5000));
}
virtual ~MockIceCandidate() {}
virtual std::string sdp_mid() const OVERRIDE {
@@ -413,11 +415,7 @@ class MockIceCandidate : public IceCandidateInterface {
return sdp_mline_index_;
}
virtual const cricket::Candidate& candidate() const OVERRIDE {
- // This function should never be called. It will intentionally crash. The
- // base class forces us to return a reference.
- NOTREACHED();
- cricket::Candidate* candidate = NULL;
- return *candidate;
+ return candidate_;
}
virtual bool ToString(std::string* out) const OVERRIDE {
*out = sdp_;
@@ -428,6 +426,7 @@ class MockIceCandidate : public IceCandidateInterface {
std::string sdp_mid_;
int sdp_mline_index_;
std::string sdp_;
+ cricket::Candidate candidate_;
};
MockPeerConnectionDependencyFactory::MockPeerConnectionDependencyFactory()