| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/presentation/Presentation.h" | 6 #include "modules/presentation/Presentation.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 visitor->trace(m_openSessions); | 77 visitor->trace(m_openSessions); |
| 78 RefCountedGarbageCollectedEventTargetWithInlineData<Presentation>::trace(vis
itor); | 78 RefCountedGarbageCollectedEventTargetWithInlineData<Presentation>::trace(vis
itor); |
| 79 DOMWindowProperty::trace(visitor); | 79 DOMWindowProperty::trace(visitor); |
| 80 } | 80 } |
| 81 | 81 |
| 82 PresentationSession* Presentation::session() const | 82 PresentationSession* Presentation::session() const |
| 83 { | 83 { |
| 84 return m_session.get(); | 84 return m_session.get(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 ScriptPromise Presentation::startSession(ScriptState* state, const String& prese
ntationUrl, const String& presentationId) | 87 ScriptPromise Presentation::startSession(ScriptState* state, const String& prese
ntationUrl) |
| 88 { | 88 { |
| 89 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(state); | 89 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(state); |
| 90 ScriptPromise promise = resolver->promise(); | 90 ScriptPromise promise = resolver->promise(); |
| 91 | 91 |
| 92 WebPresentationClient* client = presentationClient(executionContext()); | 92 WebPresentationClient* client = presentationClient(executionContext()); |
| 93 if (!client) { | 93 if (!client) { |
| 94 resolver->reject(DOMException::create(InvalidStateError, "The object is
no longer attached to the frame.")); | 94 resolver->reject(DOMException::create(InvalidStateError, "The object is
no longer attached to the frame.")); |
| 95 return promise; | 95 return promise; |
| 96 } | 96 } |
| 97 client->startSession(presentationUrl, presentationId, new PresentationSessio
nClientCallbacks(resolver, this)); | 97 client->startSession(presentationUrl, new PresentationSessionClientCallbacks
(resolver, this)); |
| 98 | 98 |
| 99 return promise; | 99 return promise; |
| 100 } | 100 } |
| 101 | 101 |
| 102 ScriptPromise Presentation::joinSession(ScriptState* state, const String& presen
tationUrl, const String& presentationId) | 102 ScriptPromise Presentation::joinSession(ScriptState* state, const String& presen
tationUrl, const String& presentationId) |
| 103 { | 103 { |
| 104 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(state); | 104 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(state); |
| 105 ScriptPromise promise = resolver->promise(); | 105 ScriptPromise promise = resolver->promise(); |
| 106 | 106 |
| 107 WebPresentationClient* client = presentationClient(executionContext()); | 107 WebPresentationClient* client = presentationClient(executionContext()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 PresentationSession* Presentation::findSession(WebPresentationSessionClient* ses
sionClient) | 160 PresentationSession* Presentation::findSession(WebPresentationSessionClient* ses
sionClient) |
| 161 { | 161 { |
| 162 for (const auto& session : m_openSessions) { | 162 for (const auto& session : m_openSessions) { |
| 163 if (session->matches(sessionClient)) | 163 if (session->matches(sessionClient)) |
| 164 return session.get(); | 164 return session.get(); |
| 165 } | 165 } |
| 166 return nullptr; | 166 return nullptr; |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace blink | 169 } // namespace blink |
| OLD | NEW |