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

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

Issue 2007923003: Use Init dictionaries in RTCPeerConnection legacy methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test expectation Created 4 years, 7 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 148
149 WebRTCAnswerOptions convertToWebRTCAnswerOptions(const RTCAnswerOptions& options ) 149 WebRTCAnswerOptions convertToWebRTCAnswerOptions(const RTCAnswerOptions& options )
150 { 150 {
151 return WebRTCAnswerOptions(RTCAnswerOptionsPlatform::create( 151 return WebRTCAnswerOptions(RTCAnswerOptionsPlatform::create(
152 options.hasVoiceActivityDetection() ? options.voiceActivityDetection() : true)); 152 options.hasVoiceActivityDetection() ? options.voiceActivityDetection() : true));
153 } 153 }
154 154
155 WebRTCICECandidate convertToWebRTCIceCandidate(const RTCIceCandidateInitOrRTCIce Candidate& candidate) 155 WebRTCICECandidate convertToWebRTCIceCandidate(const RTCIceCandidateInitOrRTCIce Candidate& candidate)
156 { 156 {
157 DCHECK(!candidate.isNull());
157 if (candidate.isRTCIceCandidateInit()) { 158 if (candidate.isRTCIceCandidateInit()) {
158 const RTCIceCandidateInit& iceCandidateInit = candidate.getAsRTCIceCandi dateInit(); 159 const RTCIceCandidateInit& iceCandidateInit = candidate.getAsRTCIceCandi dateInit();
159 return WebRTCICECandidate(iceCandidateInit.candidate(), iceCandidateInit .sdpMid(), iceCandidateInit.sdpMLineIndex()); 160 unsigned short sdpMLineIndex = iceCandidateInit.hasSdpMLineIndex() ? ice CandidateInit.sdpMLineIndex() : 0;
hta - Chromium 2016/05/26 04:56:41 Count the number of times this zeroes, and add a T
Guido Urdaneta 2016/05/26 14:37:36 Done.
161 return WebRTCICECandidate(iceCandidateInit.candidate(), iceCandidateInit .sdpMid(), sdpMLineIndex);
160 } 162 }
161 163
162 DCHECK(candidate.isRTCIceCandidate()); 164 DCHECK(candidate.isRTCIceCandidate());
163 return candidate.getAsRTCIceCandidate()->webCandidate(); 165 return candidate.getAsRTCIceCandidate()->webCandidate();
164 } 166 }
165 167
166 // Helper class for RTCPeerConnection::generateCertificate. 168 // Helper class for RTCPeerConnection::generateCertificate.
167 class WebRTCCertificateObserver : public WebRTCCertificateCallback { 169 class WebRTCCertificateObserver : public WebRTCCertificateCallback {
168 public: 170 public:
169 // Takes ownership of |resolver|. 171 // Takes ownership of |resolver|.
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 if (m_signalingState == SignalingStateClosed) 571 if (m_signalingState == SignalingStateClosed)
570 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage)); 572 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage));
571 573
572 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 574 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
573 ScriptPromise promise = resolver->promise(); 575 ScriptPromise promise = resolver->promise();
574 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver); 576 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver);
575 m_peerHandler->setLocalDescription(request, WebRTCSessionDescription(session DescriptionInit.type(), sessionDescriptionInit.sdp())); 577 m_peerHandler->setLocalDescription(request, WebRTCSessionDescription(session DescriptionInit.type(), sessionDescriptionInit.sdp()));
576 return promise; 578 return promise;
577 } 579 }
578 580
579 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, R TCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCPeer ConnectionErrorCallback* errorCallback) 581 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, c onst RTCSessionDescriptionInit& sessionDescriptionInit, VoidCallback* successCal lback, RTCPeerConnectionErrorCallback* errorCallback)
580 { 582 {
581 ExecutionContext* context = scriptState->getExecutionContext(); 583 ExecutionContext* context = scriptState->getExecutionContext();
582 if (successCallback && errorCallback) { 584 if (successCallback && errorCallback) {
583 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDescript ionLegacyCompliant); 585 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDescript ionLegacyCompliant);
584 } else { 586 } else {
585 if (!successCallback) 587 if (!successCallback)
586 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoSuccessCallback); 588 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoSuccessCallback);
587 if (!errorCallback) 589 if (!errorCallback)
588 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoFailureCallback); 590 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoFailureCallback);
589 } 591 }
590 592
591 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) ) 593 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) )
592 return ScriptPromise::castUndefined(scriptState); 594 return ScriptPromise::castUndefined(scriptState);
593 595
594 DCHECK(sessionDescription);
595
596 RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(), this, successCallback, errorCallback); 596 RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(), this, successCallback, errorCallback);
597 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe scription()); 597 m_peerHandler->setLocalDescription(request, WebRTCSessionDescription(session DescriptionInit.type(), sessionDescriptionInit.sdp()));
598 return ScriptPromise::castUndefined(scriptState); 598 return ScriptPromise::castUndefined(scriptState);
599 } 599 }
600 600
601 RTCSessionDescription* RTCPeerConnection::localDescription() 601 RTCSessionDescription* RTCPeerConnection::localDescription()
602 { 602 {
603 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip tion(); 603 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip tion();
604 if (webSessionDescription.isNull()) 604 if (webSessionDescription.isNull())
605 return nullptr; 605 return nullptr;
606 606
607 return RTCSessionDescription::create(webSessionDescription); 607 return RTCSessionDescription::create(webSessionDescription);
608 } 608 }
609 609
610 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState, const RTCSessionDescriptionInit& sessionDescriptionInit) 610 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState, const RTCSessionDescriptionInit& sessionDescriptionInit)
611 { 611 {
612 if (m_signalingState == SignalingStateClosed) 612 if (m_signalingState == SignalingStateClosed)
613 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage)); 613 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage));
614 614
615 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 615 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
616 ScriptPromise promise = resolver->promise(); 616 ScriptPromise promise = resolver->promise();
617 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver); 617 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver);
618 m_peerHandler->setRemoteDescription(request, WebRTCSessionDescription(sessio nDescriptionInit.type(), sessionDescriptionInit.sdp())); 618 m_peerHandler->setRemoteDescription(request, WebRTCSessionDescription(sessio nDescriptionInit.type(), sessionDescriptionInit.sdp()));
619 return promise; 619 return promise;
620 } 620 }
621 621
622 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState, RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCPee rConnectionErrorCallback* errorCallback) 622 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState, const RTCSessionDescriptionInit& sessionDescriptionInit, VoidCallback* successCa llback, RTCPeerConnectionErrorCallback* errorCallback)
623 { 623 {
624 ExecutionContext* context = scriptState->getExecutionContext(); 624 ExecutionContext* context = scriptState->getExecutionContext();
625 if (successCallback && errorCallback) { 625 if (successCallback && errorCallback) {
626 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDescrip tionLegacyCompliant); 626 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDescrip tionLegacyCompliant);
627 } else { 627 } else {
628 if (!successCallback) 628 if (!successCallback)
629 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoSuccessCallback); 629 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoSuccessCallback);
630 if (!errorCallback) 630 if (!errorCallback)
631 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoFailureCallback); 631 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoFailureCallback);
632 } 632 }
633 633
634 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) ) 634 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) )
635 return ScriptPromise::castUndefined(scriptState); 635 return ScriptPromise::castUndefined(scriptState);
636 636
637 DCHECK(sessionDescription);
638
639 RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(), this, successCallback, errorCallback); 637 RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(), this, successCallback, errorCallback);
640 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD escription()); 638 m_peerHandler->setRemoteDescription(request, WebRTCSessionDescription(sessio nDescriptionInit.type(), sessionDescriptionInit.sdp()));
641 return ScriptPromise::castUndefined(scriptState); 639 return ScriptPromise::castUndefined(scriptState);
642 } 640 }
643 641
644 RTCSessionDescription* RTCPeerConnection::remoteDescription() 642 RTCSessionDescription* RTCPeerConnection::remoteDescription()
645 { 643 {
646 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri ption(); 644 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri ption();
647 if (webSessionDescription.isNull()) 645 if (webSessionDescription.isNull())
648 return nullptr; 646 return nullptr;
649 647
650 return RTCSessionDescription::create(webSessionDescription); 648 return RTCSessionDescription::create(webSessionDescription);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 ScriptPromise promise = resolver->promise(); 775 ScriptPromise promise = resolver->promise();
778 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver); 776 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver);
779 WebRTCICECandidate webCandidate = convertToWebRTCIceCandidate(candidate); 777 WebRTCICECandidate webCandidate = convertToWebRTCIceCandidate(candidate);
780 bool implemented = m_peerHandler->addICECandidate(request, webCandidate); 778 bool implemented = m_peerHandler->addICECandidate(request, webCandidate);
781 if (!implemented) 779 if (!implemented)
782 resolver->reject(DOMException::create(OperationError, "This operation co uld not be completed.")); 780 resolver->reject(DOMException::create(OperationError, "This operation co uld not be completed."));
783 781
784 return promise; 782 return promise;
785 } 783 }
786 784
787 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, RTCIc eCandidate* iceCandidate, VoidCallback* successCallback, RTCPeerConnectionErrorC allback* errorCallback) 785 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const RTCIceCandidateInitOrRTCIceCandidate& candidate, VoidCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback)
788 { 786 {
789 DCHECK(iceCandidate);
790 DCHECK(successCallback); 787 DCHECK(successCallback);
791 DCHECK(errorCallback); 788 DCHECK(errorCallback);
792 789
793 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) ) 790 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) )
794 return ScriptPromise::castUndefined(scriptState); 791 return ScriptPromise::castUndefined(scriptState);
795 792
793 if (isIceCandidateMissingSdp(candidate))
794 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr ror(scriptState->isolate(), "Candidate missing values for both sdpMid and sdpMLi neIndex"));
795
796 RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(), this, successCallback, errorCallback); 796 RTCVoidRequest* request = RTCVoidRequestImpl::create(getExecutionContext(), this, successCallback, errorCallback);
797 bool implemented = m_peerHandler->addICECandidate(request, iceCandidate->web Candidate()); 797 WebRTCICECandidate webCandidate = convertToWebRTCIceCandidate(candidate);
798 bool implemented = m_peerHandler->addICECandidate(request, webCandidate);
798 if (!implemented) 799 if (!implemented)
799 asyncCallErrorCallback(errorCallback, DOMException::create(OperationErro r, "This operation could not be completed.")); 800 asyncCallErrorCallback(errorCallback, DOMException::create(OperationErro r, "This operation could not be completed."));
800 801
801 return ScriptPromise::castUndefined(scriptState); 802 return ScriptPromise::castUndefined(scriptState);
802 } 803 }
803 804
804 String RTCPeerConnection::signalingState() const 805 String RTCPeerConnection::signalingState() const
805 { 806 {
806 switch (m_signalingState) { 807 switch (m_signalingState) {
807 case SignalingStateStable: 808 case SignalingStateStable:
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 { 1214 {
1214 visitor->trace(m_localStreams); 1215 visitor->trace(m_localStreams);
1215 visitor->trace(m_remoteStreams); 1216 visitor->trace(m_remoteStreams);
1216 visitor->trace(m_dispatchScheduledEventRunner); 1217 visitor->trace(m_dispatchScheduledEventRunner);
1217 visitor->trace(m_scheduledEvents); 1218 visitor->trace(m_scheduledEvents);
1218 EventTargetWithInlineData::trace(visitor); 1219 EventTargetWithInlineData::trace(visitor);
1219 ActiveDOMObject::trace(visitor); 1220 ActiveDOMObject::trace(visitor);
1220 } 1221 }
1221 1222
1222 } // namespace blink 1223 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698