void VRController::getDisplays(std::unique_ptr<VRGetDevicesCallback> callback) { if (!m_service) { callback->onError(); return; } m_pendingGetDevicesCallbacks.append(std::move(callback)); m_service->GetDisplays(createBaseCallback(WTF::bind(&VRController::onGetDisplays, wrapPersistent(this)))); }
ImageCapture::ImageCapture(ExecutionContext* context, MediaStreamTrack* track) : ActiveScriptWrappable(this) , ContextLifecycleObserver(context) , m_streamTrack(track) { DCHECK(m_streamTrack); DCHECK(!m_service.is_bound()); Platform::current()->serviceRegistry()->connectToRemoteService(mojo::GetProxy(&m_service)); m_service.set_connection_error_handler(createBaseCallback(bind(&ImageCapture::onServiceConnectionError, WeakPersistentThisPointer<ImageCapture>(this)))); }
ScriptPromise ImageCapture::takePhoto(ScriptState* scriptState, ExceptionState& exceptionState) { ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); if (trackIsInactive(*m_streamTrack)) { resolver->reject(DOMException::create(InvalidStateError, "The associated Track is in an invalid state.")); return promise; } if (!m_service) { resolver->reject(DOMException::create(NotFoundError, kNoServiceError)); return promise; } m_serviceRequests.add(resolver); // m_streamTrack->component()->source()->id() is the renderer "name" of the camera; // TODO(mcasas) consider sending the security origin as well: // scriptState->getExecutionContext()->getSecurityOrigin()->toString() m_service->TakePhoto(m_streamTrack->component()->source()->id(), createBaseCallback(bind<String, mojo::WTFArray<uint8_t>>(&ImageCapture::onTakePhoto, this, resolver))); return promise; }