[Storage] Blob Storage Refactoring pt 1:
[chromium-blink-merge.git] / device / serial / test_serial_io_handler.h
blobdfa27dbf09b523a332d4c37597aa45e6d755932c
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef DEVICE_SERIAL_TEST_SERIAL_IO_HANDLER_H_
6 #define DEVICE_SERIAL_TEST_SERIAL_IO_HANDLER_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "device/serial/serial.mojom.h"
12 #include "device/serial/serial_io_handler.h"
14 namespace device {
16 class TestSerialIoHandler : public SerialIoHandler {
17 public:
18 TestSerialIoHandler();
20 static scoped_refptr<SerialIoHandler> Create();
22 // SerialIoHandler overrides.
23 void Open(const std::string& port,
24 const OpenCompleteCallback& callback) override;
25 bool ConfigurePort(const serial::ConnectionOptions& options) override;
26 void ReadImpl() override;
27 void CancelReadImpl() override;
28 void WriteImpl() override;
29 void CancelWriteImpl() override;
30 serial::DeviceControlSignalsPtr GetControlSignals() const override;
31 serial::ConnectionInfoPtr GetPortInfo() const override;
32 bool Flush() const override;
33 bool SetControlSignals(const serial::HostControlSignals& signals) override;
35 serial::ConnectionInfo* connection_info() { return &info_; }
36 serial::DeviceControlSignals* device_control_signals() {
37 return &device_control_signals_;
39 bool dtr() { return dtr_; }
40 bool rts() { return rts_; }
41 int flushes() { return flushes_; }
42 // This callback will be called when this IoHandler processes its next write,
43 // instead of the normal behavior of echoing the data to reads.
44 void set_send_callback(const base::Closure& callback) {
45 send_callback_ = callback;
48 protected:
49 ~TestSerialIoHandler() override;
51 private:
52 bool opened_;
53 serial::ConnectionInfo info_;
54 serial::DeviceControlSignals device_control_signals_;
55 bool dtr_;
56 bool rts_;
57 mutable int flushes_;
58 std::string buffer_;
59 base::Closure send_callback_;
61 DISALLOW_COPY_AND_ASSIGN(TestSerialIoHandler);
64 } // namespace device
66 #endif // DEVICE_SERIAL_TEST_SERIAL_IO_HANDLER_H_