| 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/RTCVoidRequestImpl.h" | 31 #include "modules/mediastream/RTCVoidRequestImpl.h" |
| 32 | 32 |
| 33 #include "core/dom/DOMException.h" |
| 34 #include "core/dom/ExceptionCode.h" |
| 33 #include "core/html/VoidCallback.h" | 35 #include "core/html/VoidCallback.h" |
| 34 #include "modules/mediastream/RTCErrorCallback.h" | |
| 35 #include "modules/mediastream/RTCPeerConnection.h" | 36 #include "modules/mediastream/RTCPeerConnection.h" |
| 37 #include "modules/mediastream/RTCPeerConnectionErrorCallback.h" |
| 36 | 38 |
| 37 namespace blink { | 39 namespace blink { |
| 38 | 40 |
| 39 RTCVoidRequestImpl* RTCVoidRequestImpl::create(ExecutionContext* context, RTCPee
rConnection* requester, VoidCallback* successCallback, RTCErrorCallback* errorCa
llback) | 41 RTCVoidRequestImpl* RTCVoidRequestImpl::create(ExecutionContext* context, RTCPee
rConnection* requester, VoidCallback* successCallback, RTCPeerConnectionErrorCal
lback* errorCallback) |
| 40 { | 42 { |
| 41 RTCVoidRequestImpl* request = new RTCVoidRequestImpl(context, requester, suc
cessCallback, errorCallback); | 43 RTCVoidRequestImpl* request = new RTCVoidRequestImpl(context, requester, suc
cessCallback, errorCallback); |
| 42 request->suspendIfNeeded(); | 44 request->suspendIfNeeded(); |
| 43 return request; | 45 return request; |
| 44 } | 46 } |
| 45 | 47 |
| 46 RTCVoidRequestImpl::RTCVoidRequestImpl(ExecutionContext* context, RTCPeerConnect
ion* requester, VoidCallback* successCallback, RTCErrorCallback* errorCallback) | 48 RTCVoidRequestImpl::RTCVoidRequestImpl(ExecutionContext* context, RTCPeerConnect
ion* requester, VoidCallback* successCallback, RTCPeerConnectionErrorCallback* e
rrorCallback) |
| 47 : ActiveDOMObject(context) | 49 : ActiveDOMObject(context) |
| 48 , m_successCallback(successCallback) | 50 , m_successCallback(successCallback) |
| 49 , m_errorCallback(errorCallback) | 51 , m_errorCallback(errorCallback) |
| 50 , m_requester(requester) | 52 , m_requester(requester) |
| 51 { | 53 { |
| 52 ASSERT(m_requester); | 54 ASSERT(m_requester); |
| 53 } | 55 } |
| 54 | 56 |
| 55 RTCVoidRequestImpl::~RTCVoidRequestImpl() | 57 RTCVoidRequestImpl::~RTCVoidRequestImpl() |
| 56 { | 58 { |
| 57 } | 59 } |
| 58 | 60 |
| 59 void RTCVoidRequestImpl::requestSucceeded() | 61 void RTCVoidRequestImpl::requestSucceeded() |
| 60 { | 62 { |
| 61 bool shouldFireCallback = m_requester ? m_requester->shouldFireDefaultCallba
cks() : false; | 63 bool shouldFireCallback = m_requester && m_requester->shouldFireDefaultCallb
acks(); |
| 62 if (shouldFireCallback && m_successCallback) | 64 if (shouldFireCallback && m_successCallback) |
| 63 m_successCallback->handleEvent(); | 65 m_successCallback->handleEvent(); |
| 64 | 66 |
| 65 clear(); | 67 clear(); |
| 66 } | 68 } |
| 67 | 69 |
| 68 void RTCVoidRequestImpl::requestFailed(const String& error) | 70 void RTCVoidRequestImpl::requestFailed(const String& error) |
| 69 { | 71 { |
| 70 bool shouldFireCallback = m_requester ? m_requester->shouldFireDefaultCallba
cks() : false; | 72 bool shouldFireCallback = m_requester && m_requester->shouldFireDefaultCallb
acks(); |
| 71 if (shouldFireCallback && m_errorCallback.get()) | 73 if (shouldFireCallback && m_errorCallback.get()) { |
| 72 m_errorCallback->handleEvent(error); | 74 // TODO(guidou): The error code should come from the content layer. See
crbug.com/589455 |
| 75 m_errorCallback->handleEvent(DOMException::create(OperationError, error)
); |
| 76 } |
| 73 | 77 |
| 74 clear(); | 78 clear(); |
| 75 } | 79 } |
| 76 | 80 |
| 77 void RTCVoidRequestImpl::stop() | 81 void RTCVoidRequestImpl::stop() |
| 78 { | 82 { |
| 79 clear(); | 83 clear(); |
| 80 } | 84 } |
| 81 | 85 |
| 82 void RTCVoidRequestImpl::clear() | 86 void RTCVoidRequestImpl::clear() |
| 83 { | 87 { |
| 84 m_successCallback.clear(); | 88 m_successCallback.clear(); |
| 85 m_errorCallback.clear(); | 89 m_errorCallback.clear(); |
| 86 m_requester.clear(); | 90 m_requester.clear(); |
| 87 } | 91 } |
| 88 | 92 |
| 89 DEFINE_TRACE(RTCVoidRequestImpl) | 93 DEFINE_TRACE(RTCVoidRequestImpl) |
| 90 { | 94 { |
| 91 visitor->trace(m_successCallback); | 95 visitor->trace(m_successCallback); |
| 92 visitor->trace(m_errorCallback); | 96 visitor->trace(m_errorCallback); |
| 93 visitor->trace(m_requester); | 97 visitor->trace(m_requester); |
| 94 RTCVoidRequest::trace(visitor); | 98 RTCVoidRequest::trace(visitor); |
| 95 ActiveDOMObject::trace(visitor); | 99 ActiveDOMObject::trace(visitor); |
| 96 } | 100 } |
| 97 | 101 |
| 98 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |