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

Unified Diff: third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp

Issue 2095643002: Add RTCPeerConnection RAPPOR metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: record metrics only for connected PCs Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp
diff --git a/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp b/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp
index 407b6293593bba645eda68dd5a52731ccfb3cfcb..2cc74fafa433374229c0d67b9f69d3108d5335d2 100644
--- a/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp
+++ b/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp
@@ -46,6 +46,7 @@
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
+#include "core/frame/HostsUsingFeatures.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/UseCounter.h"
#include "core/html/VoidCallback.h"
@@ -984,6 +985,8 @@ RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
// There was an early state transition. Don't miss it!
channel->didChangeReadyState(handlerState);
}
+ m_hasDataChannels = true;
+
return channel;
}
@@ -1106,6 +1109,7 @@ void RTCPeerConnection::didAddRemoteDataChannel(WebRTCDataChannelHandler* handle
RTCDataChannel* channel = RTCDataChannel::create(getExecutionContext(), wrapUnique(handler));
scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachannel, false, false, channel));
+ m_hasDataChannels = true;
}
void RTCPeerConnection::releasePeerConnectionHandler()
@@ -1170,6 +1174,9 @@ bool RTCPeerConnection::setIceConnectionState(ICEConnectionState iceConnectionSt
{
if (m_iceConnectionState != ICEConnectionStateClosed && m_iceConnectionState != iceConnectionState) {
m_iceConnectionState = iceConnectionState;
+ if (m_iceConnectionState == ICEConnectionStateConnected)
+ recordRapporMetrics();
+
return true;
}
return false;
@@ -1225,6 +1232,28 @@ void RTCPeerConnection::dispatchScheduledEvent()
events.clear();
}
+void RTCPeerConnection::recordRapporMetrics()
+{
+ Document* document = toDocument(getExecutionContext());
+ for (const auto& stream : m_localStreams) {
+ if (stream->getAudioTracks().size() > 0)
+ HostsUsingFeatures::countAnyWorld(*document, HostsUsingFeatures::Feature::RTCPeerConnectionAudio);
+ if (stream->getVideoTracks().size() > 0)
+ HostsUsingFeatures::countAnyWorld(*document, HostsUsingFeatures::Feature::RTCPeerConnectionVideo);
+ }
+
+ for (const auto& stream : m_remoteStreams) {
+ if (stream->getAudioTracks().size() > 0)
+ HostsUsingFeatures::countAnyWorld(*document, HostsUsingFeatures::Feature::RTCPeerConnectionAudio);
+ if (stream->getVideoTracks().size() > 0)
+ HostsUsingFeatures::countAnyWorld(*document, HostsUsingFeatures::Feature::RTCPeerConnectionVideo);
+ }
+
+ if (m_hasDataChannels)
+ HostsUsingFeatures::countAnyWorld(*document, HostsUsingFeatures::Feature::RTCPeerConnectionDataChannel);
+
+}
+
DEFINE_TRACE(RTCPeerConnection)
{
visitor->trace(m_localStreams);
« no previous file with comments | « third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.h ('k') | tools/metrics/rappor/rappor.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698