Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Side by Side Diff: content/renderer/media/rtc_peer_connection_handler.cc

Issue 1274213006: Add instrumentation to track the IceCandidatePairType and IceConnectionState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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:
513 counter, 513 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.IPMetrics", counter,
514 webrtc::kBoundary); 514 counter_max);
515 break;
516 case webrtc::kEnumCounterIceCandidatePairTypeUdp:
517 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.CandidatePairType_UDP",
518 counter, counter_max);
519 break;
520 case webrtc::kEnumCounterIceCandidatePairTypeTcp:
521 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.CandidatePairType_TCP",
522 counter, counter_max);
523 break;
524 case webrtc::kPeerConnectionEnumCounterMax:
525 NOTREACHED();
526 break;
527 }
515 } 528 }
516 529
517 void AddHistogramSample(webrtc::PeerConnectionUMAMetricsName type, 530 void AddHistogramSample(webrtc::PeerConnectionUMAMetricsName type,
518 int value) override { 531 int value) override {
519 // Runs on libjingle's signaling thread. 532 // Runs on libjingle's signaling thread.
520 switch (type) { 533 switch (type) {
521 case webrtc::kTimeToConnect: 534 case webrtc::kTimeToConnect:
522 UMA_HISTOGRAM_MEDIUM_TIMES( 535 UMA_HISTOGRAM_MEDIUM_TIMES(
523 "WebRTC.PeerConnection.TimeToConnect", 536 "WebRTC.PeerConnection.TimeToConnect",
524 base::TimeDelta::FromMilliseconds(value)); 537 base::TimeDelta::FromMilliseconds(value));
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 private: 728 private:
716 const base::WeakPtr<RTCPeerConnectionHandler> handler_; 729 const base::WeakPtr<RTCPeerConnectionHandler> handler_;
717 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; 730 const scoped_refptr<base::SingleThreadTaskRunner> main_thread_;
718 }; 731 };
719 732
720 RTCPeerConnectionHandler::RTCPeerConnectionHandler( 733 RTCPeerConnectionHandler::RTCPeerConnectionHandler(
721 blink::WebRTCPeerConnectionHandlerClient* client, 734 blink::WebRTCPeerConnectionHandlerClient* client,
722 PeerConnectionDependencyFactory* dependency_factory) 735 PeerConnectionDependencyFactory* dependency_factory)
723 : client_(client), 736 : client_(client),
724 dependency_factory_(dependency_factory), 737 dependency_factory_(dependency_factory),
725 frame_(NULL),
726 num_data_channels_created_(0),
727 num_local_candidates_ipv4_(0),
728 num_local_candidates_ipv6_(0),
729 weak_factory_(this) { 738 weak_factory_(this) {
730 g_peer_connection_handlers.Get().insert(this); 739 g_peer_connection_handlers.Get().insert(this);
731 } 740 }
732 741
733 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { 742 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() {
734 DCHECK(thread_checker_.CalledOnValidThread()); 743 DCHECK(thread_checker_.CalledOnValidThread());
735 744
736 stop(); 745 stop();
737 746
738 g_peer_connection_handlers.Get().erase(this); 747 g_peer_connection_handlers.Get().erase(this);
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 peer_connection_tracker_->TrackSignalingStateChange(this, state); 1319 peer_connection_tracker_->TrackSignalingStateChange(this, state);
1311 if (client_) 1320 if (client_)
1312 client_->didChangeSignalingState(state); 1321 client_->didChangeSignalingState(state);
1313 } 1322 }
1314 1323
1315 // Called any time the IceConnectionState changes 1324 // Called any time the IceConnectionState changes
1316 void RTCPeerConnectionHandler::OnIceConnectionChange( 1325 void RTCPeerConnectionHandler::OnIceConnectionChange(
1317 webrtc::PeerConnectionInterface::IceConnectionState new_state) { 1326 webrtc::PeerConnectionInterface::IceConnectionState new_state) {
1318 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnIceConnectionChange"); 1327 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnIceConnectionChange");
1319 DCHECK(thread_checker_.CalledOnValidThread()); 1328 DCHECK(thread_checker_.CalledOnValidThread());
1329 ReportICEState(new_state);
1320 if (new_state == webrtc::PeerConnectionInterface::kIceConnectionChecking) { 1330 if (new_state == webrtc::PeerConnectionInterface::kIceConnectionChecking) {
1321 ice_connection_checking_start_ = base::TimeTicks::Now(); 1331 ice_connection_checking_start_ = base::TimeTicks::Now();
1322 } else if (new_state == 1332 } else if (new_state ==
1323 webrtc::PeerConnectionInterface::kIceConnectionConnected) { 1333 webrtc::PeerConnectionInterface::kIceConnectionConnected) {
1324 // If the state becomes connected, send the time needed for PC to become 1334 // 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 1335 // connected from checking to UMA. UMA data will help to know how much
1326 // time needed for PC to connect with remote peer. 1336 // time needed for PC to connect with remote peer.
1327 if (ice_connection_checking_start_.is_null()) { 1337 if (ice_connection_checking_start_.is_null()) {
1328 // From UMA, we have observed a large number of calls falling into the 1338 // From UMA, we have observed a large number of calls falling into the
1329 // overflow buckets. One possibility is that the Checking is not signaled 1339 // overflow buckets. One possibility is that the Checking is not signaled
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 1373
1364 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4LocalCandidates", 1374 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4LocalCandidates",
1365 num_local_candidates_ipv4_); 1375 num_local_candidates_ipv4_);
1366 1376
1367 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6LocalCandidates", 1377 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6LocalCandidates",
1368 num_local_candidates_ipv6_); 1378 num_local_candidates_ipv6_);
1369 } else if (new_state == 1379 } else if (new_state ==
1370 webrtc::PeerConnectionInterface::kIceGatheringGathering) { 1380 webrtc::PeerConnectionInterface::kIceGatheringGathering) {
1371 // ICE restarts will change gathering state back to "gathering", 1381 // ICE restarts will change gathering state back to "gathering",
1372 // reset the counter. 1382 // reset the counter.
1373 num_local_candidates_ipv6_ = 0; 1383 ResetUMAStats();
1374 num_local_candidates_ipv4_ = 0;
1375 } 1384 }
1376 1385
1377 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = 1386 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state =
1378 GetWebKitIceGatheringState(new_state); 1387 GetWebKitIceGatheringState(new_state);
1379 if (peer_connection_tracker_) 1388 if (peer_connection_tracker_)
1380 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); 1389 peer_connection_tracker_->TrackIceGatheringStateChange(this, state);
1381 if (client_) 1390 if (client_)
1382 client_->didChangeICEGatheringState(state); 1391 client_->didChangeICEGatheringState(state);
1383 } 1392 }
1384 1393
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 } else { 1528 } else {
1520 base::WaitableEvent event(false, false); 1529 base::WaitableEvent event(false, false);
1521 thread->PostTask(FROM_HERE, 1530 thread->PostTask(FROM_HERE,
1522 base::Bind(&RunSynchronousClosure, closure, 1531 base::Bind(&RunSynchronousClosure, closure,
1523 base::Unretained(trace_event_name), 1532 base::Unretained(trace_event_name),
1524 base::Unretained(&event))); 1533 base::Unretained(&event)));
1525 event.Wait(); 1534 event.Wait();
1526 } 1535 }
1527 } 1536 }
1528 1537
1538 void RTCPeerConnectionHandler::ReportICEState(
1539 webrtc::PeerConnectionInterface::IceConnectionState new_state) {
1540 DCHECK(thread_checker_.CalledOnValidThread());
1541 if (ice_state_seen_[new_state])
1542 return;
1543 ice_state_seen_[new_state] = true;
1544 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.ConnectionState", new_state,
1545 webrtc::PeerConnectionInterface::kIceConnectionMax);
1546 }
1547
1548 void RTCPeerConnectionHandler::ResetUMAStats() {
1549 DCHECK(thread_checker_.CalledOnValidThread());
1550 num_local_candidates_ipv6_ = 0;
1551 num_local_candidates_ipv4_ = 0;
1552 ice_connection_checking_start_ = base::TimeTicks();
1553 memset(ice_state_seen_, 0, sizeof(ice_state_seen_));
1554 }
1529 } // namespace content 1555 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_peer_connection_handler.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698