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

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

Issue 600163004: Add two UMA counters for IPv4 and IPv6 local candidates gathered in WebRTC PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reset for ice restarts and also only counts first component of first m line. Created 6 years, 2 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 } // namespace 384 } // namespace
385 385
386 RTCPeerConnectionHandler::RTCPeerConnectionHandler( 386 RTCPeerConnectionHandler::RTCPeerConnectionHandler(
387 blink::WebRTCPeerConnectionHandlerClient* client, 387 blink::WebRTCPeerConnectionHandlerClient* client,
388 PeerConnectionDependencyFactory* dependency_factory) 388 PeerConnectionDependencyFactory* dependency_factory)
389 : client_(client), 389 : client_(client),
390 dependency_factory_(dependency_factory), 390 dependency_factory_(dependency_factory),
391 frame_(NULL), 391 frame_(NULL),
392 peer_connection_tracker_(NULL), 392 peer_connection_tracker_(NULL),
393 num_data_channels_created_(0) { 393 num_data_channels_created_(0),
394 num_local_candidates_ipv4_(0),
395 num_local_candidates_ipv6_(0) {
394 g_peer_connection_handlers.Get().insert(this); 396 g_peer_connection_handlers.Get().insert(this);
395 } 397 }
396 398
397 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { 399 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() {
398 g_peer_connection_handlers.Get().erase(this); 400 g_peer_connection_handlers.Get().erase(this);
399 if (peer_connection_tracker_) 401 if (peer_connection_tracker_)
400 peer_connection_tracker_->UnregisterPeerConnection(this); 402 peer_connection_tracker_->UnregisterPeerConnection(this);
401 STLDeleteValues(&remote_streams_); 403 STLDeleteValues(&remote_streams_);
402 404
403 UMA_HISTOGRAM_COUNTS_10000( 405 UMA_HISTOGRAM_COUNTS_10000(
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 } 889 }
888 890
889 // Called any time the IceGatheringState changes 891 // Called any time the IceGatheringState changes
890 void RTCPeerConnectionHandler::OnIceGatheringChange( 892 void RTCPeerConnectionHandler::OnIceGatheringChange(
891 webrtc::PeerConnectionInterface::IceGatheringState new_state) { 893 webrtc::PeerConnectionInterface::IceGatheringState new_state) {
892 if (new_state == webrtc::PeerConnectionInterface::kIceGatheringComplete) { 894 if (new_state == webrtc::PeerConnectionInterface::kIceGatheringComplete) {
893 // If ICE gathering is completed, generate a NULL ICE candidate, 895 // If ICE gathering is completed, generate a NULL ICE candidate,
894 // to signal end of candidates. 896 // to signal end of candidates.
895 blink::WebRTCICECandidate null_candidate; 897 blink::WebRTCICECandidate null_candidate;
896 client_->didGenerateICECandidate(null_candidate); 898 client_->didGenerateICECandidate(null_candidate);
899
900 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4LocalCandidates",
901 num_local_candidates_ipv4_);
902
903 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6LocalCandidates",
904 num_local_candidates_ipv6_);
905 } else if (ice_gathering_current_state_ ==
juberti2 2014/09/26 01:45:37 wouldn't it be simpler to do this if new_state ==
906 webrtc::PeerConnectionInterface::kIceGatheringComplete &&
907 new_state != ice_gathering_current_state_) {
908 // ICE restarts will change gathering state back to "gathering",
909 // reset the counter.
910 num_local_candidates_ipv6_ = 0;
911 num_local_candidates_ipv4_ = 0;
897 } 912 }
898 913
899 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = 914 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state =
900 GetWebKitIceGatheringState(new_state); 915 GetWebKitIceGatheringState(new_state);
901 if (peer_connection_tracker_) 916 if (peer_connection_tracker_)
902 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); 917 peer_connection_tracker_->TrackIceGatheringStateChange(this, state);
903 client_->didChangeICEGatheringState(state); 918 client_->didChangeICEGatheringState(state);
919 ice_gathering_current_state_ = new_state;
904 } 920 }
905 921
906 void RTCPeerConnectionHandler::OnAddStream( 922 void RTCPeerConnectionHandler::OnAddStream(
907 webrtc::MediaStreamInterface* stream_interface) { 923 webrtc::MediaStreamInterface* stream_interface) {
908 DCHECK(stream_interface); 924 DCHECK(stream_interface);
909 DCHECK(remote_streams_.find(stream_interface) == remote_streams_.end()); 925 DCHECK(remote_streams_.find(stream_interface) == remote_streams_.end());
910 926
911 RemoteMediaStreamImpl* remote_stream = 927 RemoteMediaStreamImpl* remote_stream =
912 new RemoteMediaStreamImpl(stream_interface); 928 new RemoteMediaStreamImpl(stream_interface);
913 remote_streams_.insert( 929 remote_streams_.insert(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 return; 977 return;
962 } 978 }
963 blink::WebRTCICECandidate web_candidate; 979 blink::WebRTCICECandidate web_candidate;
964 web_candidate.initialize(base::UTF8ToUTF16(sdp), 980 web_candidate.initialize(base::UTF8ToUTF16(sdp),
965 base::UTF8ToUTF16(candidate->sdp_mid()), 981 base::UTF8ToUTF16(candidate->sdp_mid()),
966 candidate->sdp_mline_index()); 982 candidate->sdp_mline_index());
967 if (peer_connection_tracker_) 983 if (peer_connection_tracker_)
968 peer_connection_tracker_->TrackAddIceCandidate( 984 peer_connection_tracker_->TrackAddIceCandidate(
969 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL, true); 985 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL, true);
970 986
987 // Only the first m line's first component is tracked to avoid
988 // miscounting when doing BUNDLE or rtcp mux.
989 if (candidate->sdp_mline_index() == 0 &&
990 candidate->candidate().component() == 1) {
991 if (candidate->candidate().address().family() == AF_INET) {
992 num_local_candidates_ipv4_++;
993 } else if (candidate->candidate().address().family() == AF_INET6) {
994 num_local_candidates_ipv6_++;
995 } else {
996 NOTREACHED();
997 }
998 }
971 client_->didGenerateICECandidate(web_candidate); 999 client_->didGenerateICECandidate(web_candidate);
972 } 1000 }
973 1001
974 void RTCPeerConnectionHandler::OnDataChannel( 1002 void RTCPeerConnectionHandler::OnDataChannel(
975 webrtc::DataChannelInterface* data_channel) { 1003 webrtc::DataChannelInterface* data_channel) {
976 if (peer_connection_tracker_) 1004 if (peer_connection_tracker_)
977 peer_connection_tracker_->TrackCreateDataChannel( 1005 peer_connection_tracker_->TrackCreateDataChannel(
978 this, data_channel, PeerConnectionTracker::SOURCE_REMOTE); 1006 this, data_channel, PeerConnectionTracker::SOURCE_REMOTE);
979 1007
980 DVLOG(1) << "RTCPeerConnectionHandler::OnDataChannel " 1008 DVLOG(1) << "RTCPeerConnectionHandler::OnDataChannel "
(...skipping 20 matching lines...) Expand all
1001 webrtc::SessionDescriptionInterface* native_desc = 1029 webrtc::SessionDescriptionInterface* native_desc =
1002 dependency_factory_->CreateSessionDescription(type, sdp, error); 1030 dependency_factory_->CreateSessionDescription(type, sdp, error);
1003 1031
1004 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." 1032 LOG_IF(ERROR, !native_desc) << "Failed to create native session description."
1005 << " Type: " << type << " SDP: " << sdp; 1033 << " Type: " << type << " SDP: " << sdp;
1006 1034
1007 return native_desc; 1035 return native_desc;
1008 } 1036 }
1009 1037
1010 } // namespace content 1038 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698