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 "core/dom/ExecutionContextTask.h" | |
9 #include "modules/presentation/PresentationConnection.h" | 10 #include "modules/presentation/PresentationConnection.h" |
11 #include "modules/presentation/PresentationConnectionAvailableEvent.h" | |
10 #include "modules/presentation/PresentationError.h" | 12 #include "modules/presentation/PresentationError.h" |
11 #include "modules/presentation/PresentationRequest.h" | 13 #include "modules/presentation/PresentationRequest.h" |
12 #include "public/platform/modules/presentation/WebPresentationConnectionClient.h " | 14 #include "public/platform/modules/presentation/WebPresentationConnectionClient.h " |
13 #include "public/platform/modules/presentation/WebPresentationError.h" | 15 #include "public/platform/modules/presentation/WebPresentationError.h" |
14 #include "wtf/PtrUtil.h" | 16 #include "wtf/PtrUtil.h" |
15 #include <memory> | 17 #include <memory> |
16 | 18 |
17 namespace blink { | 19 namespace blink { |
18 | 20 |
19 PresentationConnectionCallbacks::PresentationConnectionCallbacks( | 21 PresentationConnectionCallbacks::PresentationConnectionCallbacks( |
20 ScriptPromiseResolver* resolver, | 22 ScriptPromiseResolver* resolver, |
21 PresentationRequest* request) | 23 PresentationRequest* request) |
22 : m_resolver(resolver), m_request(request) { | 24 : m_resolver(resolver), m_request(request) { |
23 ASSERT(m_resolver); | 25 ASSERT(m_resolver); |
24 ASSERT(m_request); | 26 ASSERT(m_request); |
25 } | 27 } |
26 | 28 |
27 void PresentationConnectionCallbacks::onSuccess( | 29 void PresentationConnectionCallbacks::onSuccess( |
28 std::unique_ptr<WebPresentationConnectionClient> | 30 std::unique_ptr<WebPresentationConnectionClient> |
29 PresentationConnectionClient) { | 31 PresentationConnectionClient) { |
30 std::unique_ptr<WebPresentationConnectionClient> result( | 32 std::unique_ptr<WebPresentationConnectionClient> result( |
31 wrapUnique(PresentationConnectionClient.release())); | 33 wrapUnique(PresentationConnectionClient.release())); |
32 | 34 |
33 if (!m_resolver->getExecutionContext() || | 35 if (!m_resolver->getExecutionContext() || |
34 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | 36 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) |
35 return; | 37 return; |
36 m_resolver->resolve(PresentationConnection::take( | 38 |
37 m_resolver.get(), std::move(result), m_request)); | 39 auto* connection = PresentationConnection::take(m_resolver.get(), |
40 std::move(result), m_request); | |
41 m_resolver->resolve(connection); | |
42 | |
43 m_resolver->getExecutionContext()->postTask( | |
44 BLINK_FROM_HERE, | |
45 createSameThreadTask( | |
46 &PresentationRequest::dispatchConnectionAvailableEvent, m_request, | |
47 wrapPersistent(connection))); | |
mlamouri (slow - plz ping)
2016/12/05 13:39:10
Any reason I'm missing why this is not in the ::ta
| |
38 } | 48 } |
39 | 49 |
40 void PresentationConnectionCallbacks::onError( | 50 void PresentationConnectionCallbacks::onError( |
41 const WebPresentationError& error) { | 51 const WebPresentationError& error) { |
42 if (!m_resolver->getExecutionContext() || | 52 if (!m_resolver->getExecutionContext() || |
43 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | 53 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) |
44 return; | 54 return; |
45 m_resolver->reject(PresentationError::take(m_resolver.get(), error)); | 55 m_resolver->reject(PresentationError::take(m_resolver.get(), error)); |
46 } | 56 } |
47 | 57 |
48 } // namespace blink | 58 } // namespace blink |
OLD | NEW |