| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_SERIAL_SERIAL_CONNECTION_H_ | 5 #ifndef DEVICE_SERIAL_SERIAL_CONNECTION_H_ |
| 6 #define DEVICE_SERIAL_SERIAL_CONNECTION_H_ | 6 #define DEVICE_SERIAL_SERIAL_CONNECTION_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "device/serial/serial.mojom.h" | 10 #include "device/serial/serial.mojom.h" |
| 11 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h" | 11 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h" |
| 12 | 12 |
| 13 namespace device { | 13 namespace device { |
| 14 | 14 |
| 15 class DataSinkReceiver; | 15 class DataSinkReceiver; |
| 16 class DataSourceSender; | 16 class DataSourceSender; |
| 17 class ReadOnlyBuffer; | 17 class ReadOnlyBuffer; |
| 18 class SerialIoHandler; | 18 class SerialIoHandler; |
| 19 class WritableBuffer; | 19 class WritableBuffer; |
| 20 | 20 |
| 21 class SerialConnection : public mojo::InterfaceImpl<serial::Connection> { | 21 class SerialConnection : public mojo::InterfaceImpl<serial::Connection> { |
| 22 public: | 22 public: |
| 23 SerialConnection(scoped_refptr<SerialIoHandler> io_handler, | 23 SerialConnection(scoped_refptr<SerialIoHandler> io_handler, |
| 24 mojo::InterfaceRequest<serial::DataSink> sink, | 24 mojo::InterfaceRequest<serial::DataSink> sink, |
| 25 mojo::InterfacePtr<serial::DataSinkClient> sink_client, | 25 mojo::InterfaceRequest<serial::DataSource> source); |
| 26 mojo::InterfaceRequest<serial::DataSource> source, | |
| 27 mojo::InterfacePtr<serial::DataSourceClient> source_client); | |
| 28 ~SerialConnection() override; | 26 ~SerialConnection() override; |
| 29 | 27 |
| 30 // mojo::InterfaceImpl<serial::Connection> overrides. | 28 // mojo::InterfaceImpl<serial::Connection> overrides. |
| 31 void GetInfo( | 29 void GetInfo( |
| 32 const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback) override; | 30 const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback) override; |
| 33 void SetOptions(serial::ConnectionOptionsPtr options, | 31 void SetOptions(serial::ConnectionOptionsPtr options, |
| 34 const mojo::Callback<void(bool)>& callback) override; | 32 const mojo::Callback<void(bool)>& callback) override; |
| 35 void SetControlSignals(serial::HostControlSignalsPtr signals, | 33 void SetControlSignals(serial::HostControlSignalsPtr signals, |
| 36 const mojo::Callback<void(bool)>& callback) override; | 34 const mojo::Callback<void(bool)>& callback) override; |
| 37 void GetControlSignals( | 35 void GetControlSignals( |
| 38 const mojo::Callback<void(serial::DeviceControlSignalsPtr)>& callback) | 36 const mojo::Callback<void(serial::DeviceControlSignalsPtr)>& callback) |
| 39 override; | 37 override; |
| 40 void Flush(const mojo::Callback<void(bool)>& callback) override; | 38 void Flush(const mojo::Callback<void(bool)>& callback) override; |
| 41 | 39 |
| 42 private: | 40 private: |
| 43 void OnSendPipeReady(scoped_ptr<ReadOnlyBuffer> buffer); | 41 void OnSendPipeReady(scoped_ptr<ReadOnlyBuffer> buffer); |
| 44 void OnSendCancelled(int32_t error); | 42 void OnSendCancelled(int32_t error); |
| 45 void OnReceivePipeReady(scoped_ptr<WritableBuffer> buffer); | 43 void OnReceivePipeReady(scoped_ptr<WritableBuffer> buffer); |
| 46 | 44 |
| 47 scoped_refptr<SerialIoHandler> io_handler_; | 45 scoped_refptr<SerialIoHandler> io_handler_; |
| 48 scoped_refptr<DataSinkReceiver> receiver_; | 46 scoped_refptr<DataSinkReceiver> receiver_; |
| 49 scoped_refptr<DataSourceSender> sender_; | 47 scoped_refptr<DataSourceSender> sender_; |
| 50 | 48 |
| 51 DISALLOW_COPY_AND_ASSIGN(SerialConnection); | 49 DISALLOW_COPY_AND_ASSIGN(SerialConnection); |
| 52 }; | 50 }; |
| 53 | 51 |
| 54 } // namespace device | 52 } // namespace device |
| 55 | 53 |
| 56 #endif // DEVICE_SERIAL_SERIAL_CONNECTION_H_ | 54 #endif // DEVICE_SERIAL_SERIAL_CONNECTION_H_ |
| OLD | NEW |