| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "core/frame/LocalFrame.h" | 48 #include "core/frame/LocalFrame.h" |
| 49 #include "core/html/VoidCallback.h" | 49 #include "core/html/VoidCallback.h" |
| 50 #include "core/loader/FrameLoader.h" | 50 #include "core/loader/FrameLoader.h" |
| 51 #include "core/loader/FrameLoaderClient.h" | 51 #include "core/loader/FrameLoaderClient.h" |
| 52 #include "modules/crypto/CryptoResultImpl.h" | 52 #include "modules/crypto/CryptoResultImpl.h" |
| 53 #include "modules/mediastream/MediaConstraintsImpl.h" | 53 #include "modules/mediastream/MediaConstraintsImpl.h" |
| 54 #include "modules/mediastream/MediaStreamEvent.h" | 54 #include "modules/mediastream/MediaStreamEvent.h" |
| 55 #include "modules/mediastream/RTCDTMFSender.h" | 55 #include "modules/mediastream/RTCDTMFSender.h" |
| 56 #include "modules/mediastream/RTCDataChannel.h" | 56 #include "modules/mediastream/RTCDataChannel.h" |
| 57 #include "modules/mediastream/RTCDataChannelEvent.h" | 57 #include "modules/mediastream/RTCDataChannelEvent.h" |
| 58 #include "modules/mediastream/RTCErrorCallback.h" | |
| 59 #include "modules/mediastream/RTCIceCandidateEvent.h" | 58 #include "modules/mediastream/RTCIceCandidateEvent.h" |
| 59 #include "modules/mediastream/RTCPeerConnectionErrorCallback.h" |
| 60 #include "modules/mediastream/RTCSessionDescription.h" | 60 #include "modules/mediastream/RTCSessionDescription.h" |
| 61 #include "modules/mediastream/RTCSessionDescriptionCallback.h" | 61 #include "modules/mediastream/RTCSessionDescriptionCallback.h" |
| 62 #include "modules/mediastream/RTCSessionDescriptionInit.h" | 62 #include "modules/mediastream/RTCSessionDescriptionInit.h" |
| 63 #include "modules/mediastream/RTCSessionDescriptionRequestImpl.h" | 63 #include "modules/mediastream/RTCSessionDescriptionRequestImpl.h" |
| 64 #include "modules/mediastream/RTCStatsCallback.h" | 64 #include "modules/mediastream/RTCStatsCallback.h" |
| 65 #include "modules/mediastream/RTCStatsRequestImpl.h" | 65 #include "modules/mediastream/RTCStatsRequestImpl.h" |
| 66 #include "modules/mediastream/RTCVoidRequestImpl.h" | 66 #include "modules/mediastream/RTCVoidRequestImpl.h" |
| 67 #include "modules/mediastream/RTCVoidRequestPromiseImpl.h" | 67 #include "modules/mediastream/RTCVoidRequestPromiseImpl.h" |
| 68 #include "platform/mediastream/RTCConfiguration.h" | 68 #include "platform/mediastream/RTCConfiguration.h" |
| 69 #include "platform/mediastream/RTCOfferOptions.h" | 69 #include "platform/mediastream/RTCOfferOptions.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 96 exceptionState.throwDOMException(InvalidStateError, kSignalingStateClose
dMessage); | 96 exceptionState.throwDOMException(InvalidStateError, kSignalingStateClose
dMessage); |
| 97 return true; | 97 return true; |
| 98 } | 98 } |
| 99 | 99 |
| 100 return false; | 100 return false; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Helper class for running error callbacks asynchronously | 103 // Helper class for running error callbacks asynchronously |
| 104 class ErrorCallbackTask : public WebTaskRunner::Task { | 104 class ErrorCallbackTask : public WebTaskRunner::Task { |
| 105 public: | 105 public: |
| 106 static PassOwnPtr<ErrorCallbackTask> create(RTCErrorCallback* errorCallback,
const String& errorMessage) | 106 static PassOwnPtr<ErrorCallbackTask> create(RTCPeerConnectionErrorCallback*
errorCallback, DOMException* exception) |
| 107 { | 107 { |
| 108 return adoptPtr(new ErrorCallbackTask(errorCallback, errorMessage)); | 108 return adoptPtr(new ErrorCallbackTask(errorCallback, exception)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 ~ErrorCallbackTask() override = default; | 111 ~ErrorCallbackTask() override = default; |
| 112 | 112 |
| 113 void run() override | 113 void run() override |
| 114 { | 114 { |
| 115 m_errorCallback->handleEvent(m_errorMessage); | 115 m_errorCallback->handleEvent(m_exception); |
| 116 } | 116 } |
| 117 | 117 |
| 118 private: | 118 private: |
| 119 ErrorCallbackTask(RTCErrorCallback* errorCallback, const String& errorMessag
e) | 119 ErrorCallbackTask(RTCPeerConnectionErrorCallback* errorCallback, DOMExceptio
n* exception) |
| 120 : m_errorCallback(errorCallback) | 120 : m_errorCallback(errorCallback) |
| 121 , m_errorMessage(errorMessage) | 121 , m_exception(exception) |
| 122 { | 122 { |
| 123 ASSERT(errorCallback); | 123 ASSERT(errorCallback); |
| 124 } | 124 } |
| 125 | 125 |
| 126 Persistent<RTCErrorCallback> m_errorCallback; | 126 Persistent<RTCPeerConnectionErrorCallback> m_errorCallback; |
| 127 String m_errorMessage; | 127 Persistent<DOMException> m_exception; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 void asyncCallErrorCallback(RTCErrorCallback* errorCallback, const String& error
Message) | 130 void asyncCallErrorCallback(RTCPeerConnectionErrorCallback* errorCallback, DOMEx
ception* exception) |
| 131 { | 131 { |
| 132 Microtask::enqueueMicrotask(ErrorCallbackTask::create(errorCallback, errorMe
ssage)); | 132 Microtask::enqueueMicrotask(ErrorCallbackTask::create(errorCallback, excepti
on)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 bool callErrorCallbackIfSignalingStateClosed(RTCPeerConnection::SignalingState s
tate, RTCErrorCallback* errorCallback) | 135 bool callErrorCallbackIfSignalingStateClosed(RTCPeerConnection::SignalingState s
tate, RTCPeerConnectionErrorCallback* errorCallback) |
| 136 { | 136 { |
| 137 if (state == RTCPeerConnection::SignalingStateClosed) { | 137 if (state == RTCPeerConnection::SignalingStateClosed) { |
| 138 if (errorCallback) | 138 if (errorCallback) |
| 139 asyncCallErrorCallback(errorCallback, kSignalingStateClosedMessage); | 139 asyncCallErrorCallback(errorCallback, DOMException::create(InvalidSt
ateError, kSignalingStateClosedMessage)); |
| 140 | 140 |
| 141 return true; | 141 return true; |
| 142 } | 142 } |
| 143 | 143 |
| 144 return false; | 144 return false; |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool isIceCandidateMissingSdp(const RTCIceCandidateInitOrRTCIceCandidate& candid
ate) | 147 bool isIceCandidateMissingSdp(const RTCIceCandidateInitOrRTCIceCandidate& candid
ate) |
| 148 { | 148 { |
| 149 if (candidate.isRTCIceCandidateInit()) { | 149 if (candidate.isRTCIceCandidateInit()) { |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 } | 458 } |
| 459 } | 459 } |
| 460 | 460 |
| 461 RTCPeerConnection::~RTCPeerConnection() | 461 RTCPeerConnection::~RTCPeerConnection() |
| 462 { | 462 { |
| 463 // This checks that close() or stop() is called before the destructor. | 463 // This checks that close() or stop() is called before the destructor. |
| 464 // We are assuming that a wrapper is always created when RTCPeerConnection i
s created. | 464 // We are assuming that a wrapper is always created when RTCPeerConnection i
s created. |
| 465 ASSERT(m_closed || m_stopped); | 465 ASSERT(m_closed || m_stopped); |
| 466 } | 466 } |
| 467 | 467 |
| 468 void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescrip
tionCallback* successCallback, RTCErrorCallback* errorCallback, const Dictionary
& rtcOfferOptions, ExceptionState& exceptionState) | 468 void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescrip
tionCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback, co
nst Dictionary& rtcOfferOptions, ExceptionState& exceptionState) |
| 469 { | 469 { |
| 470 if (errorCallback) | 470 if (errorCallback) |
| 471 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegac
yFailureCallback); | 471 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegac
yFailureCallback); |
| 472 else | 472 else |
| 473 Deprecation::countDeprecation(context, UseCounter::RTCPeerConnectionCrea
teOfferLegacyNoFailureCallback); | 473 Deprecation::countDeprecation(context, UseCounter::RTCPeerConnectionCrea
teOfferLegacyNoFailureCallback); |
| 474 | 474 |
| 475 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 475 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 476 return; | 476 return; |
| 477 | 477 |
| 478 ASSERT(successCallback); | 478 ASSERT(successCallback); |
| 479 | 479 |
| 480 RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, exception
State); | 480 RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, exception
State); |
| 481 if (exceptionState.hadException()) | 481 if (exceptionState.hadException()) |
| 482 return; | 482 return; |
| 483 | 483 |
| 484 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); | 484 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(this, successCallback, errorCallback); |
| 485 | 485 |
| 486 if (offerOptions) { | 486 if (offerOptions) { |
| 487 if (offerOptions->offerToReceiveAudio() != -1 || offerOptions->offerToRe
ceiveVideo() != -1) | 487 if (offerOptions->offerToReceiveAudio() != -1 || offerOptions->offerToRe
ceiveVideo() != -1) |
| 488 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyOfferOptions); | 488 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyOfferOptions); |
| 489 else if (errorCallback) | 489 else if (errorCallback) |
| 490 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyCompliant); | 490 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyCompliant); |
| 491 | 491 |
| 492 m_peerHandler->createOffer(request, offerOptions); | 492 m_peerHandler->createOffer(request, offerOptions); |
| 493 } else { | 493 } else { |
| 494 MediaErrorState mediaErrorState; | 494 MediaErrorState mediaErrorState; |
| 495 WebMediaConstraints constraints = MediaConstraintsImpl::create(context,
rtcOfferOptions, mediaErrorState); | 495 WebMediaConstraints constraints = MediaConstraintsImpl::create(context,
rtcOfferOptions, mediaErrorState); |
| 496 if (mediaErrorState.hadException()) { | 496 if (mediaErrorState.hadException()) { |
| 497 mediaErrorState.raiseException(exceptionState); | 497 mediaErrorState.raiseException(exceptionState); |
| 498 return; | 498 return; |
| 499 } | 499 } |
| 500 | 500 |
| 501 if (!constraints.isEmpty()) | 501 if (!constraints.isEmpty()) |
| 502 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyConstraints); | 502 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyConstraints); |
| 503 else if (errorCallback) | 503 else if (errorCallback) |
| 504 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyCompliant); | 504 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL
egacyCompliant); |
| 505 | 505 |
| 506 m_peerHandler->createOffer(request, constraints); | 506 m_peerHandler->createOffer(request, constraints); |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 | 509 |
| 510 void RTCPeerConnection::createAnswer(ExecutionContext* context, RTCSessionDescri
ptionCallback* successCallback, RTCErrorCallback* errorCallback, const Dictionar
y& mediaConstraints, ExceptionState& exceptionState) | 510 void RTCPeerConnection::createAnswer(ExecutionContext* context, RTCSessionDescri
ptionCallback* successCallback, RTCPeerConnectionErrorCallback* errorCallback, c
onst Dictionary& mediaConstraints, ExceptionState& exceptionState) |
| 511 { | 511 { |
| 512 if (errorCallback) | 512 if (errorCallback) |
| 513 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega
cyFailureCallback); | 513 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega
cyFailureCallback); |
| 514 else | 514 else |
| 515 Deprecation::countDeprecation(context, UseCounter::RTCPeerConnectionCrea
teAnswerLegacyNoFailureCallback); | 515 Deprecation::countDeprecation(context, UseCounter::RTCPeerConnectionCrea
teAnswerLegacyNoFailureCallback); |
| 516 | 516 |
| 517 if (mediaConstraints.isObject()) | 517 if (mediaConstraints.isObject()) |
| 518 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega
cyConstraints); | 518 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega
cyConstraints); |
| 519 else if (errorCallback) | 519 else if (errorCallback) |
| 520 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega
cyCompliant); | 520 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega
cyCompliant); |
| 521 | 521 |
| 522 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 522 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 523 return; | 523 return; |
| 524 | 524 |
| 525 ASSERT(successCallback); | 525 ASSERT(successCallback); |
| 526 | 526 |
| 527 MediaErrorState mediaErrorState; | 527 MediaErrorState mediaErrorState; |
| 528 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, medi
aConstraints, mediaErrorState); | 528 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, medi
aConstraints, mediaErrorState); |
| 529 if (mediaErrorState.hadException()) { | 529 if (mediaErrorState.hadException()) { |
| 530 mediaErrorState.raiseException(exceptionState); | 530 mediaErrorState.raiseException(exceptionState); |
| 531 return; | 531 return; |
| 532 } | 532 } |
| 533 | 533 |
| 534 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); | 534 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(this, successCallback, errorCallback); |
| 535 m_peerHandler->createAnswer(request, constraints); | 535 m_peerHandler->createAnswer(request, constraints); |
| 536 } | 536 } |
| 537 | 537 |
| 538 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, c
onst RTCSessionDescriptionInit& sessionDescriptionInit) | 538 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, c
onst RTCSessionDescriptionInit& sessionDescriptionInit) |
| 539 { | 539 { |
| 540 if (m_signalingState == SignalingStateClosed) | 540 if (m_signalingState == SignalingStateClosed) |
| 541 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); | 541 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); |
| 542 | 542 |
| 543 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 543 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 544 ScriptPromise promise = resolver->promise(); | 544 ScriptPromise promise = resolver->promise(); |
| 545 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver,
InvalidAccessError); | 545 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver,
InvalidAccessError); |
| 546 m_peerHandler->setLocalDescription(request, WebRTCSessionDescription(session
DescriptionInit.type(), sessionDescriptionInit.sdp())); | 546 m_peerHandler->setLocalDescription(request, WebRTCSessionDescription(session
DescriptionInit.type(), sessionDescriptionInit.sdp())); |
| 547 return promise; | 547 return promise; |
| 548 } | 548 } |
| 549 | 549 |
| 550 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, R
TCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCErro
rCallback* errorCallback) | 550 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, R
TCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCPeer
ConnectionErrorCallback* errorCallback) |
| 551 { | 551 { |
| 552 ExecutionContext* context = scriptState->executionContext(); | 552 ExecutionContext* context = scriptState->executionContext(); |
| 553 if (successCallback && errorCallback) { | 553 if (successCallback && errorCallback) { |
| 554 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDescript
ionLegacyCompliant); | 554 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDescript
ionLegacyCompliant); |
| 555 } else { | 555 } else { |
| 556 if (!successCallback) | 556 if (!successCallback) |
| 557 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc
riptionLegacyNoSuccessCallback); | 557 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc
riptionLegacyNoSuccessCallback); |
| 558 if (!errorCallback) | 558 if (!errorCallback) |
| 559 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc
riptionLegacyNoFailureCallback); | 559 UseCounter::count(context, UseCounter::RTCPeerConnectionSetLocalDesc
riptionLegacyNoFailureCallback); |
| 560 } | 560 } |
| 561 | 561 |
| 562 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) | 562 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) |
| 563 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); | 563 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); |
| 564 | 564 |
| 565 ASSERT(sessionDescription); | 565 ASSERT(sessionDescription); |
| 566 | 566 |
| 567 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); | 567 RTCVoidRequest* request = RTCVoidRequestImpl::create(this, successCallback,
errorCallback, InvalidAccessError); |
| 568 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe
scription()); | 568 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe
scription()); |
| 569 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); | 569 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); |
| 570 } | 570 } |
| 571 | 571 |
| 572 RTCSessionDescription* RTCPeerConnection::localDescription() | 572 RTCSessionDescription* RTCPeerConnection::localDescription() |
| 573 { | 573 { |
| 574 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip
tion(); | 574 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip
tion(); |
| 575 if (webSessionDescription.isNull()) | 575 if (webSessionDescription.isNull()) |
| 576 return nullptr; | 576 return nullptr; |
| 577 | 577 |
| 578 return RTCSessionDescription::create(webSessionDescription); | 578 return RTCSessionDescription::create(webSessionDescription); |
| 579 } | 579 } |
| 580 | 580 |
| 581 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState,
const RTCSessionDescriptionInit& sessionDescriptionInit) | 581 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState,
const RTCSessionDescriptionInit& sessionDescriptionInit) |
| 582 { | 582 { |
| 583 if (m_signalingState == SignalingStateClosed) | 583 if (m_signalingState == SignalingStateClosed) |
| 584 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); | 584 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); |
| 585 | 585 |
| 586 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 586 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 587 ScriptPromise promise = resolver->promise(); | 587 ScriptPromise promise = resolver->promise(); |
| 588 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver,
InvalidAccessError); | 588 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver,
InvalidAccessError); |
| 589 m_peerHandler->setRemoteDescription(request, WebRTCSessionDescription(sessio
nDescriptionInit.type(), sessionDescriptionInit.sdp())); | 589 m_peerHandler->setRemoteDescription(request, WebRTCSessionDescription(sessio
nDescriptionInit.type(), sessionDescriptionInit.sdp())); |
| 590 return promise; | 590 return promise; |
| 591 } | 591 } |
| 592 | 592 |
| 593 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState,
RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCErr
orCallback* errorCallback) | 593 ScriptPromise RTCPeerConnection::setRemoteDescription(ScriptState* scriptState,
RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCPee
rConnectionErrorCallback* errorCallback) |
| 594 { | 594 { |
| 595 ExecutionContext* context = scriptState->executionContext(); | 595 ExecutionContext* context = scriptState->executionContext(); |
| 596 if (successCallback && errorCallback) { | 596 if (successCallback && errorCallback) { |
| 597 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDescrip
tionLegacyCompliant); | 597 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDescrip
tionLegacyCompliant); |
| 598 } else { | 598 } else { |
| 599 if (!successCallback) | 599 if (!successCallback) |
| 600 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes
criptionLegacyNoSuccessCallback); | 600 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes
criptionLegacyNoSuccessCallback); |
| 601 if (!errorCallback) | 601 if (!errorCallback) |
| 602 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes
criptionLegacyNoFailureCallback); | 602 UseCounter::count(context, UseCounter::RTCPeerConnectionSetRemoteDes
criptionLegacyNoFailureCallback); |
| 603 } | 603 } |
| 604 | 604 |
| 605 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) | 605 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) |
| 606 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); | 606 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); |
| 607 | 607 |
| 608 ASSERT(sessionDescription); | 608 ASSERT(sessionDescription); |
| 609 | 609 |
| 610 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); | 610 RTCVoidRequest* request = RTCVoidRequestImpl::create(this, successCallback,
errorCallback, InvalidAccessError); |
| 611 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD
escription()); | 611 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD
escription()); |
| 612 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); | 612 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); |
| 613 } | 613 } |
| 614 | 614 |
| 615 RTCSessionDescription* RTCPeerConnection::remoteDescription() | 615 RTCSessionDescription* RTCPeerConnection::remoteDescription() |
| 616 { | 616 { |
| 617 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri
ption(); | 617 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri
ption(); |
| 618 if (webSessionDescription.isNull()) | 618 if (webSessionDescription.isNull()) |
| 619 return nullptr; | 619 return nullptr; |
| 620 | 620 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); | 717 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(InvalidStateError, kSignalingStateClosedMessage)); |
| 718 | 718 |
| 719 if (isIceCandidateMissingSdp(candidate)) | 719 if (isIceCandidateMissingSdp(candidate)) |
| 720 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Candidate missing values for both sdpMid and sdpMLi
neIndex")); | 720 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr
ror(scriptState->isolate(), "Candidate missing values for both sdpMid and sdpMLi
neIndex")); |
| 721 | 721 |
| 722 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 722 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 723 ScriptPromise promise = resolver->promise(); | 723 ScriptPromise promise = resolver->promise(); |
| 724 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver,
OperationError); | 724 RTCVoidRequest* request = RTCVoidRequestPromiseImpl::create(this, resolver,
OperationError); |
| 725 WebRTCICECandidate webCandidate = convertToWebRTCIceCandidate(candidate); | 725 WebRTCICECandidate webCandidate = convertToWebRTCIceCandidate(candidate); |
| 726 bool implemented = m_peerHandler->addICECandidate(request, webCandidate); | 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) | 727 if (!implemented) |
| 729 resolver->reject(DOMException::create(NotSupportedError, "This method is
not yet implemented.")); | 728 resolver->reject(DOMException::create(OperationError, "This operation co
uld not be completed.")); |
| 730 | 729 |
| 731 return promise; | 730 return promise; |
| 732 } | 731 } |
| 733 | 732 |
| 734 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, RTCIc
eCandidate* iceCandidate, VoidCallback* successCallback, RTCErrorCallback* error
Callback) | 733 ScriptPromise RTCPeerConnection::addIceCandidate(ScriptState* scriptState, RTCIc
eCandidate* iceCandidate, VoidCallback* successCallback, RTCPeerConnectionErrorC
allback* errorCallback) |
| 735 { | 734 { |
| 736 ASSERT(iceCandidate); | 735 ASSERT(iceCandidate); |
| 737 ASSERT(successCallback); | 736 ASSERT(successCallback); |
| 738 ASSERT(errorCallback); | 737 ASSERT(errorCallback); |
| 739 | 738 |
| 740 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) | 739 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)
) |
| 741 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); | 740 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isola
te())); |
| 742 | 741 |
| 743 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); | 742 RTCVoidRequest* request = RTCVoidRequestImpl::create(this, successCallback,
errorCallback, OperationError); |
| 744 bool implemented = m_peerHandler->addICECandidate(request, iceCandidate->web
Candidate()); | 743 bool implemented = m_peerHandler->addICECandidate(request, iceCandidate->web
Candidate()); |
| 745 if (!implemented) | 744 if (!implemented) |
| 746 asyncCallErrorCallback(errorCallback, "This method is not yet implemente
d."); | 745 asyncCallErrorCallback(errorCallback, DOMException::create(OperationErro
r, "This operation could not be completed.")); |
| 747 | 746 |
| 748 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); | 747 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate()
)); |
| 749 } | 748 } |
| 750 | 749 |
| 751 String RTCPeerConnection::signalingState() const | 750 String RTCPeerConnection::signalingState() const |
| 752 { | 751 { |
| 753 switch (m_signalingState) { | 752 switch (m_signalingState) { |
| 754 case SignalingStateStable: | 753 case SignalingStateStable: |
| 755 return "stable"; | 754 return "stable"; |
| 756 case SignalingStateHaveLocalOffer: | 755 case SignalingStateHaveLocalOffer: |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 { | 1159 { |
| 1161 visitor->trace(m_localStreams); | 1160 visitor->trace(m_localStreams); |
| 1162 visitor->trace(m_remoteStreams); | 1161 visitor->trace(m_remoteStreams); |
| 1163 visitor->trace(m_dispatchScheduledEventRunner); | 1162 visitor->trace(m_dispatchScheduledEventRunner); |
| 1164 visitor->trace(m_scheduledEvents); | 1163 visitor->trace(m_scheduledEvents); |
| 1165 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); | 1164 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); |
| 1166 ActiveDOMObject::trace(visitor); | 1165 ActiveDOMObject::trace(visitor); |
| 1167 } | 1166 } |
| 1168 | 1167 |
| 1169 } // namespace blink | 1168 } // namespace blink |
| OLD | NEW |