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

Unified Diff: Source/modules/presentation/PresentationSessionClientCallbacks.cpp

Issue 940503002: [PresentationAPI] Added plumbing for start/joinSession from JS to platform (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed various lifetime issues with callbacks Created 5 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: Source/modules/presentation/PresentationSessionClientCallbacks.cpp
diff --git a/Source/modules/presentation/PresentationSessionClientCallbacks.cpp b/Source/modules/presentation/PresentationSessionClientCallbacks.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4515fbfa44e98ebb0fc0afd2f335be4c6f6bfbd4
--- /dev/null
+++ b/Source/modules/presentation/PresentationSessionClientCallbacks.cpp
@@ -0,0 +1,54 @@
+// Copyright 2015 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 "config.h"
+#include "modules/presentation/PresentationSessionClientCallbacks.h"
+
+#include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "core/dom/DOMException.h"
+#include "core/dom/ExceptionCode.h"
+#include "modules/presentation/Presentation.h"
+#include "modules/presentation/PresentationSession.h"
+#include "public/platform/WebString.h"
+#include "public/platform/modules/presentation/WebPresentationError.h"
+
+namespace blink {
+
+PresentationSessionClientCallbacks::PresentationSessionClientCallbacks(
+ PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver,
+ Presentation* presentation)
+ : m_resolver(resolver)
+ , m_presentation(presentation)
+{
+ ASSERT(m_resolver);
+ ASSERT(m_presentation);
+}
+
+PresentationSessionClientCallbacks::~PresentationSessionClientCallbacks()
+{
+}
+
+void PresentationSessionClientCallbacks::onSuccess(WebString* id)
+{
+ ASSERT(id);
+ if (m_resolver->executionContext() && !m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
+ PresentationSession* session = PresentationSession::create(m_presentation->frame(), *id);
mlamouri (slow - plz ping) 2015/02/26 10:57:03 Could you use ::dispose() and ::take() methods?
whywhat 2015/02/26 15:50:54 Sorry, there's no way I'm creating a PresentationS
+ m_presentation->didCreateSession(session);
+ m_resolver->resolve(session);
+ }
+ delete id;
+}
+
+void PresentationSessionClientCallbacks::onError(WebPresentationError* error)
+{
+ ASSERT(error);
+ if (m_resolver->executionContext() && !m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
+ // TODO(avayvod): figure out the mapping between WebPresentationError and
+ // DOMException error codes.
+ m_resolver->reject(DOMException::create(InvalidAccessError, error->message));
mlamouri (slow - plz ping) 2015/02/26 10:57:03 ditto
whywhat 2015/02/26 15:50:54 Any suggestions on mapping WebPresentationError to
+ }
+ delete error;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698