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

Unified Diff: third_party/WebKit/Source/modules/mediastream/RTCVoidRequestPromiseImpl.cpp

Issue 1661493002: Add promise-based addIceCandidate, setLocalDescription and setRemoteDescription to RTCPeerConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: philipj's comments on tests Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/mediastream/RTCVoidRequestPromiseImpl.cpp
diff --git a/third_party/WebKit/Source/modules/mediastream/RTCVoidRequestPromiseImpl.cpp b/third_party/WebKit/Source/modules/mediastream/RTCVoidRequestPromiseImpl.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2618c965e9a2c08025143219f7c1390431b44d66
--- /dev/null
+++ b/third_party/WebKit/Source/modules/mediastream/RTCVoidRequestPromiseImpl.cpp
@@ -0,0 +1,69 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "modules/mediastream/RTCVoidRequestPromiseImpl.h"
+
+#include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "core/dom/DOMException.h"
+#include "modules/mediastream/RTCPeerConnection.h"
+
+namespace blink {
+
+RTCVoidRequestPromiseImpl* RTCVoidRequestPromiseImpl::create(RTCPeerConnection* requester, ScriptPromiseResolver* resolver, ExceptionCode exceptionCode)
+{
+ return new RTCVoidRequestPromiseImpl(requester, resolver, exceptionCode);
+}
+
+RTCVoidRequestPromiseImpl::RTCVoidRequestPromiseImpl(RTCPeerConnection* requester, ScriptPromiseResolver* resolver, ExceptionCode exceptionCode)
+ : m_requester(requester)
+ , m_resolver(resolver)
+ , m_exceptionCode(exceptionCode)
+{
+ ASSERT(m_requester);
+ ASSERT(m_resolver);
+}
+
+RTCVoidRequestPromiseImpl::~RTCVoidRequestPromiseImpl()
+{
+}
+
+void RTCVoidRequestPromiseImpl::requestSucceeded()
+{
+ if (m_requester && m_requester->shouldFireDefaultCallbacks()) {
+ m_resolver->resolve();
+ } else {
+ // This is needed to have the resolver release its internal resources
+ // while leaving the associated promise pending as specified.
+ m_resolver->detach();
+ }
+
+ clear();
+}
+
+void RTCVoidRequestPromiseImpl::requestFailed(const String& error)
+{
+ if (m_requester && m_requester->shouldFireDefaultCallbacks()) {
+ m_resolver->reject(DOMException::create(m_exceptionCode, error));
+ } else {
+ // This is needed to have the resolver release its internal resources
+ // while leaving the associated promise pending as specified.
+ m_resolver->detach();
+ }
+
+ clear();
+}
+
+void RTCVoidRequestPromiseImpl::clear()
+{
+ m_requester.clear();
+}
+
+DEFINE_TRACE(RTCVoidRequestPromiseImpl)
+{
+ visitor->trace(m_resolver);
+ visitor->trace(m_requester);
+ RTCVoidRequest::trace(visitor);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698