--- services/device/hid/hid_service_freebsd.h.orig 2022-03-28 18:11:04 UTC +++ services/device/hid/hid_service_freebsd.h @@ -0,0 +1,49 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef DEVICE_HID_HID_SERVICE_FREEBSD_H_ +#define DEVICE_HID_HID_SERVICE_FREEBSD_H_ + +#include + +#include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" +#include "base/timer/timer.h" +#include "services/device/hid/hid_service.h" +#include "net/base/io_buffer.h" + +namespace device { + +class HidServiceFreeBSD : public HidService { + public: + HidServiceFreeBSD(); + + HidServiceFreeBSD(const HidServiceFreeBSD&) = delete; + HidServiceFreeBSD& operator=(const HidServiceFreeBSD&) = delete; + + ~HidServiceFreeBSD() override; + + void Connect(const std::string& device_guid, + bool allow_protected_reports, + bool allow_fido_reports, + ConnectCallback connect) override; + base::WeakPtr GetWeakPtr() override; + + private: + struct ConnectParams; + class BlockingTaskRunnerHelper; + + static void OpenOnBlockingThread(std::unique_ptr params); + static void FinishOpen(std::unique_ptr params); + + const scoped_refptr blocking_task_runner_; + // |helper_| lives on the sequence |blocking_task_runner_| posts to and holds + // a weak reference back to the service that owns it. + std::unique_ptr helper_; + base::WeakPtrFactory weak_factory_{this}; +}; + +} // namespace device + +#endif // DEVICE_HID_HID_SERVICE_FREEBSD_H_