| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 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/RTCSessionDescriptionRequestImpl.h" | 31 #include "modules/mediastream/RTCSessionDescriptionRequestImpl.h" |
| 32 | 32 |
| 33 #include "modules/mediastream/RTCErrorCallback.h" | 33 #include "core/dom/DOMException.h" |
| 34 #include "core/dom/ExceptionCode.h" |
| 34 #include "modules/mediastream/RTCPeerConnection.h" | 35 #include "modules/mediastream/RTCPeerConnection.h" |
| 36 #include "modules/mediastream/RTCPeerConnectionErrorCallback.h" |
| 35 #include "modules/mediastream/RTCSessionDescription.h" | 37 #include "modules/mediastream/RTCSessionDescription.h" |
| 36 #include "modules/mediastream/RTCSessionDescriptionCallback.h" | 38 #include "modules/mediastream/RTCSessionDescriptionCallback.h" |
| 37 #include "public/platform/WebRTCSessionDescription.h" | 39 #include "public/platform/WebRTCSessionDescription.h" |
| 38 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
| 39 | 41 |
| 40 namespace blink { | 42 namespace blink { |
| 41 | 43 |
| 42 RTCSessionDescriptionRequestImpl* RTCSessionDescriptionRequestImpl::create(Execu
tionContext* context, RTCPeerConnection* requester, RTCSessionDescriptionCallbac
k* successCallback, RTCErrorCallback* errorCallback) | 44 RTCSessionDescriptionRequestImpl* RTCSessionDescriptionRequestImpl::create(RTCPe
erConnection* requester, RTCSessionDescriptionCallback* successCallback, RTCPeer
ConnectionErrorCallback* errorCallback) |
| 43 { | 45 { |
| 44 RTCSessionDescriptionRequestImpl* request = new RTCSessionDescriptionRequest
Impl(context, requester, successCallback, errorCallback); | 46 return new RTCSessionDescriptionRequestImpl(requester, successCallback, erro
rCallback); |
| 45 request->suspendIfNeeded(); | |
| 46 return request; | |
| 47 } | 47 } |
| 48 | 48 |
| 49 RTCSessionDescriptionRequestImpl::RTCSessionDescriptionRequestImpl(ExecutionCont
ext* context, RTCPeerConnection* requester, RTCSessionDescriptionCallback* succe
ssCallback, RTCErrorCallback* errorCallback) | 49 RTCSessionDescriptionRequestImpl::RTCSessionDescriptionRequestImpl(RTCPeerConnec
tion* requester, RTCSessionDescriptionCallback* successCallback, RTCPeerConnecti
onErrorCallback* errorCallback) |
| 50 : ActiveDOMObject(context) | 50 : m_successCallback(successCallback) |
| 51 , m_successCallback(successCallback) | |
| 52 , m_errorCallback(errorCallback) | 51 , m_errorCallback(errorCallback) |
| 53 , m_requester(requester) | 52 , m_requester(requester) |
| 54 { | 53 { |
| 55 ASSERT(m_requester); | 54 ASSERT(m_requester); |
| 56 } | 55 } |
| 57 | 56 |
| 58 RTCSessionDescriptionRequestImpl::~RTCSessionDescriptionRequestImpl() | 57 RTCSessionDescriptionRequestImpl::~RTCSessionDescriptionRequestImpl() |
| 59 { | 58 { |
| 60 } | 59 } |
| 61 | 60 |
| 62 void RTCSessionDescriptionRequestImpl::requestSucceeded(const WebRTCSessionDescr
iption& webSessionDescription) | 61 void RTCSessionDescriptionRequestImpl::requestSucceeded(const WebRTCSessionDescr
iption& webSessionDescription) |
| 63 { | 62 { |
| 64 bool shouldFireCallback = m_requester ? m_requester->shouldFireDefaultCallba
cks() : false; | 63 bool shouldFireCallback = m_requester ? m_requester->shouldFireDefaultCallba
cks() : false; |
| 65 if (shouldFireCallback && m_successCallback) | 64 if (shouldFireCallback && m_successCallback) |
| 66 m_successCallback->handleEvent(RTCSessionDescription::create(webSessionD
escription)); | 65 m_successCallback->handleEvent(RTCSessionDescription::create(webSessionD
escription)); |
| 67 clear(); | 66 clear(); |
| 68 } | 67 } |
| 69 | 68 |
| 70 void RTCSessionDescriptionRequestImpl::requestFailed(const String& error) | 69 void RTCSessionDescriptionRequestImpl::requestFailed(const String& error) |
| 71 { | 70 { |
| 72 bool shouldFireCallback = m_requester ? m_requester->shouldFireDefaultCallba
cks() : false; | 71 bool shouldFireCallback = m_requester ? m_requester->shouldFireDefaultCallba
cks() : false; |
| 73 if (shouldFireCallback && m_errorCallback) | 72 if (shouldFireCallback && m_errorCallback) |
| 74 m_errorCallback->handleEvent(error); | 73 m_errorCallback->handleEvent(DOMException::create(OperationError, error)
); |
| 75 | 74 |
| 76 clear(); | 75 clear(); |
| 77 } | 76 } |
| 78 | 77 |
| 79 void RTCSessionDescriptionRequestImpl::stop() | |
| 80 { | |
| 81 clear(); | |
| 82 } | |
| 83 | |
| 84 void RTCSessionDescriptionRequestImpl::clear() | 78 void RTCSessionDescriptionRequestImpl::clear() |
| 85 { | 79 { |
| 86 m_successCallback.clear(); | 80 m_successCallback.clear(); |
| 87 m_errorCallback.clear(); | 81 m_errorCallback.clear(); |
| 88 m_requester.clear(); | 82 m_requester.clear(); |
| 89 } | 83 } |
| 90 | 84 |
| 91 DEFINE_TRACE(RTCSessionDescriptionRequestImpl) | 85 DEFINE_TRACE(RTCSessionDescriptionRequestImpl) |
| 92 { | 86 { |
| 93 visitor->trace(m_successCallback); | 87 visitor->trace(m_successCallback); |
| 94 visitor->trace(m_errorCallback); | 88 visitor->trace(m_errorCallback); |
| 95 visitor->trace(m_requester); | 89 visitor->trace(m_requester); |
| 96 RTCSessionDescriptionRequest::trace(visitor); | 90 RTCSessionDescriptionRequest::trace(visitor); |
| 97 ActiveDOMObject::trace(visitor); | |
| 98 } | 91 } |
| 99 | 92 |
| 100 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |