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