| 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(const GetInfoCallback& callback) { | 42 void SerialConnection::GetInfo( |
| 43 const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback) { |
| 43 callback.Run(io_handler_->GetPortInfo()); | 44 callback.Run(io_handler_->GetPortInfo()); |
| 44 } | 45 } |
| 45 | 46 |
| 46 void SerialConnection::SetOptions(serial::ConnectionOptionsPtr options, | 47 void SerialConnection::SetOptions(serial::ConnectionOptionsPtr options, |
| 47 const SetOptionsCallback& callback) { | 48 const mojo::Callback<void(bool)>& callback) { |
| 48 callback.Run(io_handler_->ConfigurePort(*options)); | 49 callback.Run(io_handler_->ConfigurePort(*options)); |
| 49 io_handler_->CancelRead(device::serial::ReceiveError::NONE); | 50 io_handler_->CancelRead(device::serial::ReceiveError::NONE); |
| 50 } | 51 } |
| 51 | 52 |
| 52 void SerialConnection::SetControlSignals( | 53 void SerialConnection::SetControlSignals( |
| 53 serial::HostControlSignalsPtr signals, | 54 serial::HostControlSignalsPtr signals, |
| 54 const SetControlSignalsCallback& callback) { | 55 const mojo::Callback<void(bool)>& callback) { |
| 55 callback.Run(io_handler_->SetControlSignals(*signals)); | 56 callback.Run(io_handler_->SetControlSignals(*signals)); |
| 56 } | 57 } |
| 57 | 58 |
| 58 void SerialConnection::GetControlSignals( | 59 void SerialConnection::GetControlSignals( |
| 59 const GetControlSignalsCallback& callback) { | 60 const mojo::Callback<void(serial::DeviceControlSignalsPtr)>& callback) { |
| 60 callback.Run(io_handler_->GetControlSignals()); | 61 callback.Run(io_handler_->GetControlSignals()); |
| 61 } | 62 } |
| 62 | 63 |
| 63 void SerialConnection::Flush(const FlushCallback& callback) { | 64 void SerialConnection::Flush(const mojo::Callback<void(bool)>& callback) { |
| 64 callback.Run(io_handler_->Flush()); | 65 callback.Run(io_handler_->Flush()); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void SerialConnection::OnSendCancelled(int32_t error) { | 68 void SerialConnection::OnSendCancelled(int32_t error) { |
| 68 io_handler_->CancelWrite(static_cast<serial::SendError>(error)); | 69 io_handler_->CancelWrite(static_cast<serial::SendError>(error)); |
| 69 } | 70 } |
| 70 | 71 |
| 71 void SerialConnection::OnSendPipeReady(std::unique_ptr<ReadOnlyBuffer> buffer) { | 72 void SerialConnection::OnSendPipeReady(std::unique_ptr<ReadOnlyBuffer> buffer) { |
| 72 io_handler_->Write(std::move(buffer)); | 73 io_handler_->Write(std::move(buffer)); |
| 73 } | 74 } |
| 74 | 75 |
| 75 void SerialConnection::OnReceivePipeReady( | 76 void SerialConnection::OnReceivePipeReady( |
| 76 std::unique_ptr<WritableBuffer> buffer) { | 77 std::unique_ptr<WritableBuffer> buffer) { |
| 77 io_handler_->Read(std::move(buffer)); | 78 io_handler_->Read(std::move(buffer)); |
| 78 } | 79 } |
| 79 | 80 |
| 80 } // namespace device | 81 } // namespace device |
| OLD | NEW |