chromium/services/device/usb/fake_usb_device_handle.h

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

#ifndef SERVICES_DEVICE_USB_FAKE_USB_DEVICE_HANDLE_H_
#define SERVICES_DEVICE_USB_FAKE_USB_DEVICE_HANDLE_H_

#include <vector>

#include "base/memory/raw_ptr.h"
#include "services/device/usb/usb_device_handle.h"

namespace device {

// This class implements a fake USB device handle that will handle control
// requests by responding with data out of the provided buffer. The format of
// each record in the buffer is:
//
// 0         1         2         3...
// +---------+---------+---------+---------- - - -
// | success |      length       | data...
// +---------+---------+---------+---------- - - -
//
// If |success| is 1 the transfer will succeed and respond with |length| bytes
// of the following data (no data is consumed for outgoing transfers). If
// |success| is 0 the transfer will fail with USB_TRANSFER_ERROR. If the buffer
// is exhausted all following transfers will fail with USB_TRANSFER_DISCONNECT.
class FakeUsbDeviceHandle : public UsbDeviceHandle {};

}  // namespace device

#endif  // SERVICES_DEVICE_USB_FAKE_USB_DEVICE_HANDLE_H_