Index: third_party/WebKit/Source/modules/presentation/PresentationConnectionCallbacks.cpp |
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationConnectionCallbacks.cpp b/third_party/WebKit/Source/modules/presentation/PresentationConnectionCallbacks.cpp |
index 30c89bb1c5090ddda6219a54eea174d9554cc423..88980d1de2890b084e9caadbd20a63ee6f3799b4 100644 |
--- a/third_party/WebKit/Source/modules/presentation/PresentationConnectionCallbacks.cpp |
+++ b/third_party/WebKit/Source/modules/presentation/PresentationConnectionCallbacks.cpp |
@@ -18,7 +18,7 @@ namespace blink { |
PresentationConnectionCallbacks::PresentationConnectionCallbacks( |
ScriptPromiseResolver* resolver, |
PresentationRequest* request) |
- : m_resolver(resolver), m_request(request) { |
+ : m_resolver(resolver), m_request(request), m_connection(nullptr) { |
ASSERT(m_resolver); |
ASSERT(m_request); |
} |
@@ -29,16 +29,24 @@ void PresentationConnectionCallbacks::onSuccess( |
m_resolver->getExecutionContext()->isContextDestroyed()) { |
return; |
} |
- m_resolver->resolve( |
- PresentationConnection::take(m_resolver.get(), sessionInfo, m_request)); |
+ |
+ m_connection = |
+ PresentationConnection::take(m_resolver.get(), sessionInfo, m_request); |
+ m_resolver->resolve(m_connection); |
} |
void PresentationConnectionCallbacks::onError( |
const WebPresentationError& error) { |
if (!m_resolver->getExecutionContext() || |
- m_resolver->getExecutionContext()->isContextDestroyed()) |
+ m_resolver->getExecutionContext()->isContextDestroyed()) { |
return; |
+ } |
m_resolver->reject(PresentationError::take(error)); |
+ m_connection = nullptr; |
+} |
+ |
+WebPresentationConnection* PresentationConnectionCallbacks::getConnection() { |
+ return m_connection ? m_connection.get() : nullptr; |
} |
} // namespace blink |