Chromium Code Reviews| Index: content/renderer/media/rtc_peer_connection_handler.cc |
| diff --git a/content/renderer/media/rtc_peer_connection_handler.cc b/content/renderer/media/rtc_peer_connection_handler.cc |
| index 2de508789f2b1050a5f9e62ffef495cf89cd1de8..0a1b3b234bfb04e4e4d650b3e202f06e969baefc 100644 |
| --- a/content/renderer/media/rtc_peer_connection_handler.cc |
| +++ b/content/renderer/media/rtc_peer_connection_handler.cc |
| @@ -505,13 +505,25 @@ class PeerConnectionUMAObserver : public webrtc::UMAObserver { |
| public: |
| PeerConnectionUMAObserver() {} |
| ~PeerConnectionUMAObserver() override {} |
| - |
| - void IncrementCounter( |
| - webrtc::PeerConnectionUMAMetricsCounter counter) override { |
| - // Runs on libjingle's signaling thread. |
| - UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.IPMetrics", |
| - counter, |
| - webrtc::kBoundary); |
| + void IncrementEnumCounter(webrtc::PeerConnectionEnumCounterType counter_type, |
| + int counter, |
| + int counter_max) override { |
| + switch (counter_type) { |
| + case webrtc::kEnumCounterAddressFamily: |
| + UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.IPMetrics", counter, |
| + counter_max); |
|
tommi (sloooow) - chröme
2015/08/19 19:29:25
missing break?
guoweis_left_chromium
2015/08/19 19:37:29
Thanks for catching this. Since this is based on a
|
| + case webrtc::kEnumCounterIceEndpointTypeUdp: |
| + UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.CandidatePairType_UDP", |
| + counter, counter_max); |
| + break; |
| + case webrtc::kEnumCounterIceEndpointTypeTcp: |
| + UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.CandidatePairType_TCP", |
| + counter, counter_max); |
| + break; |
| + case webrtc::kPeerConnectionEnumCounterMax: |
|
tommi (sloooow) - chröme
2015/08/19 19:29:26
default: too?
guoweis_left_chromium
2015/08/19 19:37:29
I purposedly removed the default so all enums will
tommi (sloooow) - chröme
2015/08/19 19:46:18
sgtm
|
| + NOTREACHED(); |
| + break; |
| + } |
| } |
| void AddHistogramSample(webrtc::PeerConnectionUMAMetricsName type, |
| @@ -728,6 +740,7 @@ RTCPeerConnectionHandler::RTCPeerConnectionHandler( |
| num_local_candidates_ipv6_(0), |
| weak_factory_(this) { |
| g_peer_connection_handlers.Get().insert(this); |
| + ResetUMAStats(); |
|
tommi (sloooow) - chröme
2015/08/19 19:29:25
might not need this if the array is initialized.
guoweis_left_chromium
2015/08/19 19:37:29
Done.
|
| } |
| RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { |
| @@ -1316,6 +1329,7 @@ void RTCPeerConnectionHandler::OnSignalingChange( |
| void RTCPeerConnectionHandler::OnIceConnectionChange( |
| webrtc::PeerConnectionInterface::IceConnectionState new_state) { |
| TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnIceConnectionChange"); |
| + ReportICEState(new_state); |
|
tommi (sloooow) - chröme
2015/08/19 19:29:26
move below the thread check
guoweis_left_chromium
2015/08/19 19:37:29
Done.
|
| DCHECK(thread_checker_.CalledOnValidThread()); |
| if (new_state == webrtc::PeerConnectionInterface::kIceConnectionChecking) { |
| ice_connection_checking_start_ = base::TimeTicks::Now(); |
| @@ -1370,8 +1384,7 @@ void RTCPeerConnectionHandler::OnIceGatheringChange( |
| 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; |
| + ResetUMAStats(); |
| } |
| blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = |
| @@ -1526,4 +1539,19 @@ void RTCPeerConnectionHandler::RunSynchronousClosureOnSignalingThread( |
| } |
| } |
| +void RTCPeerConnectionHandler::ReportICEState( |
|
tommi (sloooow) - chröme
2015/08/19 19:29:26
add DCHECK(thread_checker_.CalledOnValidThread());
guoweis_left_chromium
2015/08/19 19:37:29
Done.
|
| + webrtc::PeerConnectionInterface::IceConnectionState new_state) { |
| + if (ice_state_seen_[new_state]) |
| + return; |
| + ice_state_seen_[new_state] = true; |
| + UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.ConnectionState", new_state, |
| + webrtc::PeerConnectionInterface::kIceConnectionMax); |
| +} |
| + |
| +void RTCPeerConnectionHandler::ResetUMAStats() { |
|
tommi (sloooow) - chröme
2015/08/19 19:29:26
add DCHECK(thread_checker_.CalledOnValidThread());
guoweis_left_chromium
2015/08/19 19:37:29
Done.
|
| + num_local_candidates_ipv6_ = 0; |
| + num_local_candidates_ipv4_ = 0; |
| + ice_connection_checking_start_ = base::TimeTicks(); |
| + memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); |
| +} |
| } // namespace content |