OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |