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(Execu
tionContext* context, RTCPeerConnection* requester, RTCSessionDescriptionCallbac
k* successCallback, RTCPeerConnectionErrorCallback* errorCallback) |
43 { | 45 { |
44 RTCSessionDescriptionRequestImpl* request = new RTCSessionDescriptionRequest
Impl(context, requester, successCallback, errorCallback); | 46 RTCSessionDescriptionRequestImpl* request = new RTCSessionDescriptionRequest
Impl(context, requester, successCallback, errorCallback); |
45 request->suspendIfNeeded(); | 47 request->suspendIfNeeded(); |
46 return request; | 48 return request; |
47 } | 49 } |
48 | 50 |
49 RTCSessionDescriptionRequestImpl::RTCSessionDescriptionRequestImpl(ExecutionCont
ext* context, RTCPeerConnection* requester, RTCSessionDescriptionCallback* succe
ssCallback, RTCErrorCallback* errorCallback) | 51 RTCSessionDescriptionRequestImpl::RTCSessionDescriptionRequestImpl(ExecutionCont
ext* context, RTCPeerConnection* requester, RTCSessionDescriptionCallback* succe
ssCallback, RTCPeerConnectionErrorCallback* errorCallback) |
50 : ActiveDOMObject(context) | 52 : ActiveDOMObject(context) |
51 , m_successCallback(successCallback) | 53 , m_successCallback(successCallback) |
52 , m_errorCallback(errorCallback) | 54 , m_errorCallback(errorCallback) |
53 , m_requester(requester) | 55 , m_requester(requester) |
54 { | 56 { |
55 ASSERT(m_requester); | 57 ASSERT(m_requester); |
56 } | 58 } |
57 | 59 |
58 RTCSessionDescriptionRequestImpl::~RTCSessionDescriptionRequestImpl() | 60 RTCSessionDescriptionRequestImpl::~RTCSessionDescriptionRequestImpl() |
59 { | 61 { |
60 } | 62 } |
61 | 63 |
62 void RTCSessionDescriptionRequestImpl::requestSucceeded(const WebRTCSessionDescr
iption& webSessionDescription) | 64 void RTCSessionDescriptionRequestImpl::requestSucceeded(const WebRTCSessionDescr
iption& webSessionDescription) |
63 { | 65 { |
64 bool shouldFireCallback = m_requester ? m_requester->shouldFireDefaultCallba
cks() : false; | 66 bool shouldFireCallback = m_requester ? m_requester->shouldFireDefaultCallba
cks() : false; |
65 if (shouldFireCallback && m_successCallback) | 67 if (shouldFireCallback && m_successCallback) |
66 m_successCallback->handleEvent(RTCSessionDescription::create(webSessionD
escription)); | 68 m_successCallback->handleEvent(RTCSessionDescription::create(webSessionD
escription)); |
67 clear(); | 69 clear(); |
68 } | 70 } |
69 | 71 |
70 void RTCSessionDescriptionRequestImpl::requestFailed(const String& error) | 72 void RTCSessionDescriptionRequestImpl::requestFailed(const String& error) |
71 { | 73 { |
72 bool shouldFireCallback = m_requester ? m_requester->shouldFireDefaultCallba
cks() : false; | 74 bool shouldFireCallback = m_requester ? m_requester->shouldFireDefaultCallba
cks() : false; |
73 if (shouldFireCallback && m_errorCallback) | 75 if (shouldFireCallback && m_errorCallback) |
74 m_errorCallback->handleEvent(error); | 76 m_errorCallback->handleEvent(DOMException::create(OperationError, error)
); |
75 | 77 |
76 clear(); | 78 clear(); |
77 } | 79 } |
78 | 80 |
79 void RTCSessionDescriptionRequestImpl::stop() | 81 void RTCSessionDescriptionRequestImpl::stop() |
80 { | 82 { |
81 clear(); | 83 clear(); |
82 } | 84 } |
83 | 85 |
84 void RTCSessionDescriptionRequestImpl::clear() | 86 void RTCSessionDescriptionRequestImpl::clear() |
85 { | 87 { |
86 m_successCallback.clear(); | 88 m_successCallback.clear(); |
87 m_errorCallback.clear(); | 89 m_errorCallback.clear(); |
88 m_requester.clear(); | 90 m_requester.clear(); |
89 } | 91 } |
90 | 92 |
91 DEFINE_TRACE(RTCSessionDescriptionRequestImpl) | 93 DEFINE_TRACE(RTCSessionDescriptionRequestImpl) |
92 { | 94 { |
93 visitor->trace(m_successCallback); | 95 visitor->trace(m_successCallback); |
94 visitor->trace(m_errorCallback); | 96 visitor->trace(m_errorCallback); |
95 visitor->trace(m_requester); | 97 visitor->trace(m_requester); |
96 RTCSessionDescriptionRequest::trace(visitor); | 98 RTCSessionDescriptionRequest::trace(visitor); |
97 ActiveDOMObject::trace(visitor); | 99 ActiveDOMObject::trace(visitor); |
98 } | 100 } |
99 | 101 |
100 } // namespace blink | 102 } // namespace blink |
OLD | NEW |