OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "device/serial/serial_connection.h" |
| 6 |
| 7 #include "device/serial/serial_io_handler.h" |
| 8 |
| 9 namespace device { |
| 10 |
| 11 SerialConnection::SerialConnection(scoped_refptr<SerialIoHandler> io_handler) |
| 12 : io_handler_(io_handler) { |
| 13 // TODO(sammc): Call io_handler_->Initialize() once we support send and recv. |
| 14 } |
| 15 |
| 16 SerialConnection::~SerialConnection() { |
| 17 } |
| 18 |
| 19 void SerialConnection::GetInfo( |
| 20 const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback) { |
| 21 callback.Run(io_handler_->GetPortInfo()); |
| 22 } |
| 23 |
| 24 void SerialConnection::SetOptions(serial::ConnectionOptionsPtr options, |
| 25 const mojo::Callback<void(bool)>& callback) { |
| 26 callback.Run(io_handler_->ConfigurePort(*options)); |
| 27 io_handler_->CancelRead(device::serial::RECEIVE_ERROR_NONE); |
| 28 } |
| 29 |
| 30 void SerialConnection::SetControlSignals( |
| 31 serial::HostControlSignalsPtr signals, |
| 32 const mojo::Callback<void(bool)>& callback) { |
| 33 callback.Run(io_handler_->SetControlSignals(*signals)); |
| 34 } |
| 35 |
| 36 void SerialConnection::GetControlSignals( |
| 37 const mojo::Callback<void(serial::DeviceControlSignalsPtr)>& callback) { |
| 38 callback.Run(io_handler_->GetControlSignals()); |
| 39 } |
| 40 |
| 41 void SerialConnection::Flush(const mojo::Callback<void(bool)>& callback) { |
| 42 callback.Run(io_handler_->Flush()); |
| 43 } |
| 44 |
| 45 void SerialConnection::OnConnectionError() { |
| 46 delete this; |
| 47 } |
| 48 |
| 49 } // namespace device |
OLD | NEW |