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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) | 87 ScriptPromise Presentation::startSession(ScriptState* state, const String& prese
ntationUrl) |
88 { | 88 { |
89 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(state); | 89 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, new PresentationSessionClientCallbacks
(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 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()); |
108 if (!client) { | 108 if (!client) { |
109 resolver->reject(DOMException::create(InvalidStateError, "The object is
no longer attached to the frame.")); | 109 resolver->reject(DOMException::create(InvalidStateError, "The object is
no longer attached to the frame.")); |
110 return promise; | 110 return promise; |
111 } | 111 } |
112 client->joinSession(presentationUrl, presentationId, new PresentationSession
ClientCallbacks(resolver, this)); | 112 client->joinSession(presentationUrl, presentationId, new PresentationSession
ClientCallbacks(resolver, this)); |
113 | 113 |
114 return promise; | 114 return promise; |
115 } | 115 } |
116 | 116 |
117 ScriptPromise Presentation::getAvailability(ScriptState* state, const String& pr
esentationUrl) | 117 ScriptPromise Presentation::getAvailability(ScriptState* state, const String& pr
esentationUrl) |
118 { | 118 { |
119 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(state); | 119 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(state); |
120 ScriptPromise promise = resolver->promise(); | 120 ScriptPromise promise = resolver->promise(); |
121 | 121 |
122 WebPresentationClient* client = presentationClient(executionContext()); | 122 WebPresentationClient* client = presentationClient(executionContext()); |
123 if (!client) { | 123 if (!client) { |
124 resolver->reject(DOMException::create(InvalidStateError, "The object is
no longer attached to the frame.")); | 124 resolver->reject(DOMException::create(InvalidStateError, "The object is
no longer attached to the frame.")); |
125 return promise; | 125 return promise; |
126 } | 126 } |
127 client->getAvailability(presentationUrl, new PresentationAvailabilityCallbac
k(resolver)); | 127 client->getAvailability(presentationUrl, new PresentationAvailabilityCallbac
k(resolver)); |
128 | 128 |
129 return promise; | 129 return promise; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 PresentationSession* Presentation::findSession(WebPresentationSessionClient* ses
sionClient) | 169 PresentationSession* Presentation::findSession(WebPresentationSessionClient* ses
sionClient) |
170 { | 170 { |
171 for (const auto& session : m_openSessions) { | 171 for (const auto& session : m_openSessions) { |
172 if (session->matches(sessionClient)) | 172 if (session->matches(sessionClient)) |
173 return session.get(); | 173 return session.get(); |
174 } | 174 } |
175 return nullptr; | 175 return nullptr; |
176 } | 176 } |
177 | 177 |
178 } // namespace blink | 178 } // namespace blink |
OLD | NEW |