Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: device/serial/serial_connection.cc

Issue 401563002: Add a partial Mojo serial connection interface and implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698