| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/presentation/PresentationRequest.h" | 6 #include "modules/presentation/PresentationRequest.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 bool PresentationRequest::hasPendingActivity() const | 62 bool PresentationRequest::hasPendingActivity() const |
| 63 { | 63 { |
| 64 // Prevents garbage collecting of this object when not hold by another | 64 // Prevents garbage collecting of this object when not hold by another |
| 65 // object but still has listeners registered. | 65 // object but still has listeners registered. |
| 66 return hasEventListeners(); | 66 return hasEventListeners(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 ScriptPromise PresentationRequest::start(ScriptState* scriptState) | 69 ScriptPromise PresentationRequest::start(ScriptState* scriptState) |
| 70 { | 70 { |
| 71 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 71 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 72 ScriptPromise promise = resolver->promise(); | 72 ScriptPromise promise = resolver->promise(); |
| 73 | 73 |
| 74 WebPresentationClient* client = presentationClient(executionContext()); | 74 WebPresentationClient* client = presentationClient(executionContext()); |
| 75 if (!client) { | 75 if (!client) { |
| 76 resolver->reject(DOMException::create(InvalidStateError, "The Presentati
onRequest is no longer associated to a frame.")); | 76 resolver->reject(DOMException::create(InvalidStateError, "The Presentati
onRequest is no longer associated to a frame.")); |
| 77 return promise; | 77 return promise; |
| 78 } | 78 } |
| 79 client->startSession(m_url.string(), new CallbackPromiseAdapter<Presentation
Session, PresentationError>(resolver)); | 79 client->startSession(m_url.string(), new CallbackPromiseAdapter<Presentation
Session, PresentationError>(resolver)); |
| 80 | 80 |
| 81 return promise; | 81 return promise; |
| 82 } | 82 } |
| 83 | 83 |
| 84 ScriptPromise PresentationRequest::join(ScriptState* scriptState, const String&
id) | 84 ScriptPromise PresentationRequest::join(ScriptState* scriptState, const String&
id) |
| 85 { | 85 { |
| 86 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 86 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 87 ScriptPromise promise = resolver->promise(); | 87 ScriptPromise promise = resolver->promise(); |
| 88 | 88 |
| 89 WebPresentationClient* client = presentationClient(executionContext()); | 89 WebPresentationClient* client = presentationClient(executionContext()); |
| 90 if (!client) { | 90 if (!client) { |
| 91 resolver->reject(DOMException::create(InvalidStateError, "The Presentati
onRequest is no longer associated to a frame.")); | 91 resolver->reject(DOMException::create(InvalidStateError, "The Presentati
onRequest is no longer associated to a frame.")); |
| 92 return promise; | 92 return promise; |
| 93 } | 93 } |
| 94 client->joinSession(m_url.string(), id, new CallbackPromiseAdapter<Presentat
ionSession, PresentationError>(resolver)); | 94 client->joinSession(m_url.string(), id, new CallbackPromiseAdapter<Presentat
ionSession, PresentationError>(resolver)); |
| 95 | 95 |
| 96 return promise; | 96 return promise; |
| 97 } | 97 } |
| 98 | 98 |
| 99 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) | 99 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) |
| 100 { | 100 { |
| 101 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 101 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 102 ScriptPromise promise = resolver->promise(); | 102 ScriptPromise promise = resolver->promise(); |
| 103 | 103 |
| 104 WebPresentationClient* client = presentationClient(executionContext()); | 104 WebPresentationClient* client = presentationClient(executionContext()); |
| 105 if (!client) { | 105 if (!client) { |
| 106 resolver->reject(DOMException::create(InvalidStateError, "The object is
no longer associated to a frame.")); | 106 resolver->reject(DOMException::create(InvalidStateError, "The object is
no longer associated to a frame.")); |
| 107 return promise; | 107 return promise; |
| 108 } | 108 } |
| 109 client->getAvailability(m_url.string(), new CallbackPromiseAdapter<Presentat
ionAvailability, PresentationError>(resolver)); | 109 client->getAvailability(m_url.string(), new CallbackPromiseAdapter<Presentat
ionAvailability, PresentationError>(resolver)); |
| 110 | 110 |
| 111 return promise; | 111 return promise; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 122 ActiveDOMObject::trace(visitor); | 122 ActiveDOMObject::trace(visitor); |
| 123 } | 123 } |
| 124 | 124 |
| 125 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, con
st KURL& url) | 125 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, con
st KURL& url) |
| 126 : ActiveDOMObject(executionContext) | 126 : ActiveDOMObject(executionContext) |
| 127 , m_url(url) | 127 , m_url(url) |
| 128 { | 128 { |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace blink | 131 } // namespace blink |
| OLD | NEW |