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 17 matching lines...) Expand all Loading... |
28 base::Bind(base::DoNothing)); | 28 base::Bind(base::DoNothing)); |
29 sender_ = new DataSourceSender( | 29 sender_ = new DataSourceSender( |
30 std::move(source), std::move(source_client), | 30 std::move(source), std::move(source_client), |
31 base::Bind(&SerialConnection::OnReceivePipeReady, base::Unretained(this)), | 31 base::Bind(&SerialConnection::OnReceivePipeReady, base::Unretained(this)), |
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::RECEIVE_ERROR_DISCONNECTED); | 38 io_handler_->CancelRead(serial::ReceiveError::DISCONNECTED); |
39 io_handler_->CancelWrite(serial::SEND_ERROR_DISCONNECTED); | 39 io_handler_->CancelWrite(serial::SendError::DISCONNECTED); |
40 } | 40 } |
41 | 41 |
42 void SerialConnection::GetInfo( | 42 void SerialConnection::GetInfo( |
43 const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback) { | 43 const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback) { |
44 callback.Run(io_handler_->GetPortInfo()); | 44 callback.Run(io_handler_->GetPortInfo()); |
45 } | 45 } |
46 | 46 |
47 void SerialConnection::SetOptions(serial::ConnectionOptionsPtr options, | 47 void SerialConnection::SetOptions(serial::ConnectionOptionsPtr options, |
48 const mojo::Callback<void(bool)>& callback) { | 48 const mojo::Callback<void(bool)>& callback) { |
49 callback.Run(io_handler_->ConfigurePort(*options)); | 49 callback.Run(io_handler_->ConfigurePort(*options)); |
50 io_handler_->CancelRead(device::serial::RECEIVE_ERROR_NONE); | 50 io_handler_->CancelRead(device::serial::ReceiveError::NONE); |
51 } | 51 } |
52 | 52 |
53 void SerialConnection::SetControlSignals( | 53 void SerialConnection::SetControlSignals( |
54 serial::HostControlSignalsPtr signals, | 54 serial::HostControlSignalsPtr signals, |
55 const mojo::Callback<void(bool)>& callback) { | 55 const mojo::Callback<void(bool)>& callback) { |
56 callback.Run(io_handler_->SetControlSignals(*signals)); | 56 callback.Run(io_handler_->SetControlSignals(*signals)); |
57 } | 57 } |
58 | 58 |
59 void SerialConnection::GetControlSignals( | 59 void SerialConnection::GetControlSignals( |
60 const mojo::Callback<void(serial::DeviceControlSignalsPtr)>& callback) { | 60 const mojo::Callback<void(serial::DeviceControlSignalsPtr)>& callback) { |
(...skipping 10 matching lines...) Expand all Loading... |
71 | 71 |
72 void SerialConnection::OnSendPipeReady(scoped_ptr<ReadOnlyBuffer> buffer) { | 72 void SerialConnection::OnSendPipeReady(scoped_ptr<ReadOnlyBuffer> buffer) { |
73 io_handler_->Write(std::move(buffer)); | 73 io_handler_->Write(std::move(buffer)); |
74 } | 74 } |
75 | 75 |
76 void SerialConnection::OnReceivePipeReady(scoped_ptr<WritableBuffer> buffer) { | 76 void SerialConnection::OnReceivePipeReady(scoped_ptr<WritableBuffer> buffer) { |
77 io_handler_->Read(std::move(buffer)); | 77 io_handler_->Read(std::move(buffer)); |
78 } | 78 } |
79 | 79 |
80 } // namespace device | 80 } // namespace device |
OLD | NEW |