OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/imagecapture/ImageCapture.h" | 5 #include "modules/imagecapture/ImageCapture.h" |
6 | 6 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 102 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
103 ScriptPromise promise = resolver->promise(); | 103 ScriptPromise promise = resolver->promise(); |
104 | 104 |
105 if (!m_service) { | 105 if (!m_service) { |
106 resolver->reject(DOMException::create(NotFoundError, kNoServiceError)); | 106 resolver->reject(DOMException::create(NotFoundError, kNoServiceError)); |
107 return promise; | 107 return promise; |
108 } | 108 } |
109 | 109 |
110 m_serviceRequests.add(resolver); | 110 m_serviceRequests.add(resolver); |
111 | 111 |
112 // m_streamTrack->component()->source()->id() is the renderer "name" of the ca
mera; | 112 // m_streamTrack->component()->source()->id() is the renderer "name" of the |
| 113 // camera; |
113 // TODO(mcasas) consider sending the security origin as well: | 114 // TODO(mcasas) consider sending the security origin as well: |
114 // scriptState->getExecutionContext()->getSecurityOrigin()->toString() | 115 // scriptState->getExecutionContext()->getSecurityOrigin()->toString() |
115 m_service->GetCapabilities( | 116 m_service->GetCapabilities( |
116 m_streamTrack->component()->source()->id(), | 117 m_streamTrack->component()->source()->id(), |
117 convertToBaseCallback(WTF::bind(&ImageCapture::onCapabilities, | 118 convertToBaseCallback(WTF::bind(&ImageCapture::onCapabilities, |
118 wrapPersistent(this), | 119 wrapPersistent(this), |
119 wrapPersistent(resolver)))); | 120 wrapPersistent(resolver)))); |
120 return promise; | 121 return promise; |
121 } | 122 } |
122 | 123 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return promise; | 206 return promise; |
206 } | 207 } |
207 | 208 |
208 if (!m_service) { | 209 if (!m_service) { |
209 resolver->reject(DOMException::create(NotFoundError, kNoServiceError)); | 210 resolver->reject(DOMException::create(NotFoundError, kNoServiceError)); |
210 return promise; | 211 return promise; |
211 } | 212 } |
212 | 213 |
213 m_serviceRequests.add(resolver); | 214 m_serviceRequests.add(resolver); |
214 | 215 |
215 // m_streamTrack->component()->source()->id() is the renderer "name" of the ca
mera; | 216 // m_streamTrack->component()->source()->id() is the renderer "name" of the |
| 217 // camera; |
216 // TODO(mcasas) consider sending the security origin as well: | 218 // TODO(mcasas) consider sending the security origin as well: |
217 // scriptState->getExecutionContext()->getSecurityOrigin()->toString() | 219 // scriptState->getExecutionContext()->getSecurityOrigin()->toString() |
218 m_service->TakePhoto(m_streamTrack->component()->source()->id(), | 220 m_service->TakePhoto(m_streamTrack->component()->source()->id(), |
219 convertToBaseCallback(WTF::bind( | 221 convertToBaseCallback(WTF::bind( |
220 &ImageCapture::onTakePhoto, wrapPersistent(this), | 222 &ImageCapture::onTakePhoto, wrapPersistent(this), |
221 wrapPersistent(resolver)))); | 223 wrapPersistent(resolver)))); |
222 return promise; | 224 return promise; |
223 } | 225 } |
224 | 226 |
225 ScriptPromise ImageCapture::grabFrame(ScriptState* scriptState, | 227 ScriptPromise ImageCapture::grabFrame(ScriptState* scriptState, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } | 348 } |
347 | 349 |
348 DEFINE_TRACE(ImageCapture) { | 350 DEFINE_TRACE(ImageCapture) { |
349 visitor->trace(m_streamTrack); | 351 visitor->trace(m_streamTrack); |
350 visitor->trace(m_serviceRequests); | 352 visitor->trace(m_serviceRequests); |
351 EventTargetWithInlineData::trace(visitor); | 353 EventTargetWithInlineData::trace(visitor); |
352 ContextLifecycleObserver::trace(visitor); | 354 ContextLifecycleObserver::trace(visitor); |
353 } | 355 } |
354 | 356 |
355 } // namespace blink | 357 } // namespace blink |
OLD | NEW |