1 --- services/device/hid/hid_connection_fido.h.orig 2022-02-07 13:39:41 UTC 2 +++ services/device/hid/hid_connection_fido.h 3 @@ -0,0 +1,57 @@ 4 +// Copyright (c) 2020 The Chromium Authors. All rights reserved. 5 +// Use of this source code is governed by a BSD-style license that can be 6 +// found in the LICENSE file. 7 + 8 +#ifndef SERVICE_DEVICE_HID_HID_CONNECTION_FIDO_H_ 9 +#define SERVICE_DEVICE_HID_HID_CONNECTION_FIDO_H_ 10 + 11 +#include "base/files/scoped_file.h" 12 +#include "base/memory/ptr_util.h" 13 +#include "base/memory/ref_counted_memory.h" 14 +#include "base/memory/weak_ptr.h" 15 +#include "base/sequence_checker.h" 16 +#include "services/device/hid/hid_connection.h" 17 + 18 +namespace device { 19 + 20 +class HidConnectionFido : public HidConnection { 21 +public: 22 + HidConnectionFido( 23 + scoped_refptr<HidDeviceInfo> device_info, base::ScopedFD fd, 24 + scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, 25 + bool allow_protected_reports, bool allow_fido_reports); 26 + 27 +private: 28 + friend class base::RefCountedThreadSafe<HidConnectionFido>; 29 + class BlockingTaskHelper; 30 + 31 + HidConnectionFido(const HidConnectionFido&) = delete; 32 + HidConnectionFido& operator=(const HidConnectionFido&) = delete; 33 + 34 + ~HidConnectionFido() override; 35 + 36 + // HidConnection implementation. 37 + void PlatformClose() override; 38 + void PlatformWrite(scoped_refptr<base::RefCountedBytes> buffer, 39 + WriteCallback callback) override; 40 + void PlatformGetFeatureReport(uint8_t report_id, 41 + ReadCallback callback) override; 42 + void PlatformSendFeatureReport(scoped_refptr<base::RefCountedBytes> buffer, 43 + WriteCallback callback) override; 44 + 45 + const scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 46 + const scoped_refptr<base::SequencedTaskRunner> task_runner_; 47 + 48 + SEQUENCE_CHECKER(sequence_checker_); 49 + 50 + base::WeakPtrFactory<HidConnectionFido> weak_factory_; 51 + 52 + // |helper_| lives on the sequence to which |blocking_task_runner_| posts 53 + // tasks so all calls must be posted there including this object's 54 + // destruction. 55 + std::unique_ptr<BlockingTaskHelper> helper_; 56 +}; 57 + 58 +} // namespace device 59 + 60 +#endif // SERVICE_DEVICE_HID_HID_CONNECTION_FIDO_H_ 61