| 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/PresentationConnectionCallbacks.h" | 5 #include "modules/presentation/PresentationConnectionCallbacks.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 "modules/presentation/PresentationRequest.h" | 11 #include "modules/presentation/PresentationRequest.h" |
| 12 #include "public/platform/modules/presentation/WebPresentationConnectionClient.h
" | 12 #include "public/platform/modules/presentation/WebPresentationConnectionClient.h
" |
| 13 #include "public/platform/modules/presentation/WebPresentationError.h" | 13 #include "public/platform/modules/presentation/WebPresentationError.h" |
| 14 #include "wtf/PtrUtil.h" | |
| 15 #include <memory> | 14 #include <memory> |
| 15 #include <utility> |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 PresentationConnectionCallbacks::PresentationConnectionCallbacks( | 19 PresentationConnectionCallbacks::PresentationConnectionCallbacks( |
| 20 ScriptPromiseResolver* resolver, | 20 ScriptPromiseResolver* resolver, |
| 21 PresentationRequest* request) | 21 PresentationRequest* request) |
| 22 : m_resolver(resolver), m_request(request) { | 22 : m_resolver(resolver), m_request(request) { |
| 23 ASSERT(m_resolver); | 23 ASSERT(m_resolver); |
| 24 ASSERT(m_request); | 24 ASSERT(m_request); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void PresentationConnectionCallbacks::onSuccess( | 27 void PresentationConnectionCallbacks::onSuccess( |
| 28 std::unique_ptr<WebPresentationConnectionClient> | 28 std::unique_ptr<WebPresentationConnectionClient> |
| 29 PresentationConnectionClient) { | 29 presentationConnectionClient) { |
| 30 std::unique_ptr<WebPresentationConnectionClient> result( | 30 std::unique_ptr<WebPresentationConnectionClient> result( |
| 31 wrapUnique(PresentationConnectionClient.release())); | 31 std::move(presentationConnectionClient)); |
| 32 | 32 |
| 33 if (!m_resolver->getExecutionContext() || | 33 if (!m_resolver->getExecutionContext()) |
| 34 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | |
| 35 return; | 34 return; |
| 36 m_resolver->resolve(PresentationConnection::take( | 35 m_resolver->resolve(PresentationConnection::take( |
| 37 m_resolver.get(), std::move(result), m_request)); | 36 m_resolver.get(), std::move(result), m_request)); |
| 38 } | 37 } |
| 39 | 38 |
| 40 void PresentationConnectionCallbacks::onError( | 39 void PresentationConnectionCallbacks::onError( |
| 41 const WebPresentationError& error) { | 40 const WebPresentationError& error) { |
| 42 if (!m_resolver->getExecutionContext() || | 41 if (!m_resolver->getExecutionContext()) |
| 43 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | |
| 44 return; | 42 return; |
| 45 m_resolver->reject(PresentationError::take(m_resolver.get(), error)); | 43 m_resolver->reject(PresentationError::take(m_resolver.get(), error)); |
| 46 } | 44 } |
| 47 | 45 |
| 48 } // namespace blink | 46 } // namespace blink |
| OLD | NEW |