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

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

Issue 646053002: Implement permission_broker for serial devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix device_unittests. Created 6 years, 2 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
« 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
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_service_impl.h" 5 #include "device/serial/serial_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "device/serial/serial_io_handler.h" 9 #include "device/serial/serial_io_handler.h"
10 10
(...skipping 10 matching lines...) Expand all
21 : device_enumerator_(device_enumerator.Pass()), 21 : device_enumerator_(device_enumerator.Pass()),
22 connection_factory_(connection_factory) { 22 connection_factory_(connection_factory) {
23 } 23 }
24 24
25 SerialServiceImpl::~SerialServiceImpl() { 25 SerialServiceImpl::~SerialServiceImpl() {
26 } 26 }
27 27
28 // static 28 // static
29 void SerialServiceImpl::Create( 29 void SerialServiceImpl::Create(
30 scoped_refptr<base::MessageLoopProxy> io_message_loop, 30 scoped_refptr<base::MessageLoopProxy> io_message_loop,
31 scoped_refptr<base::MessageLoopProxy> ui_message_loop,
31 mojo::InterfaceRequest<serial::SerialService> request) { 32 mojo::InterfaceRequest<serial::SerialService> request) {
32 mojo::BindToRequest(new SerialServiceImpl(new SerialConnectionFactory( 33 mojo::BindToRequest(new SerialServiceImpl(new SerialConnectionFactory(
33 base::Bind(SerialIoHandler::Create, 34 base::Bind(SerialIoHandler::Create,
34 base::MessageLoopProxy::current()), 35 base::MessageLoopProxy::current(),
36 ui_message_loop),
35 io_message_loop)), 37 io_message_loop)),
36 &request); 38 &request);
37 } 39 }
38 40
39 // static 41 // static
40 void SerialServiceImpl::CreateOnMessageLoop( 42 void SerialServiceImpl::CreateOnMessageLoop(
41 scoped_refptr<base::MessageLoopProxy> message_loop, 43 scoped_refptr<base::MessageLoopProxy> message_loop,
42 scoped_refptr<base::MessageLoopProxy> io_message_loop, 44 scoped_refptr<base::MessageLoopProxy> io_message_loop,
45 scoped_refptr<base::MessageLoopProxy> ui_message_loop,
43 mojo::InterfaceRequest<serial::SerialService> request) { 46 mojo::InterfaceRequest<serial::SerialService> request) {
44 message_loop->PostTask( 47 message_loop->PostTask(FROM_HERE,
45 FROM_HERE, 48 base::Bind(&SerialServiceImpl::Create,
46 base::Bind( 49 io_message_loop,
47 &SerialServiceImpl::Create, io_message_loop, base::Passed(&request))); 50 ui_message_loop,
51 base::Passed(&request)));
48 } 52 }
49 53
50 void SerialServiceImpl::GetDevices( 54 void SerialServiceImpl::GetDevices(
51 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) { 55 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) {
52 callback.Run(GetDeviceEnumerator()->GetDevices()); 56 callback.Run(GetDeviceEnumerator()->GetDevices());
53 } 57 }
54 58
55 void SerialServiceImpl::Connect( 59 void SerialServiceImpl::Connect(
56 const mojo::String& path, 60 const mojo::String& path,
57 serial::ConnectionOptionsPtr options, 61 serial::ConnectionOptionsPtr options,
(...skipping 19 matching lines...) Expand all
77 mojo::Array<serial::DeviceInfoPtr> devices( 81 mojo::Array<serial::DeviceInfoPtr> devices(
78 GetDeviceEnumerator()->GetDevices()); 82 GetDeviceEnumerator()->GetDevices());
79 for (size_t i = 0; i < devices.size(); i++) { 83 for (size_t i = 0; i < devices.size(); i++) {
80 if (path == devices[i]->path) 84 if (path == devices[i]->path)
81 return true; 85 return true;
82 } 86 }
83 return false; 87 return false;
84 } 88 }
85 89
86 } // namespace device 90 } // 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