Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(652)

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/RTCSessionDescriptionRequestPromiseImpl.cpp

Issue 2097563002: Split the mediastream module in Blink into mediastream and peerconnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add DEPS file Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/mediastream/RTCSessionDescriptionRequestPromiseImpl.h"
6
7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "core/dom/DOMException.h"
9 #include "core/dom/ExceptionCode.h"
10 #include "modules/mediastream/RTCPeerConnection.h"
11 #include "modules/mediastream/RTCSessionDescription.h"
12 #include "public/platform/WebRTCSessionDescription.h"
13
14 namespace blink {
15
16 RTCSessionDescriptionRequestPromiseImpl* RTCSessionDescriptionRequestPromiseImpl ::create(RTCPeerConnection* requester, ScriptPromiseResolver* resolver)
17 {
18 return new RTCSessionDescriptionRequestPromiseImpl(requester, resolver);
19 }
20
21 RTCSessionDescriptionRequestPromiseImpl::RTCSessionDescriptionRequestPromiseImpl (RTCPeerConnection* requester, ScriptPromiseResolver* resolver)
22 : m_requester(requester)
23 , m_resolver(resolver)
24 {
25 DCHECK(m_requester);
26 DCHECK(m_resolver);
27 }
28
29 RTCSessionDescriptionRequestPromiseImpl::~RTCSessionDescriptionRequestPromiseImp l()
30 {
31 DCHECK(!m_requester);
32 }
33
34 void RTCSessionDescriptionRequestPromiseImpl::requestSucceeded(const WebRTCSessi onDescription& webSessionDescription)
35 {
36 if (m_requester && m_requester->shouldFireDefaultCallbacks()) {
37 m_resolver->resolve(RTCSessionDescription::create(webSessionDescription) );
38 } else {
39 // This is needed to have the resolver release its internal resources
40 // while leaving the associated promise pending as specified.
41 m_resolver->detach();
42 }
43
44 clear();
45 }
46
47 void RTCSessionDescriptionRequestPromiseImpl::requestFailed(const String& error)
48 {
49 if (m_requester && m_requester->shouldFireDefaultCallbacks()) {
50 // TODO(guidou): The error code should come from the content layer. See crbug.com/589455
51 m_resolver->reject(DOMException::create(OperationError, error));
52 } else {
53 // This is needed to have the resolver release its internal resources
54 // while leaving the associated promise pending as specified.
55 m_resolver->detach();
56 }
57
58 clear();
59 }
60
61 void RTCSessionDescriptionRequestPromiseImpl::clear()
62 {
63 m_requester.clear();
64 }
65
66 DEFINE_TRACE(RTCSessionDescriptionRequestPromiseImpl)
67 {
68 visitor->trace(m_resolver);
69 visitor->trace(m_requester);
70 RTCSessionDescriptionRequest::trace(visitor);
71 }
72
73 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698