Chromium Code Reviews| 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: |
| 513 counter, | 513 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.IPMetrics", counter, |
| 514 webrtc::kBoundary); | 514 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
| |
| 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 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
| |
| 524 NOTREACHED(); | |
| 525 break; | |
| 526 } | |
| 515 } | 527 } |
| 516 | 528 |
| 517 void AddHistogramSample(webrtc::PeerConnectionUMAMetricsName type, | 529 void AddHistogramSample(webrtc::PeerConnectionUMAMetricsName type, |
| 518 int value) override { | 530 int value) override { |
| 519 // Runs on libjingle's signaling thread. | 531 // Runs on libjingle's signaling thread. |
| 520 switch (type) { | 532 switch (type) { |
| 521 case webrtc::kTimeToConnect: | 533 case webrtc::kTimeToConnect: |
| 522 UMA_HISTOGRAM_MEDIUM_TIMES( | 534 UMA_HISTOGRAM_MEDIUM_TIMES( |
| 523 "WebRTC.PeerConnection.TimeToConnect", | 535 "WebRTC.PeerConnection.TimeToConnect", |
| 524 base::TimeDelta::FromMilliseconds(value)); | 536 base::TimeDelta::FromMilliseconds(value)); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 blink::WebRTCPeerConnectionHandlerClient* client, | 733 blink::WebRTCPeerConnectionHandlerClient* client, |
| 722 PeerConnectionDependencyFactory* dependency_factory) | 734 PeerConnectionDependencyFactory* dependency_factory) |
| 723 : client_(client), | 735 : client_(client), |
| 724 dependency_factory_(dependency_factory), | 736 dependency_factory_(dependency_factory), |
| 725 frame_(NULL), | 737 frame_(NULL), |
| 726 num_data_channels_created_(0), | 738 num_data_channels_created_(0), |
| 727 num_local_candidates_ipv4_(0), | 739 num_local_candidates_ipv4_(0), |
| 728 num_local_candidates_ipv6_(0), | 740 num_local_candidates_ipv6_(0), |
| 729 weak_factory_(this) { | 741 weak_factory_(this) { |
| 730 g_peer_connection_handlers.Get().insert(this); | 742 g_peer_connection_handlers.Get().insert(this); |
| 743 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.
| |
| 731 } | 744 } |
| 732 | 745 |
| 733 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { | 746 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { |
| 734 DCHECK(thread_checker_.CalledOnValidThread()); | 747 DCHECK(thread_checker_.CalledOnValidThread()); |
| 735 | 748 |
| 736 stop(); | 749 stop(); |
| 737 | 750 |
| 738 g_peer_connection_handlers.Get().erase(this); | 751 g_peer_connection_handlers.Get().erase(this); |
| 739 if (peer_connection_tracker_) | 752 if (peer_connection_tracker_) |
| 740 peer_connection_tracker_->UnregisterPeerConnection(this); | 753 peer_connection_tracker_->UnregisterPeerConnection(this); |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1309 if (peer_connection_tracker_) | 1322 if (peer_connection_tracker_) |
| 1310 peer_connection_tracker_->TrackSignalingStateChange(this, state); | 1323 peer_connection_tracker_->TrackSignalingStateChange(this, state); |
| 1311 if (client_) | 1324 if (client_) |
| 1312 client_->didChangeSignalingState(state); | 1325 client_->didChangeSignalingState(state); |
| 1313 } | 1326 } |
| 1314 | 1327 |
| 1315 // Called any time the IceConnectionState changes | 1328 // Called any time the IceConnectionState changes |
| 1316 void RTCPeerConnectionHandler::OnIceConnectionChange( | 1329 void RTCPeerConnectionHandler::OnIceConnectionChange( |
| 1317 webrtc::PeerConnectionInterface::IceConnectionState new_state) { | 1330 webrtc::PeerConnectionInterface::IceConnectionState new_state) { |
| 1318 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnIceConnectionChange"); | 1331 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::OnIceConnectionChange"); |
| 1332 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.
| |
| 1319 DCHECK(thread_checker_.CalledOnValidThread()); | 1333 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1320 if (new_state == webrtc::PeerConnectionInterface::kIceConnectionChecking) { | 1334 if (new_state == webrtc::PeerConnectionInterface::kIceConnectionChecking) { |
| 1321 ice_connection_checking_start_ = base::TimeTicks::Now(); | 1335 ice_connection_checking_start_ = base::TimeTicks::Now(); |
| 1322 } else if (new_state == | 1336 } else if (new_state == |
| 1323 webrtc::PeerConnectionInterface::kIceConnectionConnected) { | 1337 webrtc::PeerConnectionInterface::kIceConnectionConnected) { |
| 1324 // If the state becomes connected, send the time needed for PC to become | 1338 // 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 | 1339 // connected from checking to UMA. UMA data will help to know how much |
| 1326 // time needed for PC to connect with remote peer. | 1340 // time needed for PC to connect with remote peer. |
| 1327 if (ice_connection_checking_start_.is_null()) { | 1341 if (ice_connection_checking_start_.is_null()) { |
| 1328 // From UMA, we have observed a large number of calls falling into the | 1342 // 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 | 1377 |
| 1364 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4LocalCandidates", | 1378 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4LocalCandidates", |
| 1365 num_local_candidates_ipv4_); | 1379 num_local_candidates_ipv4_); |
| 1366 | 1380 |
| 1367 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6LocalCandidates", | 1381 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6LocalCandidates", |
| 1368 num_local_candidates_ipv6_); | 1382 num_local_candidates_ipv6_); |
| 1369 } else if (new_state == | 1383 } else if (new_state == |
| 1370 webrtc::PeerConnectionInterface::kIceGatheringGathering) { | 1384 webrtc::PeerConnectionInterface::kIceGatheringGathering) { |
| 1371 // ICE restarts will change gathering state back to "gathering", | 1385 // ICE restarts will change gathering state back to "gathering", |
| 1372 // reset the counter. | 1386 // reset the counter. |
| 1373 num_local_candidates_ipv6_ = 0; | 1387 ResetUMAStats(); |
| 1374 num_local_candidates_ipv4_ = 0; | |
| 1375 } | 1388 } |
| 1376 | 1389 |
| 1377 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = | 1390 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = |
| 1378 GetWebKitIceGatheringState(new_state); | 1391 GetWebKitIceGatheringState(new_state); |
| 1379 if (peer_connection_tracker_) | 1392 if (peer_connection_tracker_) |
| 1380 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); | 1393 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); |
| 1381 if (client_) | 1394 if (client_) |
| 1382 client_->didChangeICEGatheringState(state); | 1395 client_->didChangeICEGatheringState(state); |
| 1383 } | 1396 } |
| 1384 | 1397 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1519 } else { | 1532 } else { |
| 1520 base::WaitableEvent event(false, false); | 1533 base::WaitableEvent event(false, false); |
| 1521 thread->PostTask(FROM_HERE, | 1534 thread->PostTask(FROM_HERE, |
| 1522 base::Bind(&RunSynchronousClosure, closure, | 1535 base::Bind(&RunSynchronousClosure, closure, |
| 1523 base::Unretained(trace_event_name), | 1536 base::Unretained(trace_event_name), |
| 1524 base::Unretained(&event))); | 1537 base::Unretained(&event))); |
| 1525 event.Wait(); | 1538 event.Wait(); |
| 1526 } | 1539 } |
| 1527 } | 1540 } |
| 1528 | 1541 |
| 1542 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.
| |
| 1543 webrtc::PeerConnectionInterface::IceConnectionState new_state) { | |
| 1544 if (ice_state_seen_[new_state]) | |
| 1545 return; | |
| 1546 ice_state_seen_[new_state] = true; | |
| 1547 UMA_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.ConnectionState", new_state, | |
| 1548 webrtc::PeerConnectionInterface::kIceConnectionMax); | |
| 1549 } | |
| 1550 | |
| 1551 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.
| |
| 1552 num_local_candidates_ipv6_ = 0; | |
| 1553 num_local_candidates_ipv4_ = 0; | |
| 1554 ice_connection_checking_start_ = base::TimeTicks(); | |
| 1555 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); | |
| 1556 } | |
| 1529 } // namespace content | 1557 } // namespace content |
| OLD | NEW |