OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/rtc_peer_connection_handler.h" | 5 #include "content/renderer/media/rtc_peer_connection_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 if (!pc->GetStats(observer.get(), track.get(), level)) { | 498 if (!pc->GetStats(observer.get(), track.get(), level)) { |
499 DVLOG(1) << "GetStats failed."; | 499 DVLOG(1) << "GetStats failed."; |
500 observer->OnComplete(StatsReports()); | 500 observer->OnComplete(StatsReports()); |
501 } | 501 } |
502 } | 502 } |
503 | 503 |
504 class PeerConnectionUMAObserver : public webrtc::UMAObserver { | 504 class PeerConnectionUMAObserver : public webrtc::UMAObserver { |
505 public: | 505 public: |
506 PeerConnectionUMAObserver() {} | 506 PeerConnectionUMAObserver() {} |
507 ~PeerConnectionUMAObserver() override {} | 507 ~PeerConnectionUMAObserver() override {} |
508 | 508 void IncrementEnumCounter(webrtc::PeerConnectionEnumCounterType counter_type, |
509 void IncrementCounter( | 509 int counter, |
510 webrtc::PeerConnectionUMAMetricsCounter counter) override { | 510 int counter_max) override { |
511 // Runs on libjingle's signaling thread. | 511 switch (counter_type) { |
512 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.IPMetrics", | 512 case webrtc::kEnumCounterAddressFamily: |
pthatcher2
2015/08/19 02:59:06
Would it have made more sense to pass in a string
guoweis_left_chromium
2015/08/19 18:42:49
Can you elaborate?
| |
513 counter, | 513 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.IPMetrics", counter, |
514 webrtc::kBoundary); | 514 counter_max); |
515 case webrtc::kEnumCounterIceEndpointTypeUdp: | |
516 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.CandidatePairType_UDP", | |
517 counter, counter_max); | |
518 break; | |
519 case webrtc::kEnumCounterIceEndpointTypeTcp: | |
520 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.CandidatePairType_TCP", | |
521 counter, counter_max); | |
522 break; | |
523 default: | |
524 NOTREACHED(); | |
525 } | |
515 } | 526 } |
516 | 527 |
517 void AddHistogramSample(webrtc::PeerConnectionUMAMetricsName type, | 528 void AddHistogramSample(webrtc::PeerConnectionUMAMetricsName type, |
518 int value) override { | 529 int value) override { |
519 // Runs on libjingle's signaling thread. | 530 // Runs on libjingle's signaling thread. |
520 switch (type) { | 531 switch (type) { |
521 case webrtc::kTimeToConnect: | 532 case webrtc::kTimeToConnect: |
522 UMA_HISTOGRAM_MEDIUM_TIMES( | 533 UMA_HISTOGRAM_MEDIUM_TIMES( |
523 "WebRTC.PeerConnection.TimeToConnect", | 534 "WebRTC.PeerConnection.TimeToConnect", |
524 base::TimeDelta::FromMilliseconds(value)); | 535 base::TimeDelta::FromMilliseconds(value)); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
721 blink::WebRTCPeerConnectionHandlerClient* client, | 732 blink::WebRTCPeerConnectionHandlerClient* client, |
722 PeerConnectionDependencyFactory* dependency_factory) | 733 PeerConnectionDependencyFactory* dependency_factory) |
723 : client_(client), | 734 : client_(client), |
724 dependency_factory_(dependency_factory), | 735 dependency_factory_(dependency_factory), |
725 frame_(NULL), | 736 frame_(NULL), |
726 num_data_channels_created_(0), | 737 num_data_channels_created_(0), |
727 num_local_candidates_ipv4_(0), | 738 num_local_candidates_ipv4_(0), |
728 num_local_candidates_ipv6_(0), | 739 num_local_candidates_ipv6_(0), |
729 weak_factory_(this) { | 740 weak_factory_(this) { |
730 g_peer_connection_handlers.Get().insert(this); | 741 g_peer_connection_handlers.Get().insert(this); |
742 ResetUMAStats(); | |
731 } | 743 } |
732 | 744 |
733 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { | 745 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { |
734 DCHECK(thread_checker_.CalledOnValidThread()); | 746 DCHECK(thread_checker_.CalledOnValidThread()); |
735 | 747 |
736 stop(); | 748 stop(); |
737 | 749 |
738 g_peer_connection_handlers.Get().erase(this); | 750 g_peer_connection_handlers.Get().erase(this); |
739 if (peer_connection_tracker_) | 751 if (peer_connection_tracker_) |
740 peer_connection_tracker_->UnregisterPeerConnection(this); | 752 peer_connection_tracker_->UnregisterPeerConnection(this); |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1309 if (peer_connection_tracker_) | 1321 if (peer_connection_tracker_) |
1310 peer_connection_tracker_->TrackSignalingStateChange(this, state); | 1322 peer_connection_tracker_->TrackSignalingStateChange(this, state); |
1311 if (client_) | 1323 if (client_) |
1312 client_->didChangeSignalingState(state); | 1324 client_->didChangeSignalingState(state); |
1313 } | 1325 } |
1314 | 1326 |
1315 // Called any time the IceConnectionState changes | 1327 // Called any time the IceConnectionState changes |
1316 void RTCPeerConnectionHandler::OnIceConnectionChange( | 1328 void RTCPeerConnectionHandler::OnIceConnectionChange( |
1317 webrtc::PeerConnectionInterface::IceConnectionState new_state) { | 1329 webrtc::PeerConnectionInterface::IceConnectionState new_state) { |
1318 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnIceConnectionChange"); | 1330 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnIceConnectionChange"); |
1331 ReportICEState(new_state); | |
1319 DCHECK(thread_checker_.CalledOnValidThread()); | 1332 DCHECK(thread_checker_.CalledOnValidThread()); |
1320 if (new_state == webrtc::PeerConnectionInterface::kIceConnectionChecking) { | 1333 if (new_state == webrtc::PeerConnectionInterface::kIceConnectionChecking) { |
1321 ice_connection_checking_start_ = base::TimeTicks::Now(); | 1334 ice_connection_checking_start_ = base::TimeTicks::Now(); |
1322 } else if (new_state == | 1335 } else if (new_state == |
1323 webrtc::PeerConnectionInterface::kIceConnectionConnected) { | 1336 webrtc::PeerConnectionInterface::kIceConnectionConnected) { |
1324 // If the state becomes connected, send the time needed for PC to become | 1337 // If the state becomes connected, send the time needed for PC to become |
1325 // connected from checking to UMA. UMA data will help to know how much | 1338 // connected from checking to UMA. UMA data will help to know how much |
1326 // time needed for PC to connect with remote peer. | 1339 // time needed for PC to connect with remote peer. |
1327 if (ice_connection_checking_start_.is_null()) { | 1340 if (ice_connection_checking_start_.is_null()) { |
1328 // From UMA, we have observed a large number of calls falling into the | 1341 // From UMA, we have observed a large number of calls falling into the |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1363 | 1376 |
1364 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4LocalCandidates", | 1377 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4LocalCandidates", |
1365 num_local_candidates_ipv4_); | 1378 num_local_candidates_ipv4_); |
1366 | 1379 |
1367 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6LocalCandidates", | 1380 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6LocalCandidates", |
1368 num_local_candidates_ipv6_); | 1381 num_local_candidates_ipv6_); |
1369 } else if (new_state == | 1382 } else if (new_state == |
1370 webrtc::PeerConnectionInterface::kIceGatheringGathering) { | 1383 webrtc::PeerConnectionInterface::kIceGatheringGathering) { |
1371 // ICE restarts will change gathering state back to "gathering", | 1384 // ICE restarts will change gathering state back to "gathering", |
1372 // reset the counter. | 1385 // reset the counter. |
1373 num_local_candidates_ipv6_ = 0; | 1386 ResetUMAStats(); |
pthatcher2
2015/08/19 02:59:06
This makes it so that we get a UMA for ICE every s
guoweis_left_chromium
2015/08/19 18:42:49
I think we should also track the stat after restar
| |
1374 num_local_candidates_ipv4_ = 0; | |
1375 } | 1387 } |
1376 | 1388 |
1377 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = | 1389 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = |
1378 GetWebKitIceGatheringState(new_state); | 1390 GetWebKitIceGatheringState(new_state); |
1379 if (peer_connection_tracker_) | 1391 if (peer_connection_tracker_) |
1380 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); | 1392 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); |
1381 if (client_) | 1393 if (client_) |
1382 client_->didChangeICEGatheringState(state); | 1394 client_->didChangeICEGatheringState(state); |
1383 } | 1395 } |
1384 | 1396 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1519 } else { | 1531 } else { |
1520 base::WaitableEvent event(false, false); | 1532 base::WaitableEvent event(false, false); |
1521 thread->PostTask(FROM_HERE, | 1533 thread->PostTask(FROM_HERE, |
1522 base::Bind(&RunSynchronousClosure, closure, | 1534 base::Bind(&RunSynchronousClosure, closure, |
1523 base::Unretained(trace_event_name), | 1535 base::Unretained(trace_event_name), |
1524 base::Unretained(&event))); | 1536 base::Unretained(&event))); |
1525 event.Wait(); | 1537 event.Wait(); |
1526 } | 1538 } |
1527 } | 1539 } |
1528 | 1540 |
1541 void RTCPeerConnectionHandler::ReportICEState( | |
1542 webrtc::PeerConnectionInterface::IceConnectionState new_state) { | |
1543 if (ice_state_tracking_[new_state]) | |
pthatcher2
2015/08/19 02:59:06
I'd rename ice_state_tracking_ to ice_state_seen_.
guoweis_left_chromium
2015/08/19 18:42:49
Done.
| |
1544 return; | |
1545 ice_state_tracking_[new_state] = true; | |
1546 UMA_HISTOGRAM_ENUMERATION( | |
1547 "WebRTC.PeerConnection.ConnectionState", new_state, | |
1548 webrtc::PeerConnectionInterface::kIceConnectionStateMax); | |
1549 } | |
1550 | |
1551 void RTCPeerConnectionHandler::ResetUMAStats() { | |
1552 num_local_candidates_ipv6_ = 0; | |
1553 num_local_candidates_ipv4_ = 0; | |
1554 ice_connection_checking_start_ = base::TimeTicks(); | |
1555 memset(ice_state_tracking_, 0, sizeof(ice_state_tracking_)); | |
1556 } | |
1529 } // namespace content | 1557 } // namespace content |
OLD | NEW |