| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/presentation/ExistingPresentationConnectionCallbacks.h" | 5 #include "modules/presentation/ExistingPresentationConnectionCallbacks.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
| 9 #include "modules/presentation/PresentationConnection.h" | 9 #include "modules/presentation/PresentationConnection.h" |
| 10 #include "modules/presentation/PresentationError.h" | 10 #include "modules/presentation/PresentationError.h" |
| 11 #include "public/platform/modules/presentation/WebPresentationError.h" | 11 #include "public/platform/modules/presentation/WebPresentationError.h" |
| 12 #include "wtf/PtrUtil.h" | 12 #include "wtf/PtrUtil.h" |
| 13 #include <memory> | 13 #include <memory> |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 ExistingPresentationConnectionCallbacks:: | 17 ExistingPresentationConnectionCallbacks:: |
| 18 ExistingPresentationConnectionCallbacks(ScriptPromiseResolver* resolver, | 18 ExistingPresentationConnectionCallbacks(ScriptPromiseResolver* resolver, |
| 19 PresentationConnection* connection) | 19 PresentationConnection* connection) |
| 20 : m_resolver(resolver), m_connection(connection) { | 20 : m_resolver(resolver), m_connection(connection) { |
| 21 DCHECK(m_resolver); | 21 DCHECK(m_resolver); |
| 22 DCHECK(m_connection); | 22 DCHECK(m_connection); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void ExistingPresentationConnectionCallbacks::onSuccess( | 25 void ExistingPresentationConnectionCallbacks::onSuccess( |
| 26 const WebPresentationSessionInfo& sessionInfo) { | 26 const WebPresentationInfo& presentationInfo) { |
| 27 if (!m_resolver->getExecutionContext() || | 27 if (!m_resolver->getExecutionContext() || |
| 28 m_resolver->getExecutionContext()->isContextDestroyed()) { | 28 m_resolver->getExecutionContext()->isContextDestroyed()) { |
| 29 return; | 29 return; |
| 30 } | 30 } |
| 31 | 31 |
| 32 if (m_connection->getState() == WebPresentationConnectionState::Closed) | 32 if (m_connection->getState() == WebPresentationConnectionState::Closed) |
| 33 m_connection->didChangeState(WebPresentationConnectionState::Connecting); | 33 m_connection->didChangeState(WebPresentationConnectionState::Connecting); |
| 34 | 34 |
| 35 m_resolver->resolve(m_connection); | 35 m_resolver->resolve(m_connection); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void ExistingPresentationConnectionCallbacks::onError( | 38 void ExistingPresentationConnectionCallbacks::onError( |
| 39 const WebPresentationError& error) { | 39 const WebPresentationError& error) { |
| 40 NOTREACHED(); | 40 NOTREACHED(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 WebPresentationConnection* | 43 WebPresentationConnection* |
| 44 ExistingPresentationConnectionCallbacks::getConnection() { | 44 ExistingPresentationConnectionCallbacks::getConnection() { |
| 45 return m_connection.get(); | 45 return m_connection.get(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace blink | 48 } // namespace blink |
| OLD | NEW |