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

Unified Diff: device/serial/serial_service_impl.cc

Issue 363853003: Add a basic Mojo SerialService that implements GetDevices(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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_service_impl.h ('k') | device/serial/serial_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/serial/serial_service_impl.cc
diff --git a/device/serial/serial_service_impl.cc b/device/serial/serial_service_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1d83e23a6ad848177018e6c400e04f0c995b2af8
--- /dev/null
+++ b/device/serial/serial_service_impl.cc
@@ -0,0 +1,44 @@
+// 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_service_impl.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+
+namespace device {
+
+SerialServiceImpl::SerialServiceImpl() {
+}
+
+SerialServiceImpl::~SerialServiceImpl() {
+}
+
+// static
+void SerialServiceImpl::Create(
+ mojo::InterfaceRequest<serial::SerialService> request) {
+ mojo::BindToRequest(new SerialServiceImpl(), &request);
+}
+
+// static
+void SerialServiceImpl::CreateOnMessageLoop(
+ scoped_refptr<base::MessageLoopProxy> message_loop,
+ mojo::InterfaceRequest<serial::SerialService> request) {
+ message_loop->PostTask(
+ FROM_HERE,
+ base::Bind(&SerialServiceImpl::Create, base::Passed(&request)));
+}
+
+void SerialServiceImpl::GetDevices(
+ const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) {
+ if (!device_enumerator_)
+ device_enumerator_ = SerialDeviceEnumerator::Create();
+ callback.Run(device_enumerator_->GetDevices());
+}
+
+void SerialServiceImpl::OnConnectionError() {
+ delete this;
+}
+
+} // namespace device
« no previous file with comments | « device/serial/serial_service_impl.h ('k') | device/serial/serial_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698