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

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: return ScriptPromise(undefined) instead of ScriptPromise() 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/ScriptState.h"
39 #include "bindings/core/v8/ScriptValue.h"
40 #include "bindings/core/v8/V8ThrowException.h"
41 #include "bindings/modules/v8/UnionTypesModules.h"
38 #include "bindings/modules/v8/V8RTCCertificate.h" 42 #include "bindings/modules/v8/V8RTCCertificate.h"
39 #include "core/dom/Document.h" 43 #include "core/dom/Document.h"
40 #include "core/dom/ExceptionCode.h" 44 #include "core/dom/ExceptionCode.h"
41 #include "core/dom/ExecutionContext.h" 45 #include "core/dom/ExecutionContext.h"
46 #include "core/dom/Microtask.h"
42 #include "core/frame/Deprecation.h" 47 #include "core/frame/Deprecation.h"
43 #include "core/frame/LocalFrame.h" 48 #include "core/frame/LocalFrame.h"
44 #include "core/html/VoidCallback.h" 49 #include "core/html/VoidCallback.h"
45 #include "core/loader/FrameLoader.h" 50 #include "core/loader/FrameLoader.h"
46 #include "core/loader/FrameLoaderClient.h" 51 #include "core/loader/FrameLoaderClient.h"
47 #include "modules/crypto/CryptoResultImpl.h" 52 #include "modules/crypto/CryptoResultImpl.h"
48 #include "modules/mediastream/MediaConstraintsImpl.h" 53 #include "modules/mediastream/MediaConstraintsImpl.h"
49 #include "modules/mediastream/MediaStreamEvent.h" 54 #include "modules/mediastream/MediaStreamEvent.h"
50 #include "modules/mediastream/RTCDTMFSender.h" 55 #include "modules/mediastream/RTCDTMFSender.h"
51 #include "modules/mediastream/RTCDataChannel.h" 56 #include "modules/mediastream/RTCDataChannel.h"
52 #include "modules/mediastream/RTCDataChannelEvent.h" 57 #include "modules/mediastream/RTCDataChannelEvent.h"
53 #include "modules/mediastream/RTCErrorCallback.h" 58 #include "modules/mediastream/RTCErrorCallback.h"
54 #include "modules/mediastream/RTCIceCandidateEvent.h" 59 #include "modules/mediastream/RTCIceCandidateEvent.h"
55 #include "modules/mediastream/RTCSessionDescription.h" 60 #include "modules/mediastream/RTCSessionDescription.h"
56 #include "modules/mediastream/RTCSessionDescriptionCallback.h" 61 #include "modules/mediastream/RTCSessionDescriptionCallback.h"
62 #include "modules/mediastream/RTCSessionDescriptionInit.h"
57 #include "modules/mediastream/RTCSessionDescriptionRequestImpl.h" 63 #include "modules/mediastream/RTCSessionDescriptionRequestImpl.h"
58 #include "modules/mediastream/RTCStatsCallback.h" 64 #include "modules/mediastream/RTCStatsCallback.h"
59 #include "modules/mediastream/RTCStatsRequestImpl.h" 65 #include "modules/mediastream/RTCStatsRequestImpl.h"
60 #include "modules/mediastream/RTCVoidRequestImpl.h" 66 #include "modules/mediastream/RTCVoidRequestImpl.h"
67 #include "modules/mediastream/RTCVoidRequestPromiseImpl.h"
61 #include "platform/mediastream/RTCConfiguration.h" 68 #include "platform/mediastream/RTCConfiguration.h"
62 #include "platform/mediastream/RTCOfferOptions.h" 69 #include "platform/mediastream/RTCOfferOptions.h"
63 #include "public/platform/Platform.h" 70 #include "public/platform/Platform.h"
64 #include "public/platform/WebCryptoAlgorithmParams.h" 71 #include "public/platform/WebCryptoAlgorithmParams.h"
65 #include "public/platform/WebCryptoUtil.h" 72 #include "public/platform/WebCryptoUtil.h"
66 #include "public/platform/WebMediaStream.h" 73 #include "public/platform/WebMediaStream.h"
67 #include "public/platform/WebRTCCertificate.h" 74 #include "public/platform/WebRTCCertificate.h"
68 #include "public/platform/WebRTCCertificateGenerator.h" 75 #include "public/platform/WebRTCCertificateGenerator.h"
69 #include "public/platform/WebRTCConfiguration.h" 76 #include "public/platform/WebRTCConfiguration.h"
70 #include "public/platform/WebRTCDataChannelHandler.h" 77 #include "public/platform/WebRTCDataChannelHandler.h"
71 #include "public/platform/WebRTCDataChannelInit.h" 78 #include "public/platform/WebRTCDataChannelInit.h"
72 #include "public/platform/WebRTCICECandidate.h" 79 #include "public/platform/WebRTCICECandidate.h"
73 #include "public/platform/WebRTCKeyParams.h" 80 #include "public/platform/WebRTCKeyParams.h"
74 #include "public/platform/WebRTCOfferOptions.h" 81 #include "public/platform/WebRTCOfferOptions.h"
75 #include "public/platform/WebRTCSessionDescription.h" 82 #include "public/platform/WebRTCSessionDescription.h"
76 #include "public/platform/WebRTCSessionDescriptionRequest.h" 83 #include "public/platform/WebRTCSessionDescriptionRequest.h"
77 #include "public/platform/WebRTCStatsRequest.h" 84 #include "public/platform/WebRTCStatsRequest.h"
78 #include "public/platform/WebRTCVoidRequest.h" 85 #include "public/platform/WebRTCVoidRequest.h"
79 86
80 namespace blink { 87 namespace blink {
81 88
82 namespace { 89 namespace {
83 90
84 static bool throwExceptionIfSignalingStateClosed(RTCPeerConnection::SignalingSta te state, ExceptionState& exceptionState) 91 const char kSignalingStateClosedMessage[] = "The RTCPeerConnection's signalingSt ate is 'closed'.";
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 dMessage);
88 return true; 97 return true;
89 } 98 }
90 99
91 return false; 100 return false;
92 } 101 }
93 102
103 // Helper class for running error callbacks asynchronously
104 class ErrorCallbackTask : public WebTaskRunner::Task {
105 public:
106 static PassOwnPtr<ErrorCallbackTask> create(RTCErrorCallback* errorCallback, const String& errorMessage)
107 {
108 return adoptPtr(new ErrorCallbackTask(errorCallback, errorMessage));
109 }
110
111 ~ErrorCallbackTask() override = default;
112
113 void run() override
114 {
115 m_errorCallback->handleEvent(m_errorMessage);
116 }
117
118 private:
119 ErrorCallbackTask(RTCErrorCallback* errorCallback, const String& errorMessag e)
120 : m_errorCallback(errorCallback)
121 , m_errorMessage(errorMessage)
122 {
123 ASSERT(errorCallback);
124 }
125
126 Persistent<RTCErrorCallback> m_errorCallback;
127 String m_errorMessage;
128 };
129
130 void asyncCallErrorCallback(RTCErrorCallback* errorCallback, const String& error Message)
131 {
132 Microtask::enqueueMicrotask(ErrorCallbackTask::create(errorCallback, errorMe ssage));
133 }
134
135 bool callErrorCallbackIfSignalingStateClosed(RTCPeerConnection::SignalingState s tate, RTCErrorCallback* errorCallback)
136 {
137 if (state == RTCPeerConnection::SignalingStateClosed) {
138 if (errorCallback)
139 asyncCallErrorCallback(errorCallback, kSignalingStateClosedMessage);
140
141 return true;
142 }
143
144 return false;
145 }
146
147 bool isIceCandidateMissingSdp(const RTCIceCandidateInitOrRTCIceCandidate& candid ate)
148 {
149 if (candidate.isRTCIceCandidateInit()) {
150 const RTCIceCandidateInit& iceCandidateInit = candidate.getAsRTCIceCandi dateInit();
151 return !iceCandidateInit.hasSdpMid() && !iceCandidateInit.hasSdpMLineInd ex();
152 }
153
154 ASSERT(candidate.isRTCIceCandidate());
155 return false;
156 }
157
158 WebRTCICECandidate convertToWebRTCIceCandidate(const RTCIceCandidateInitOrRTCIce Candidate& candidate)
159 {
160 if (candidate.isRTCIceCandidateInit()) {
161 const RTCIceCandidateInit& iceCandidateInit = candidate.getAsRTCIceCandi dateInit();
162 return WebRTCICECandidate(iceCandidateInit.candidate(), iceCandidateInit .sdpMid(), iceCandidateInit.sdpMLineIndex());
163 }
164
165 ASSERT(candidate.isRTCIceCandidate());
166 return candidate.getAsRTCIceCandidate()->webCandidate();
167 }
168
94 // Helper class for RTCPeerConnection::generateCertificate. 169 // Helper class for RTCPeerConnection::generateCertificate.
95 class WebRTCCertificateObserver : public WebCallbacks<WebRTCCertificate*, void> { 170 class WebRTCCertificateObserver : public WebCallbacks<WebRTCCertificate*, void> {
96 public: 171 public:
97 // The created observer is responsible for deleting itself after onSuccess/o nError. To avoid memory 172 // 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 173 // 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|. 174 // which is ensured to invoke one of these. Takes ownership of |resolver|.
100 static WebRTCCertificateObserver* create(ScriptPromiseResolver* resolver) 175 static WebRTCCertificateObserver* create(ScriptPromiseResolver* resolver)
101 { 176 {
102 return new WebRTCCertificateObserver(resolver); 177 return new WebRTCCertificateObserver(resolver);
103 } 178 }
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, medi aConstraints, mediaErrorState); 528 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, medi aConstraints, mediaErrorState);
454 if (mediaErrorState.hadException()) { 529 if (mediaErrorState.hadException()) {
455 mediaErrorState.raiseException(exceptionState); 530 mediaErrorState.raiseException(exceptionState);
456 return; 531 return;
457 } 532 }
458 533
459 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr eate(executionContext(), this, successCallback, errorCallback); 534 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr eate(executionContext(), this, successCallback, errorCallback);
460 m_peerHandler->createAnswer(request, constraints); 535 m_peerHandler->createAnswer(request, constraints);
461 } 536 }
462 537
463 void RTCPeerConnection::setLocalDescription(ExecutionContext* context, RTCSessio nDescription* sessionDescription, VoidCallback* successCallback, RTCErrorCallbac k* errorCallback, ExceptionState& exceptionState) 538 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, c onst RTCSessionDescriptionInit& sessionDescriptionInit)
464 { 539 {
540 if (m_signalingState == SignalingStateClosed)
541 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage));
542
543 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
544 ScriptPromise promise = resolver->promise();
545 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver, InvalidAccessError);
546 m_peerHandler->setLocalDescription(request, WebRTCSessionDescription(session DescriptionInit.type(), sessionDescriptionInit.sdp()));
547 return promise;
548 }
549
550 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, R TCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCErro rCallback* errorCallback)
551 {
552 ExecutionContext* context = scriptState->executionContext();
465 if (successCallback && errorCallback) { 553 if (successCallback && errorCallback) {
466 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDescript ionLegacyCompliant); 554 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDescript ionLegacyCompliant);
467 } else { 555 } else {
468 if (!successCallback) 556 if (!successCallback)
469 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoSuccessCallback); 557 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoSuccessCallback);
470 if (!errorCallback) 558 if (!errorCallback)
471 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoFailureCallback); 559 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc riptionLegacyNoFailureCallback);
472 } 560 }
473 561
474 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 562 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) )
475 return; 563 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola te()));
philipj_slow 2016/02/18 02:31:56 Is this change observable? I thought it was the sa
476 564
477 ASSERT(sessionDescription); 565 ASSERT(sessionDescription);
478 566
479 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback); 567 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback);
480 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe scription()); 568 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe scription());
569 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate() ));
481 } 570 }
482 571
483 RTCSessionDescription* RTCPeerConnection::localDescription() 572 RTCSessionDescription* RTCPeerConnection::localDescription()
484 { 573 {
485 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip tion(); 574 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip tion();
486 if (webSessionDescription.isNull()) 575 if (webSessionDescription.isNull())
487 return nullptr; 576 return nullptr;
488 577
489 return RTCSessionDescription::create(webSessionDescription); 578 return RTCSessionDescription::create(webSessionDescription);
490 } 579 }
491 580
492 void RTCPeerConnection::setRemoteDescription(ExecutionContext* context, RTCSessi onDescription* sessionDescription, VoidCallback* successCallback, RTCErrorCallba ck* errorCallback, ExceptionState& exceptionState) 581 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState, const RTCSessionDescriptionInit& sessionDescriptionInit)
493 { 582 {
583 if (m_signalingState == SignalingStateClosed)
584 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage));
585
586 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
587 ScriptPromise promise = resolver->promise();
588 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver, InvalidAccessError);
589 m_peerHandler->setRemoteDescription(request, WebRTCSessionDescription(sessio nDescriptionInit.type(), sessionDescriptionInit.sdp()));
590 return promise;
591 }
592
593 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState, RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCErr orCallback* errorCallback)
594 {
595 ExecutionContext* context = scriptState->executionContext();
494 if (successCallback && errorCallback) { 596 if (successCallback && errorCallback) {
495 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDescrip tionLegacyCompliant); 597 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDescrip tionLegacyCompliant);
496 } else { 598 } else {
497 if (!successCallback) 599 if (!successCallback)
498 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoSuccessCallback); 600 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoSuccessCallback);
499 if (!errorCallback) 601 if (!errorCallback)
500 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoFailureCallback); 602 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes criptionLegacyNoFailureCallback);
501 } 603 }
502 604
503 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 605 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) )
504 return; 606 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola te()));
505 607
506 ASSERT(sessionDescription); 608 ASSERT(sessionDescription);
507 609
508 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback); 610 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback);
509 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD escription()); 611 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD escription());
612 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate() ));
510 } 613 }
511 614
512 RTCSessionDescription* RTCPeerConnection::remoteDescription() 615 RTCSessionDescription* RTCPeerConnection::remoteDescription()
513 { 616 {
514 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri ption(); 617 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri ption();
515 if (webSessionDescription.isNull()) 618 if (webSessionDescription.isNull())
516 return nullptr; 619 return nullptr;
517 620
518 return RTCSessionDescription::create(webSessionDescription); 621 return RTCSessionDescription::create(webSessionDescription);
519 } 622 }
(...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. 704 // The observer will manage its own destruction as well as the resolver's de struction.
602 certificateGenerator->generateCertificate( 705 certificateGenerator->generateCertificate(
603 keyParams.get(), 706 keyParams.get(),
604 toDocument(scriptState->executionContext())->url(), 707 toDocument(scriptState->executionContext())->url(),
605 toDocument(scriptState->executionContext())->firstPartyForCookies(), 708 toDocument(scriptState->executionContext())->firstPartyForCookies(),
606 certificateObserver); 709 certificateObserver);
607 710
608 return promise; 711 return promise;
609 } 712 }
610 713
611 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, Exception State& exceptionState) 714 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, const RTCIceCandidateInitOrRTCIceCandidate& candidate)
612 { 715 {
613 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 716 if (m_signalingState == SignalingStateClosed)
614 return; 717 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, kSignalingStateClosedMessage));
615 718
616 ASSERT(iceCandidate); 719 if (isIceCandidateMissingSdp(candidate))
720 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr ror(scriptState->isolate(), "Candidate missing values for both sdpMid and sdpMLi neIndex"));
617 721
618 bool valid = m_peerHandler->addICECandidate(iceCandidate->webCandidate()); 722 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
619 if (!valid) 723 ScriptPromise promise = resolver->promise();
620 exceptionState.throwDOMException(SyntaxError, "The ICE candidate could n ot be added."); 724 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver, OperationError);
725 WebRTCICECandidate webCandidate = convertToWebRTCIceCandidate(candidate);
726 bool implemented = m_peerHandler->addICECandidate(request, webCandidate);
727 // TODO(guidou): replace NotSupportedError when error handling in the spec i s finalized. crbug.com/585621
728 if (!implemented)
729 resolver->reject(DOMException::create(NotSupportedError, "This method is not yet implemented."));
730
731 return promise;
621 } 732 }
622 733
623 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, VoidCallb ack* successCallback, RTCErrorCallback* errorCallback, ExceptionState& exception State) 734 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, RTCIc eCandidate* iceCandidate, VoidCallback* successCallback, RTCErrorCallback* error Callback)
624 { 735 {
625 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
626 return;
627
628 ASSERT(iceCandidate); 736 ASSERT(iceCandidate);
629 ASSERT(successCallback); 737 ASSERT(successCallback);
630 ASSERT(errorCallback); 738 ASSERT(errorCallback);
631 739
740 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) )
741 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola te()));
742
632 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback); 743 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback);
744 bool implemented = m_peerHandler->addICECandidate(request, iceCandidate->web Candidate());
745 if (!implemented)
746 asyncCallErrorCallback(errorCallback, "This method is not yet implemente d.");
633 747
634 bool implemented = m_peerHandler->addICECandidate(request, iceCandidate->web Candidate()); 748 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate() ));
635 if (!implemented) {
636 exceptionState.throwDOMException(NotSupportedError, "This method is not yet implemented.");
637 }
638 } 749 }
639 750
640 String RTCPeerConnection::signalingState() const 751 String RTCPeerConnection::signalingState() const
641 { 752 {
642 switch (m_signalingState) { 753 switch (m_signalingState) {
643 case SignalingStateStable: 754 case SignalingStateStable:
644 return "stable"; 755 return "stable";
645 case SignalingStateHaveLocalOffer: 756 case SignalingStateHaveLocalOffer:
646 return "have-local-offer"; 757 return "have-local-offer";
647 case SignalingStateHaveRemoteOffer: 758 case SignalingStateHaveRemoteOffer:
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 { 1160 {
1050 visitor->trace(m_localStreams); 1161 visitor->trace(m_localStreams);
1051 visitor->trace(m_remoteStreams); 1162 visitor->trace(m_remoteStreams);
1052 visitor->trace(m_dispatchScheduledEventRunner); 1163 visitor->trace(m_dispatchScheduledEventRunner);
1053 visitor->trace(m_scheduledEvents); 1164 visitor->trace(m_scheduledEvents);
1054 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor); 1165 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor);
1055 ActiveDOMObject::trace(visitor); 1166 ActiveDOMObject::trace(visitor);
1056 } 1167 }
1057 1168
1058 } // namespace blink 1169 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698