chromium/third_party/blink/renderer/modules/hid/hid_device.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/hid/hid_device.h"

#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_hid_collection_info.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_hid_report_info.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_array_piece.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_data_view.h"
#include "third_party/blink/renderer/modules/event_target_modules.h"
#include "third_party/blink/renderer/modules/hid/hid_input_report_event.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"

namespace blink {

namespace {

const char kDeviceStateChangeInProgress[] =;
const char kDeviceIsForgotten[] =;
const char kOpenRequired[] =;
const char kOpenFailed[] =;
const char kSendReportFailed[] =;
const char kSendFeatureReportFailed[] =;
const char kReceiveFeatureReportFailed[] =;
const char kUnexpectedClose[] =;
const char kArrayBufferTooBig[] =;
const char kContextGone[] =;

enum ReportType {};

bool IsProtectedReportType(
    const device::mojom::blink::HidUsageAndPage& hid_usage_and_page,
    ReportType report_type) {}

// The HID specification defines four canonical unit systems. Each unit system
// corresponds to a set of units for length, mass, time, temperature, current,
// and luminous intensity. The vendor-defined unit system can be used for
// devices which produce measurements that cannot be adequately described by
// these unit systems.
//
// See the Units table in section 6.2.2.7 of the Device Class Definition for
// HID v1.11.
// https://www.usb.org/document-library/device-class-definition-hid-111
enum HidUnitSystem {};

uint32_t ConvertHidUsageAndPageToUint32(
    const device::mojom::blink::HidUsageAndPage& usage) {}

String UnitSystemToString(uint8_t unit) {}

// Convert |unit_factor_exponent| from its coded representation to a signed
// integer type.
int8_t UnitFactorExponentToInt(uint8_t unit_factor_exponent) {}

// Unpack the 32-bit unit definition value |unit| into each of its components.
// The unit definition value includes the unit system as well as unit factor
// exponents for each of the 6 units defined by the unit system.
void UnpackUnitValues(uint32_t unit,
                      String& unit_system,
                      int8_t& length_exponent,
                      int8_t& mass_exponent,
                      int8_t& time_exponent,
                      int8_t& temperature_exponent,
                      int8_t& current_exponent,
                      int8_t& luminous_intensity_exponent) {}

HIDReportInfo* ToHIDReportInfo(
    const device::mojom::blink::HidReportDescription& report_info) {}

HIDCollectionInfo* ToHIDCollectionInfo(
    const device::mojom::blink::HidCollectionInfo& collection) {}

}  // namespace

HIDDevice::HIDDevice(ServiceInterface* parent,
                     device::mojom::blink::HidDeviceInfoPtr info,
                     ExecutionContext* context)
    :{}

HIDDevice::~HIDDevice() {}

ExecutionContext* HIDDevice::GetExecutionContext() const {}

const AtomicString& HIDDevice::InterfaceName() const {}

void HIDDevice::OnInputReport(uint8_t report_id,
                              const Vector<uint8_t>& buffer) {}

bool HIDDevice::opened() const {}

uint16_t HIDDevice::vendorId() const {}

uint16_t HIDDevice::productId() const {}

String HIDDevice::productName() const {}

const HeapVector<Member<HIDCollectionInfo>>& HIDDevice::collections() const {}

ScriptPromise<IDLUndefined> HIDDevice::open(ScriptState* script_state,
                                            ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> HIDDevice::close(ScriptState* script_state) {}

ScriptPromise<IDLUndefined> HIDDevice::forget(ScriptState* script_state,
                                              ExceptionState& exception_state) {}

ScriptPromise<IDLUndefined> HIDDevice::sendReport(ScriptState* script_state,
                                                  uint8_t report_id,
                                                  const DOMArrayPiece& data) {}

ScriptPromise<IDLUndefined> HIDDevice::sendFeatureReport(
    ScriptState* script_state,
    uint8_t report_id,
    const DOMArrayPiece& data) {}

ScriptPromise<NotShared<DOMDataView>> HIDDevice::receiveFeatureReport(
    ScriptState* script_state,
    uint8_t report_id) {}

void HIDDevice::ContextDestroyed() {}

bool HIDDevice::HasPendingActivity() const {}

void HIDDevice::UpdateDeviceInfo(device::mojom::blink::HidDeviceInfoPtr info) {}

void HIDDevice::ResetIsForgotten() {}

void HIDDevice::Trace(Visitor* visitor) const {}

bool HIDDevice::EnsureNoDeviceChangeInProgress(
    ScriptPromiseResolverBase* resolver) const {}

bool HIDDevice::EnsureDeviceIsNotForgotten(
    ScriptPromiseResolverBase* resolver) const {}

void HIDDevice::FinishOpen(
    ScriptPromiseResolver<IDLUndefined>* resolver,
    mojo::PendingRemote<device::mojom::blink::HidConnection> connection) {}

void HIDDevice::FinishForget(ScriptPromiseResolver<IDLUndefined>* resolver) {}

void HIDDevice::OnServiceConnectionError() {}

void HIDDevice::FinishSendReport(ScriptPromiseResolver<IDLUndefined>* resolver,
                                 bool success) {}

void HIDDevice::FinishSendFeatureReport(
    ScriptPromiseResolver<IDLUndefined>* resolver,
    bool success) {}

void HIDDevice::FinishReceiveFeatureReport(
    ScriptPromiseResolver<NotShared<DOMDataView>>* resolver,
    bool success,
    const std::optional<Vector<uint8_t>>& data) {}

void HIDDevice::MarkRequestComplete(ScriptPromiseResolverBase* resolver) {}

// static
HIDReportItem* HIDDevice::ToHIDReportItem(
    const device::mojom::blink::HidReportItem& report_item) {}

}  // namespace blink