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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « device/serial/serial_service_impl.h ('k') | device/serial/serial_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_service_impl.h"
6
7 #include "base/bind.h"
8 #include "base/location.h"
9
10 namespace device {
11
12 SerialServiceImpl::SerialServiceImpl() {
13 }
14
15 SerialServiceImpl::~SerialServiceImpl() {
16 }
17
18 // static
19 void SerialServiceImpl::Create(
20 mojo::InterfaceRequest<serial::SerialService> request) {
21 mojo::BindToRequest(new SerialServiceImpl(), &request);
22 }
23
24 // static
25 void SerialServiceImpl::CreateOnMessageLoop(
26 scoped_refptr<base::MessageLoopProxy> message_loop,
27 mojo::InterfaceRequest<serial::SerialService> request) {
28 message_loop->PostTask(
29 FROM_HERE,
30 base::Bind(&SerialServiceImpl::Create, base::Passed(&request)));
31 }
32
33 void SerialServiceImpl::GetDevices(
34 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) {
35 if (!device_enumerator_)
36 device_enumerator_ = SerialDeviceEnumerator::Create();
37 callback.Run(device_enumerator_->GetDevices());
38 }
39
40 void SerialServiceImpl::OnConnectionError() {
41 delete this;
42 }
43
44 } // namespace device
OLDNEW
« 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