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

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

Issue 1661493002: Add promise-based addIceCandidate, setLocalDescription and setRemoteDescription to RTCPeerConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some philipj's comments Created 4 years, 10 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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "modules/mediastream/RTCPeerConnection.h" 31 #include "modules/mediastream/RTCPeerConnection.h"
32 32
33 #include "bindings/core/v8/ArrayValue.h" 33 #include "bindings/core/v8/ArrayValue.h"
34 #include "bindings/core/v8/ExceptionMessages.h" 34 #include "bindings/core/v8/ExceptionMessages.h"
35 #include "bindings/core/v8/ExceptionState.h" 35 #include "bindings/core/v8/ExceptionState.h"
36 #include "bindings/core/v8/Nullable.h" 36 #include "bindings/core/v8/Nullable.h"
37 #include "bindings/core/v8/ScriptPromiseResolver.h" 37 #include "bindings/core/v8/ScriptPromiseResolver.h"
38 #include "bindings/core/v8/V8ThrowException.h"
39 #include "bindings/modules/v8/UnionTypesModules.h"
38 #include "bindings/modules/v8/V8RTCCertificate.h" 40 #include "bindings/modules/v8/V8RTCCertificate.h"
39 #include "core/dom/Document.h" 41 #include "core/dom/Document.h"
40 #include "core/dom/ExceptionCode.h" 42 #include "core/dom/ExceptionCode.h"
41 #include "core/dom/ExecutionContext.h" 43 #include "core/dom/ExecutionContext.h"
42 #include "core/frame/LocalFrame.h" 44 #include "core/frame/LocalFrame.h"
43 #include "core/frame/UseCounter.h" 45 #include "core/frame/UseCounter.h"
44 #include "core/html/VoidCallback.h" 46 #include "core/html/VoidCallback.h"
45 #include "core/loader/FrameLoader.h" 47 #include "core/loader/FrameLoader.h"
46 #include "core/loader/FrameLoaderClient.h" 48 #include "core/loader/FrameLoaderClient.h"
47 #include "modules/crypto/CryptoResultImpl.h" 49 #include "modules/crypto/CryptoResultImpl.h"
48 #include "modules/mediastream/MediaConstraintsImpl.h" 50 #include "modules/mediastream/MediaConstraintsImpl.h"
49 #include "modules/mediastream/MediaStreamEvent.h" 51 #include "modules/mediastream/MediaStreamEvent.h"
50 #include "modules/mediastream/RTCDTMFSender.h" 52 #include "modules/mediastream/RTCDTMFSender.h"
51 #include "modules/mediastream/RTCDataChannel.h" 53 #include "modules/mediastream/RTCDataChannel.h"
52 #include "modules/mediastream/RTCDataChannelEvent.h" 54 #include "modules/mediastream/RTCDataChannelEvent.h"
53 #include "modules/mediastream/RTCErrorCallback.h" 55 #include "modules/mediastream/RTCErrorCallback.h"
54 #include "modules/mediastream/RTCIceCandidateEvent.h" 56 #include "modules/mediastream/RTCIceCandidateEvent.h"
55 #include "modules/mediastream/RTCSessionDescription.h" 57 #include "modules/mediastream/RTCSessionDescription.h"
56 #include "modules/mediastream/RTCSessionDescriptionCallback.h" 58 #include "modules/mediastream/RTCSessionDescriptionCallback.h"
59 #include "modules/mediastream/RTCSessionDescriptionInit.h"
57 #include "modules/mediastream/RTCSessionDescriptionRequestImpl.h" 60 #include "modules/mediastream/RTCSessionDescriptionRequestImpl.h"
58 #include "modules/mediastream/RTCStatsCallback.h" 61 #include "modules/mediastream/RTCStatsCallback.h"
59 #include "modules/mediastream/RTCStatsRequestImpl.h" 62 #include "modules/mediastream/RTCStatsRequestImpl.h"
60 #include "modules/mediastream/RTCVoidRequestImpl.h" 63 #include "modules/mediastream/RTCVoidRequestImpl.h"
64 #include "modules/mediastream/RTCVoidRequestPromiseImpl.h"
65 #include "platform/Timer.h"
61 #include "platform/mediastream/RTCConfiguration.h" 66 #include "platform/mediastream/RTCConfiguration.h"
62 #include "platform/mediastream/RTCOfferOptions.h" 67 #include "platform/mediastream/RTCOfferOptions.h"
63 #include "public/platform/Platform.h" 68 #include "public/platform/Platform.h"
64 #include "public/platform/WebCryptoAlgorithmParams.h" 69 #include "public/platform/WebCryptoAlgorithmParams.h"
65 #include "public/platform/WebCryptoUtil.h" 70 #include "public/platform/WebCryptoUtil.h"
66 #include "public/platform/WebMediaStream.h" 71 #include "public/platform/WebMediaStream.h"
67 #include "public/platform/WebRTCCertificate.h" 72 #include "public/platform/WebRTCCertificate.h"
68 #include "public/platform/WebRTCCertificateGenerator.h" 73 #include "public/platform/WebRTCCertificateGenerator.h"
69 #include "public/platform/WebRTCConfiguration.h" 74 #include "public/platform/WebRTCConfiguration.h"
70 #include "public/platform/WebRTCDataChannelHandler.h" 75 #include "public/platform/WebRTCDataChannelHandler.h"
71 #include "public/platform/WebRTCDataChannelInit.h" 76 #include "public/platform/WebRTCDataChannelInit.h"
72 #include "public/platform/WebRTCICECandidate.h" 77 #include "public/platform/WebRTCICECandidate.h"
73 #include "public/platform/WebRTCKeyParams.h" 78 #include "public/platform/WebRTCKeyParams.h"
74 #include "public/platform/WebRTCOfferOptions.h" 79 #include "public/platform/WebRTCOfferOptions.h"
75 #include "public/platform/WebRTCSessionDescription.h" 80 #include "public/platform/WebRTCSessionDescription.h"
76 #include "public/platform/WebRTCSessionDescriptionRequest.h" 81 #include "public/platform/WebRTCSessionDescriptionRequest.h"
77 #include "public/platform/WebRTCStatsRequest.h" 82 #include "public/platform/WebRTCStatsRequest.h"
78 #include "public/platform/WebRTCVoidRequest.h" 83 #include "public/platform/WebRTCVoidRequest.h"
79 84
80 namespace blink { 85 namespace blink {
81 86
82 namespace { 87 namespace {
83 88
84 static bool throwExceptionIfSignalingStateClosed(RTCPeerConnection::SignalingSta te state, ExceptionState& exceptionState) 89 const char kSignalingStateClosedMsg[] = "The RTCPeerConnection's signalingState is 'closed'.";
90 const char kDefaultErrorName[] = "InternalError";
91 const char kSessionDescriptionErrorName[] = "InvalidSessionDescription";
92
93 bool throwExceptionIfSignalingStateClosed(RTCPeerConnection::SignalingState stat e, ExceptionState& exceptionState)
85 { 94 {
86 if (state == RTCPeerConnection::SignalingStateClosed) { 95 if (state == RTCPeerConnection::SignalingStateClosed) {
87 exceptionState.throwDOMException(InvalidStateError, "The RTCPeerConnecti on's signalingState is 'closed'."); 96 exceptionState.throwDOMException(InvalidStateError, kSignalingStateClose dMsg);
88 return true; 97 return true;
89 } 98 }
90 99
91 return false; 100 return false;
92 } 101 }
93 102
103 class ErrorCallbackRunner final : public GarbageCollectedFinalized<ErrorCallback Runner> {
104 WTF_MAKE_NONCOPYABLE(ErrorCallbackRunner);
105 public:
106 static ErrorCallbackRunner* create(RTCErrorCallback*, const String& errorMsg );
107 ~ErrorCallbackRunner() = default;
108 void startAsync();
109
110 DECLARE_TRACE();
111
112 private:
113 ErrorCallbackRunner(RTCErrorCallback*, const String& errorMsg);
114 void timerFired(Timer<ErrorCallbackRunner>*);
115
116 Member<RTCErrorCallback> m_errorCallback;
117 String m_errorMsg;
118 Timer<ErrorCallbackRunner> m_timer;
philipj_slow 2016/02/09 18:59:17 To get the same timing as a promise rejection, wha
Guido Urdaneta 2016/02/10 07:05:13 Done. Layout test still needs fixing to verify tim
119 };
120
121 ErrorCallbackRunner* ErrorCallbackRunner::create(RTCErrorCallback* errorCallback , const String& errorMsg)
122 {
123 return new ErrorCallbackRunner(errorCallback, errorMsg);
124 }
125
126 ErrorCallbackRunner::ErrorCallbackRunner(RTCErrorCallback* errorCallback, const String& errorMsg)
127 : m_errorCallback(errorCallback)
128 , m_errorMsg(errorMsg)
129 , m_timer(this, &ErrorCallbackRunner::timerFired)
130 {
131 }
132
133 void ErrorCallbackRunner::startAsync()
134 {
135 m_timer.startOneShot(0, BLINK_FROM_HERE);
136 }
137
138 void ErrorCallbackRunner::timerFired(Timer<ErrorCallbackRunner>* timer)
139 {
140 m_errorCallback->handleEvent(m_errorMsg);
141 }
142
143 DEFINE_TRACE(ErrorCallbackRunner)
144 {
145 visitor->trace(m_errorCallback);
146 ErrorCallbackRunner::trace(visitor);
147 }
148
149 void asyncCallErrorCallback(RTCErrorCallback* errorCallback, const String& error Msg)
150 {
151 ErrorCallbackRunner* runner = ErrorCallbackRunner::create(errorCallback, err orMsg);
152 runner->startAsync();
153 }
154
155 bool callErrorCallbackIfSignalingStateClosed(RTCPeerConnection::SignalingState s tate, RTCErrorCallback* errorCallback)
156 {
157 if (state == RTCPeerConnection::SignalingStateClosed) {
158 if (errorCallback)
159 asyncCallErrorCallback(errorCallback, kSignalingStateClosedMsg);
160
161 return true;
162 }
163
164 return false;
165 }
166
167 bool isIceCandidateMissingSdp(const RTCIceCandidateInitOrRTCIceCandidate& candid ate)
168 {
169 if (candidate.isRTCIceCandidateInit()) {
170 const RTCIceCandidateInit& iceCandidateInit = candidate.getAsRTCIceCandi dateInit();
171 return !iceCandidateInit.hasSdpMid() && !iceCandidateInit.hasSdpMLineInd ex();
172 }
173
174 ASSERT(candidate.isRTCIceCandidate());
175 return false;
176 }
177
178 WebRTCICECandidate convertToWebRTCIceCandidate(const RTCIceCandidateInitOrRTCIce Candidate& candidate)
179 {
180 if (candidate.isRTCIceCandidateInit()) {
181 const RTCIceCandidateInit& iceCandidateInit = candidate.getAsRTCIceCandi dateInit();
182 return WebRTCICECandidate(iceCandidateInit.candidate(), iceCandidateInit .sdpMid(), iceCandidateInit.sdpMLineIndex());
183 }
184
185 ASSERT(candidate.isRTCIceCandidate());
186 return candidate.getAsRTCIceCandidate()->webCandidate();
187 }
188
94 // Helper class for RTCPeerConnection::generateCertificate. 189 // Helper class for RTCPeerConnection::generateCertificate.
95 class WebRTCCertificateObserver : public WebCallbacks<WebRTCCertificate*, void> { 190 class WebRTCCertificateObserver : public WebCallbacks<WebRTCCertificate*, void> {
96 public: 191 public:
97 // The created observer is responsible for deleting itself after onSuccess/o nError. To avoid memory 192 // The created observer is responsible for deleting itself after onSuccess/o nError. To avoid memory
98 // leak the observer should therefore be used in a WebRTCCertificateGenerato r::generateCertificate call 193 // leak the observer should therefore be used in a WebRTCCertificateGenerato r::generateCertificate call
99 // which is ensured to invoke one of these. Takes ownership of |resolver|. 194 // which is ensured to invoke one of these. Takes ownership of |resolver|.
100 static WebRTCCertificateObserver* create(ScriptPromiseResolver* resolver) 195 static WebRTCCertificateObserver* create(ScriptPromiseResolver* resolver)
101 { 196 {
102 return new WebRTCCertificateObserver(resolver); 197 return new WebRTCCertificateObserver(resolver);
103 } 198 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, medi aConstraints, mediaErrorState); 548 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, medi aConstraints, mediaErrorState);
454 if (mediaErrorState.hadException()) { 549 if (mediaErrorState.hadException()) {
455 mediaErrorState.raiseException(exceptionState); 550 mediaErrorState.raiseException(exceptionState);
456 return; 551 return;
457 } 552 }
458 553
459 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr eate(executionContext(), this, successCallback, errorCallback); 554 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr eate(executionContext(), this, successCallback, errorCallback);
460 m_peerHandler->createAnswer(request, constraints); 555 m_peerHandler->createAnswer(request, constraints);
461 } 556 }
462 557
463 void RTCPeerConnection::setLocalDescription(ExecutionContext* context, RTCSessio nDescription* sessionDescription, VoidCallback* successCallback, RTCErrorCallbac k* errorCallback, ExceptionState& exceptionState) 558 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, c onst RTCSessionDescriptionInit& sessionDescriptionInit)
559 {
560 if (m_signalingState == SignalingStateClosed)
561 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMsg));
562
563 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
564 ScriptPromise promise = resolver->promise();
565 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver, kSessionDescriptionErrorName);
566 m_peerHandler->setLocalDescription(request, WebRTCSessionDescription(session DescriptionInit.type(), sessionDescriptionInit.sdp()));
567 return promise;
568 }
569
570 ScriptPromise RTCPeerConnection::setLocalDescription(ExecutionContext* context, RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCErr orCallback* errorCallback)
464 { 571 {
465 if (successCallback && errorCallback) { 572 if (successCallback && errorCallback) {
466 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDescript ionLegacyCompliant); 573 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDescript ionLegacyCompliant);
467 } else { 574 } else {
468 if (!successCallback) 575 if (!successCallback)
469 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoSuccessCallback); 576 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoSuccessCallback);
470 if (!errorCallback) 577 if (!errorCallback)
471 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoFailureCallback); 578 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoFailureCallback);
472 } 579 }
473 580
474 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 581 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) )
475 return; 582 return ScriptPromise();
476 583
477 ASSERT(sessionDescription); 584 ASSERT(sessionDescription);
478 585
479 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback); 586 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback);
480 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe scription()); 587 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe scription());
588 return ScriptPromise();
481 } 589 }
482 590
483 RTCSessionDescription* RTCPeerConnection::localDescription() 591 RTCSessionDescription* RTCPeerConnection::localDescription()
484 { 592 {
485 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip tion(); 593 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip tion();
486 if (webSessionDescription.isNull()) 594 if (webSessionDescription.isNull())
487 return nullptr; 595 return nullptr;
488 596
489 return RTCSessionDescription::create(webSessionDescription); 597 return RTCSessionDescription::create(webSessionDescription);
490 } 598 }
491 599
492 void RTCPeerConnection::setRemoteDescription(ExecutionContext* context, RTCSessi onDescription* sessionDescription, VoidCallback* successCallback, RTCErrorCallba ck* errorCallback, ExceptionState& exceptionState) 600 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState, const RTCSessionDescriptionInit& sessionDescriptionInit)
601 {
602 if (m_signalingState == SignalingStateClosed)
603 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMsg));
604
605 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
606 ScriptPromise promise = resolver->promise();
607 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver, kSessionDescriptionErrorName);
608 m_peerHandler->setRemoteDescription(request, WebRTCSessionDescription(sessio nDescriptionInit.type(), sessionDescriptionInit.sdp()));
609 return promise;
610 }
611
612 ScriptPromise RTCPeerConnection::setRemoteDescription(ExecutionContext* context, RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCEr rorCallback* errorCallback)
493 { 613 {
494 if (successCallback && errorCallback) { 614 if (successCallback && errorCallback) {
495 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDescrip tionLegacyCompliant); 615 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDescrip tionLegacyCompliant);
496 } else { 616 } else {
497 if (!successCallback) 617 if (!successCallback)
498 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoSuccessCallback); 618 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoSuccessCallback);
499 if (!errorCallback) 619 if (!errorCallback)
500 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoFailureCallback); 620 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoFailureCallback);
501 } 621 }
502 622
503 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 623 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) )
504 return; 624 return ScriptPromise();
505 625
506 ASSERT(sessionDescription); 626 ASSERT(sessionDescription);
507 627
508 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback); 628 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback);
509 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD escription()); 629 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD escription());
630 return ScriptPromise();
510 } 631 }
511 632
512 RTCSessionDescription* RTCPeerConnection::remoteDescription() 633 RTCSessionDescription* RTCPeerConnection::remoteDescription()
513 { 634 {
514 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri ption(); 635 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri ption();
515 if (webSessionDescription.isNull()) 636 if (webSessionDescription.isNull())
516 return nullptr; 637 return nullptr;
517 638
518 return RTCSessionDescription::create(webSessionDescription); 639 return RTCSessionDescription::create(webSessionDescription);
519 } 640 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 // The observer will manage its own destruction as well as the resolver's de struction. 722 // The observer will manage its own destruction as well as the resolver's de struction.
602 certificateGenerator->generateCertificate( 723 certificateGenerator->generateCertificate(
603 keyParams.get(), 724 keyParams.get(),
604 toDocument(scriptState->executionContext())->url(), 725 toDocument(scriptState->executionContext())->url(),
605 toDocument(scriptState->executionContext())->firstPartyForCookies(), 726 toDocument(scriptState->executionContext())->firstPartyForCookies(),
606 certificateObserver); 727 certificateObserver);
607 728
608 return promise; 729 return promise;
609 } 730 }
610 731
611 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, Exception State& exceptionState) 732 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const RTCIceCandidateInitOrRTCIceCandidate& candidate)
612 { 733 {
613 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 734 if (m_signalingState == SignalingStateClosed)
614 return; 735 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMsg));
615 736
616 ASSERT(iceCandidate); 737 if (isIceCandidateMissingSdp(candidate))
738 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr ror(scriptState->isolate(), "Candidate missing values for both sdpMid and sdpMLi neIndex"));
617 739
618 bool valid = m_peerHandler->addICECandidate(iceCandidate->webCandidate()); 740 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
619 if (!valid) 741 ScriptPromise promise = resolver->promise();
620 exceptionState.throwDOMException(SyntaxError, "The ICE candidate could n ot be added."); 742 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver, kDefaultErrorName);
743 WebRTCICECandidate webCandidate = convertToWebRTCIceCandidate(candidate);
744 bool implemented = m_peerHandler->addICECandidate(request, webCandidate);
745 if (!implemented)
746 resolver->reject(DOMException::create(NotSupportedError, "This method is not yet implemented."));
747
748 return promise;
621 } 749 }
622 750
623 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, VoidCallb ack* successCallback, RTCErrorCallback* errorCallback, ExceptionState& exception State) 751 ScriptPromise RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, VoidCallback* successCallback, RTCErrorCallback* errorCallback)
624 { 752 {
625 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
626 return;
627
628 ASSERT(iceCandidate); 753 ASSERT(iceCandidate);
629 ASSERT(successCallback); 754 ASSERT(successCallback);
630 ASSERT(errorCallback); 755 ASSERT(errorCallback);
631 756
757 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) )
758 return ScriptPromise();
759
632 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback); 760 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback);
633
634 bool implemented = m_peerHandler->addICECandidate(request, iceCandidate->web Candidate()); 761 bool implemented = m_peerHandler->addICECandidate(request, iceCandidate->web Candidate());
635 if (!implemented) { 762 if (!implemented) {
philipj_slow 2016/02/09 18:59:17 Drop added { }?
Guido Urdaneta 2016/02/10 07:05:13 Done.
636 exceptionState.throwDOMException(NotSupportedError, "This method is not yet implemented."); 763 asyncCallErrorCallback(errorCallback, "This method is not yet implemente d.");
637 } 764 }
765
766 return ScriptPromise();
638 } 767 }
639 768
640 String RTCPeerConnection::signalingState() const 769 String RTCPeerConnection::signalingState() const
641 { 770 {
642 switch (m_signalingState) { 771 switch (m_signalingState) {
643 case SignalingStateStable: 772 case SignalingStateStable:
644 return "stable"; 773 return "stable";
645 case SignalingStateHaveLocalOffer: 774 case SignalingStateHaveLocalOffer:
646 return "have-local-offer"; 775 return "have-local-offer";
647 case SignalingStateHaveRemoteOffer: 776 case SignalingStateHaveRemoteOffer:
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 { 1178 {
1050 visitor->trace(m_localStreams); 1179 visitor->trace(m_localStreams);
1051 visitor->trace(m_remoteStreams); 1180 visitor->trace(m_remoteStreams);
1052 visitor->trace(m_dispatchScheduledEventRunner); 1181 visitor->trace(m_dispatchScheduledEventRunner);
1053 visitor->trace(m_scheduledEvents); 1182 visitor->trace(m_scheduledEvents);
1054 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor); 1183 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor);
1055 ActiveDOMObject::trace(visitor); 1184 ActiveDOMObject::trace(visitor);
1056 } 1185 }
1057 1186
1058 } // namespace blink 1187 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698