Пример #1
0
void ImageCapture::onTakePhoto(ScriptPromiseResolver* resolver, const String& mimeType, mojo::WTFArray<uint8_t> data)
{
    if (!m_serviceRequests.contains(resolver))
        return;

    if (data.is_null() || data.empty()) {
        resolver->reject(DOMException::create(UnknownError, "platform error"));
    } else {
        const auto& storage = data.storage();
        resolver->resolve(Blob::create(storage.data(), storage.size(), mimeType));
    }
    m_serviceRequests.remove(resolver);
}
Пример #2
0
void BudgetService::gotBudget(
    ScriptPromiseResolver* resolver,
    mojom::blink::BudgetServiceErrorType error,
    const mojo::WTFArray<mojom::blink::BudgetStatePtr> expectations) const {
  if (error != mojom::blink::BudgetServiceErrorType::NONE) {
    resolver->reject(errorTypeToException(error));
    return;
  }

  // Copy the chunks into the budget array.
  HeapVector<Member<BudgetState>> budget(expectations.size());
  for (size_t i = 0; i < expectations.size(); i++)
    budget[i] =
        new BudgetState(expectations[i]->budget_at, expectations[i]->time);

  resolver->resolve(budget);
}
Пример #3
0
VRDisplayVector VRController::updateDisplays(
    mojo::WTFArray<device::blink::VRDisplayPtr> displays) {
  VRDisplayVector vrDisplays;

  for (const auto& display : displays.PassStorage()) {
    VRDisplay* vrDisplay = createOrUpdateDisplay(display);
    vrDisplays.append(vrDisplay);
  }

  return vrDisplays;
}
Пример #4
0
VRDisplayVector VRDisplayCollection::updateDisplays(mojo::WTFArray<mojom::blink::VRDeviceInfoPtr> devices)
{
    VRDisplayVector vrDevices;

    for (const auto& device : devices.PassStorage()) {
        VRDisplay* display = getDisplayForIndex(device->index);
        if (!display) {
            display = new VRDisplay(m_navigatorVR);
            m_displays.append(display);
        }

        display->update(device);
        vrDevices.append(display);
    }

    return vrDevices;
}