Commit 8fb8b1b7 authored by guoweis's avatar guoweis Committed by Commit bot

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}
parent a8af5943
...@@ -390,7 +390,9 @@ RTCPeerConnectionHandler::RTCPeerConnectionHandler( ...@@ -390,7 +390,9 @@ RTCPeerConnectionHandler::RTCPeerConnectionHandler(
dependency_factory_(dependency_factory), dependency_factory_(dependency_factory),
frame_(NULL), frame_(NULL),
peer_connection_tracker_(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); g_peer_connection_handlers.Get().insert(this);
} }
...@@ -894,6 +896,18 @@ void RTCPeerConnectionHandler::OnIceGatheringChange( ...@@ -894,6 +896,18 @@ void RTCPeerConnectionHandler::OnIceGatheringChange(
// to signal end of candidates. // to signal end of candidates.
blink::WebRTCICECandidate null_candidate; blink::WebRTCICECandidate null_candidate;
client_->didGenerateICECandidate(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 = blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state =
...@@ -968,6 +982,18 @@ void RTCPeerConnectionHandler::OnIceCandidate( ...@@ -968,6 +982,18 @@ void RTCPeerConnectionHandler::OnIceCandidate(
peer_connection_tracker_->TrackAddIceCandidate( peer_connection_tracker_->TrackAddIceCandidate(
this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL, true); 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); client_->didGenerateICECandidate(web_candidate);
} }
......
...@@ -218,6 +218,10 @@ class CONTENT_EXPORT RTCPeerConnectionHandler ...@@ -218,6 +218,10 @@ class CONTENT_EXPORT RTCPeerConnectionHandler
// Counter for a UMA stat reported at destruction time. // Counter for a UMA stat reported at destruction time.
int num_data_channels_created_; 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. // |native_peer_connection_| is the libjingle native PeerConnection object.
scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection_; scoped_refptr<webrtc::PeerConnectionInterface> native_peer_connection_;
......
...@@ -404,6 +404,8 @@ class MockIceCandidate : public IceCandidateInterface { ...@@ -404,6 +404,8 @@ class MockIceCandidate : public IceCandidateInterface {
: sdp_mid_(sdp_mid), : sdp_mid_(sdp_mid),
sdp_mline_index_(sdp_mline_index), sdp_mline_index_(sdp_mline_index),
sdp_(sdp) { 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 ~MockIceCandidate() {}
virtual std::string sdp_mid() const OVERRIDE { virtual std::string sdp_mid() const OVERRIDE {
...@@ -413,11 +415,7 @@ class MockIceCandidate : public IceCandidateInterface { ...@@ -413,11 +415,7 @@ class MockIceCandidate : public IceCandidateInterface {
return sdp_mline_index_; return sdp_mline_index_;
} }
virtual const cricket::Candidate& candidate() const OVERRIDE { virtual const cricket::Candidate& candidate() const OVERRIDE {
// This function should never be called. It will intentionally crash. The return candidate_;
// base class forces us to return a reference.
NOTREACHED();
cricket::Candidate* candidate = NULL;
return *candidate;
} }
virtual bool ToString(std::string* out) const OVERRIDE { virtual bool ToString(std::string* out) const OVERRIDE {
*out = sdp_; *out = sdp_;
...@@ -428,6 +426,7 @@ class MockIceCandidate : public IceCandidateInterface { ...@@ -428,6 +426,7 @@ class MockIceCandidate : public IceCandidateInterface {
std::string sdp_mid_; std::string sdp_mid_;
int sdp_mline_index_; int sdp_mline_index_;
std::string sdp_; std::string sdp_;
cricket::Candidate candidate_;
}; };
MockPeerConnectionDependencyFactory::MockPeerConnectionDependencyFactory() MockPeerConnectionDependencyFactory::MockPeerConnectionDependencyFactory()
......
...@@ -37971,6 +37971,15 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -37971,6 +37971,15 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary> </summary>
</histogram> </histogram>
<histogram name="WebRTC.PeerConnection.IPv4LocalCandidates">
<owner>guoweis@chromium.org</owner>
<summary>
Number of IPv4 local Candidates gathered in a PeerConnection Session once
the ICE address gathering process reaches the Completed status. To avoid
miscounting, this only includes the first m line's first component.
</summary>
</histogram>
<histogram name="WebRTC.PeerConnection.IPv6Interfaces"> <histogram name="WebRTC.PeerConnection.IPv6Interfaces">
<owner>mallinath@chromium.org</owner> <owner>mallinath@chromium.org</owner>
<summary> <summary>
...@@ -37978,6 +37987,15 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -37978,6 +37987,15 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary> </summary>
</histogram> </histogram>
<histogram name="WebRTC.PeerConnection.IPv6LocalCandidates">
<owner>guoweis@chromium.org</owner>
<summary>
Number of IPv6 local Candidates gathered in a PeerConnection Session once
the ICE address gathering process reaches the Completed status. To avoid
miscounting, this only includes the first m line's first component.
</summary>
</histogram>
<histogram name="WebRTC.PeerConnection.TimeToConnect" units="milliseconds"> <histogram name="WebRTC.PeerConnection.TimeToConnect" units="milliseconds">
<owner>mallinath@chromium.org</owner> <owner>mallinath@chromium.org</owner>
<summary>Time to setup a peer to peer call with PeerConnection.</summary> <summary>Time to setup a peer to peer call with PeerConnection.</summary>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment