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

Side by Side Diff: third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp

Issue 2363673002: Promise-based RTCPeerConnection::getStats implementation. (Closed)
Patch Set: RTCStatsReport.idl behind getStats-flag instead of updating virtual/stable/webexposed/global-interf… Created 4 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "modules/peerconnection/RTCDataChannelEvent.h" 62 #include "modules/peerconnection/RTCDataChannelEvent.h"
63 #include "modules/peerconnection/RTCIceCandidateEvent.h" 63 #include "modules/peerconnection/RTCIceCandidateEvent.h"
64 #include "modules/peerconnection/RTCOfferOptions.h" 64 #include "modules/peerconnection/RTCOfferOptions.h"
65 #include "modules/peerconnection/RTCPeerConnectionErrorCallback.h" 65 #include "modules/peerconnection/RTCPeerConnectionErrorCallback.h"
66 #include "modules/peerconnection/RTCSessionDescription.h" 66 #include "modules/peerconnection/RTCSessionDescription.h"
67 #include "modules/peerconnection/RTCSessionDescriptionCallback.h" 67 #include "modules/peerconnection/RTCSessionDescriptionCallback.h"
68 #include "modules/peerconnection/RTCSessionDescriptionInit.h" 68 #include "modules/peerconnection/RTCSessionDescriptionInit.h"
69 #include "modules/peerconnection/RTCSessionDescriptionRequestImpl.h" 69 #include "modules/peerconnection/RTCSessionDescriptionRequestImpl.h"
70 #include "modules/peerconnection/RTCSessionDescriptionRequestPromiseImpl.h" 70 #include "modules/peerconnection/RTCSessionDescriptionRequestPromiseImpl.h"
71 #include "modules/peerconnection/RTCStatsCallback.h" 71 #include "modules/peerconnection/RTCStatsCallback.h"
72 #include "modules/peerconnection/RTCStatsReport.h"
72 #include "modules/peerconnection/RTCStatsRequestImpl.h" 73 #include "modules/peerconnection/RTCStatsRequestImpl.h"
73 #include "modules/peerconnection/RTCVoidRequestImpl.h" 74 #include "modules/peerconnection/RTCVoidRequestImpl.h"
74 #include "modules/peerconnection/RTCVoidRequestPromiseImpl.h" 75 #include "modules/peerconnection/RTCVoidRequestPromiseImpl.h"
75 #include "platform/RuntimeEnabledFeatures.h" 76 #include "platform/RuntimeEnabledFeatures.h"
76 #include "platform/peerconnection/RTCAnswerOptionsPlatform.h" 77 #include "platform/peerconnection/RTCAnswerOptionsPlatform.h"
77 #include "platform/peerconnection/RTCConfiguration.h" 78 #include "platform/peerconnection/RTCConfiguration.h"
78 #include "platform/peerconnection/RTCOfferOptionsPlatform.h" 79 #include "platform/peerconnection/RTCOfferOptionsPlatform.h"
79 #include "public/platform/Platform.h" 80 #include "public/platform/Platform.h"
80 #include "public/platform/WebCryptoAlgorithmParams.h" 81 #include "public/platform/WebCryptoAlgorithmParams.h"
81 #include "public/platform/WebMediaStream.h" 82 #include "public/platform/WebMediaStream.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 offerToReceiveVideo = 0; 367 offerToReceiveVideo = 0;
367 if (DictionaryHelper::get(options, "offerToReceiveAudio", offerToReceiveAudi o) && offerToReceiveAudio < 0) 368 if (DictionaryHelper::get(options, "offerToReceiveAudio", offerToReceiveAudi o) && offerToReceiveAudio < 0)
368 offerToReceiveAudio = 0; 369 offerToReceiveAudio = 0;
369 DictionaryHelper::get(options, "voiceActivityDetection", voiceActivityDetect ion); 370 DictionaryHelper::get(options, "voiceActivityDetection", voiceActivityDetect ion);
370 DictionaryHelper::get(options, "iceRestart", iceRestart); 371 DictionaryHelper::get(options, "iceRestart", iceRestart);
371 372
372 RTCOfferOptionsPlatform* rtcOfferOptions = RTCOfferOptionsPlatform::create(o fferToReceiveVideo, offerToReceiveAudio, voiceActivityDetection, iceRestart); 373 RTCOfferOptionsPlatform* rtcOfferOptions = RTCOfferOptionsPlatform::create(o fferToReceiveVideo, offerToReceiveAudio, voiceActivityDetection, iceRestart);
373 return rtcOfferOptions; 374 return rtcOfferOptions;
374 } 375 }
375 376
377 // Helper class for |RTCPeerConnection::getStats(ScriptState*, MediaStreamTrack* )|
378 class WebRTCStatsReportCallbackResolver : public WebRTCStatsReportCallback {
379 public:
380 // Takes ownership of |resolver|.
381 static std::unique_ptr<WebRTCStatsReportCallback> create(ScriptPromiseResolv er* resolver)
382 {
383 return std::unique_ptr<WebRTCStatsReportCallback>(new WebRTCStatsReportC allbackResolver(resolver));
384 }
385
386 ~WebRTCStatsReportCallbackResolver() override {}
387
388 private:
389 WebRTCStatsReportCallbackResolver(ScriptPromiseResolver* resolver)
390 : m_resolver(resolver) {}
391
392 void OnStatsDelivered(std::unique_ptr<WebRTCStatsReport> report) override
393 {
394 m_resolver->resolve(new RTCStatsReport(std::move(report)));
395 }
396
397 Persistent<ScriptPromiseResolver> m_resolver;
398 };
399
376 } // namespace 400 } // namespace
377 401
378 RTCPeerConnection::EventWrapper::EventWrapper( 402 RTCPeerConnection::EventWrapper::EventWrapper(
379 Event* event, 403 Event* event,
380 std::unique_ptr<BoolFunction> function) 404 std::unique_ptr<BoolFunction> function)
381 : m_event(event) 405 : m_event(event)
382 , m_setupFunction(std::move(function)) 406 , m_setupFunction(std::move(function))
383 { 407 {
384 } 408 }
385 409
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 m_peerHandler->getStats(statsRequest); 990 m_peerHandler->getStats(statsRequest);
967 991
968 resolver->resolve(); 992 resolver->resolve();
969 return promise; 993 return promise;
970 } 994 }
971 995
972 ScriptPromise RTCPeerConnection::getStats(ScriptState* scriptState, MediaStreamT rack* selector) 996 ScriptPromise RTCPeerConnection::getStats(ScriptState* scriptState, MediaStreamT rack* selector)
973 { 997 {
974 ExecutionContext* context = scriptState->getExecutionContext(); 998 ExecutionContext* context = scriptState->getExecutionContext();
975 UseCounter::count(context, UseCounter::RTCPeerConnectionGetStats); 999 UseCounter::count(context, UseCounter::RTCPeerConnectionGetStats);
976 // TODO(hbos): Implement new |getStats| function. crbug.com/627816 1000
977 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea te(NotSupportedError, "getStats(optional MediaStreamTrack?) has not been impleme nted yet.")); 1001 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
1002 ScriptPromise promise = resolver->promise();
1003 m_peerHandler->getStats(WebRTCStatsReportCallbackResolver::create(resolver)) ;
1004
1005 return promise;
978 } 1006 }
979 1007
980 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction ary& options, ExceptionState& exceptionState) 1008 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction ary& options, ExceptionState& exceptionState)
981 { 1009 {
982 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 1010 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
983 return nullptr; 1011 return nullptr;
984 1012
985 WebRTCDataChannelInit init; 1013 WebRTCDataChannelInit init;
986 DictionaryHelper::get(options, "ordered", init.ordered); 1014 DictionaryHelper::get(options, "ordered", init.ordered);
987 DictionaryHelper::get(options, "negotiated", init.negotiated); 1015 DictionaryHelper::get(options, "negotiated", init.negotiated);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 { 1307 {
1280 visitor->trace(m_localStreams); 1308 visitor->trace(m_localStreams);
1281 visitor->trace(m_remoteStreams); 1309 visitor->trace(m_remoteStreams);
1282 visitor->trace(m_dispatchScheduledEventRunner); 1310 visitor->trace(m_dispatchScheduledEventRunner);
1283 visitor->trace(m_scheduledEvents); 1311 visitor->trace(m_scheduledEvents);
1284 EventTargetWithInlineData::trace(visitor); 1312 EventTargetWithInlineData::trace(visitor);
1285 ActiveDOMObject::trace(visitor); 1313 ActiveDOMObject::trace(visitor);
1286 } 1314 }
1287 1315
1288 } // namespace blink 1316 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698