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

Unified Diff: third_party/WebKit/Source/modules/presentation/ExistingPresentationConnectionCallbacks.cpp

Issue 2602523002: [Presentation API] Resolve PresentationRequest::reconnect() with existing presentation connection i… (Closed)
Patch Set: remove getExecutionContext() null check in PresentationRequest::reconnect() Created 3 years, 11 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/presentation/ExistingPresentationConnectionCallbacks.cpp
diff --git a/third_party/WebKit/Source/modules/presentation/ExistingPresentationConnectionCallbacks.cpp b/third_party/WebKit/Source/modules/presentation/ExistingPresentationConnectionCallbacks.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7d7a69e17d13079a106deb9ccdd7c850aa87fe22
--- /dev/null
+++ b/third_party/WebKit/Source/modules/presentation/ExistingPresentationConnectionCallbacks.cpp
@@ -0,0 +1,43 @@
+// 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 "modules/presentation/ExistingPresentationConnectionCallbacks.h"
+
+#include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "core/dom/DOMException.h"
+#include "modules/presentation/PresentationConnection.h"
+#include "modules/presentation/PresentationError.h"
+#include "public/platform/modules/presentation/WebPresentationError.h"
+#include "wtf/PtrUtil.h"
+#include <memory>
+
+namespace blink {
+
+ExistingPresentationConnectionCallbacks::
+ ExistingPresentationConnectionCallbacks(ScriptPromiseResolver* resolver,
+ PresentationConnection* connection)
+ : m_resolver(resolver), m_connection(connection) {
+ DCHECK(m_resolver);
+ DCHECK(m_connection);
+}
+
+void ExistingPresentationConnectionCallbacks::onSuccess(
+ const WebPresentationSessionInfo& sessionInfo) {
+ if (!m_resolver->getExecutionContext() ||
+ m_resolver->getExecutionContext()->isContextDestroyed()) {
+ return;
+ }
+
+ if (m_connection->getState() == WebPresentationConnectionState::Closed)
+ m_connection->didChangeState(WebPresentationConnectionState::Connecting);
+
+ m_resolver->resolve(m_connection);
+}
+
+void ExistingPresentationConnectionCallbacks::onError(
+ const WebPresentationError& error) {
+ NOTREACHED();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698