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 |