| 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 #include "device/serial/serial_connection.h" | 5 #include "device/serial/serial_connection.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "device/serial/buffer.h" | 10 #include "device/serial/buffer.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 base::Bind(base::DoNothing)); | 32 base::Bind(base::DoNothing)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 SerialConnection::~SerialConnection() { | 35 SerialConnection::~SerialConnection() { |
| 36 receiver_->ShutDown(); | 36 receiver_->ShutDown(); |
| 37 sender_->ShutDown(); | 37 sender_->ShutDown(); |
| 38 io_handler_->CancelRead(serial::ReceiveError::DISCONNECTED); | 38 io_handler_->CancelRead(serial::ReceiveError::DISCONNECTED); |
| 39 io_handler_->CancelWrite(serial::SendError::DISCONNECTED); | 39 io_handler_->CancelWrite(serial::SendError::DISCONNECTED); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void SerialConnection::GetInfo( | 42 void SerialConnection::GetInfo(const GetInfoCallback& callback) { |
| 43 const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback) { | |
| 44 callback.Run(io_handler_->GetPortInfo()); | 43 callback.Run(io_handler_->GetPortInfo()); |
| 45 } | 44 } |
| 46 | 45 |
| 47 void SerialConnection::SetOptions(serial::ConnectionOptionsPtr options, | 46 void SerialConnection::SetOptions(serial::ConnectionOptionsPtr options, |
| 48 const mojo::Callback<void(bool)>& callback) { | 47 const SetOptionsCallback& callback) { |
| 49 callback.Run(io_handler_->ConfigurePort(*options)); | 48 callback.Run(io_handler_->ConfigurePort(*options)); |
| 50 io_handler_->CancelRead(device::serial::ReceiveError::NONE); | 49 io_handler_->CancelRead(device::serial::ReceiveError::NONE); |
| 51 } | 50 } |
| 52 | 51 |
| 53 void SerialConnection::SetControlSignals( | 52 void SerialConnection::SetControlSignals( |
| 54 serial::HostControlSignalsPtr signals, | 53 serial::HostControlSignalsPtr signals, |
| 55 const mojo::Callback<void(bool)>& callback) { | 54 const SetControlSignalsCallback& callback) { |
| 56 callback.Run(io_handler_->SetControlSignals(*signals)); | 55 callback.Run(io_handler_->SetControlSignals(*signals)); |
| 57 } | 56 } |
| 58 | 57 |
| 59 void SerialConnection::GetControlSignals( | 58 void SerialConnection::GetControlSignals( |
| 60 const mojo::Callback<void(serial::DeviceControlSignalsPtr)>& callback) { | 59 const GetControlSignalsCallback& callback) { |
| 61 callback.Run(io_handler_->GetControlSignals()); | 60 callback.Run(io_handler_->GetControlSignals()); |
| 62 } | 61 } |
| 63 | 62 |
| 64 void SerialConnection::Flush(const mojo::Callback<void(bool)>& callback) { | 63 void SerialConnection::Flush(const FlushCallback& callback) { |
| 65 callback.Run(io_handler_->Flush()); | 64 callback.Run(io_handler_->Flush()); |
| 66 } | 65 } |
| 67 | 66 |
| 68 void SerialConnection::OnSendCancelled(int32_t error) { | 67 void SerialConnection::OnSendCancelled(int32_t error) { |
| 69 io_handler_->CancelWrite(static_cast<serial::SendError>(error)); | 68 io_handler_->CancelWrite(static_cast<serial::SendError>(error)); |
| 70 } | 69 } |
| 71 | 70 |
| 72 void SerialConnection::OnSendPipeReady(std::unique_ptr<ReadOnlyBuffer> buffer) { | 71 void SerialConnection::OnSendPipeReady(std::unique_ptr<ReadOnlyBuffer> buffer) { |
| 73 io_handler_->Write(std::move(buffer)); | 72 io_handler_->Write(std::move(buffer)); |
| 74 } | 73 } |
| 75 | 74 |
| 76 void SerialConnection::OnReceivePipeReady( | 75 void SerialConnection::OnReceivePipeReady( |
| 77 std::unique_ptr<WritableBuffer> buffer) { | 76 std::unique_ptr<WritableBuffer> buffer) { |
| 78 io_handler_->Read(std::move(buffer)); | 77 io_handler_->Read(std::move(buffer)); |
| 79 } | 78 } |
| 80 | 79 |
| 81 } // namespace device | 80 } // namespace device |
| OLD | NEW |