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

Unified 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: address comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/serial/serial_connection.h ('k') | device/serial/serial_connection_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/serial/serial_connection.cc
diff --git a/device/serial/serial_connection.cc b/device/serial/serial_connection.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0845b88189ce37de01e71229723ce0afa7d5f8e0
--- /dev/null
+++ b/device/serial/serial_connection.cc
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "device/serial/serial_connection.h"
+
+#include "device/serial/serial_io_handler.h"
+
+namespace device {
+
+SerialConnection::SerialConnection(scoped_refptr<SerialIoHandler> io_handler)
+ : io_handler_(io_handler) {
+ // TODO(sammc): Call io_handler_->Initialize() once we support send and recv.
+}
+
+SerialConnection::~SerialConnection() {
+}
+
+void SerialConnection::GetInfo(
+ const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback) {
+ callback.Run(io_handler_->GetPortInfo());
+}
+
+void SerialConnection::SetOptions(serial::ConnectionOptionsPtr options,
+ const mojo::Callback<void(bool)>& callback) {
+ callback.Run(io_handler_->ConfigurePort(*options));
+ io_handler_->CancelRead(device::serial::RECEIVE_ERROR_NONE);
+}
+
+void SerialConnection::SetControlSignals(
+ serial::HostControlSignalsPtr signals,
+ const mojo::Callback<void(bool)>& callback) {
+ callback.Run(io_handler_->SetControlSignals(*signals));
+}
+
+void SerialConnection::GetControlSignals(
+ const mojo::Callback<void(serial::DeviceControlSignalsPtr)>& callback) {
+ callback.Run(io_handler_->GetControlSignals());
+}
+
+void SerialConnection::Flush(const mojo::Callback<void(bool)>& callback) {
+ callback.Run(io_handler_->Flush());
+}
+
+void SerialConnection::OnConnectionError() {
+ delete this;
+}
+
+} // namespace device
« no previous file with comments | « device/serial/serial_connection.h ('k') | device/serial/serial_connection_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698