// 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_SERIAL_SERIAL_CONNECTION_H_ #define DEVICE_SERIAL_SERIAL_CONNECTION_H_ #include #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "device/serial/serial.mojom.h" #include "mojo/public/cpp/bindings/strong_binding.h" namespace device { class DataSinkReceiver; class DataSourceSender; class ReadOnlyBuffer; class SerialIoHandler; class WritableBuffer; class SerialConnection : public serial::Connection { public: SerialConnection(scoped_refptr io_handler, mojo::InterfaceRequest sink, mojo::InterfaceRequest source, mojo::InterfacePtr source_client, mojo::InterfaceRequest request); ~SerialConnection() override; // serial::Connection overrides. void GetInfo( const mojo::Callback& callback) override; void SetOptions(serial::ConnectionOptionsPtr options, const mojo::Callback& callback) override; void SetControlSignals(serial::HostControlSignalsPtr signals, const mojo::Callback& callback) override; void GetControlSignals( const mojo::Callback& callback) override; void Flush(const mojo::Callback& callback) override; private: void OnSendPipeReady(scoped_ptr buffer); void OnSendCancelled(int32_t error); void OnReceivePipeReady(scoped_ptr buffer); scoped_refptr io_handler_; scoped_refptr receiver_; scoped_refptr sender_; mojo::StrongBinding binding_; DISALLOW_COPY_AND_ASSIGN(SerialConnection); }; } // namespace device #endif // DEVICE_SERIAL_SERIAL_CONNECTION_H_