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

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

Issue 1107013002: [device] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Review Comments : Removal of message_loop_proxy header file Created 5 years, 7 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
11 namespace device { 11 namespace device {
12 12
13 SerialServiceImpl::SerialServiceImpl( 13 SerialServiceImpl::SerialServiceImpl(
14 scoped_refptr<SerialConnectionFactory> connection_factory) 14 scoped_refptr<SerialConnectionFactory> connection_factory)
15 : connection_factory_(connection_factory) { 15 : connection_factory_(connection_factory) {
16 } 16 }
17 17
18 SerialServiceImpl::SerialServiceImpl( 18 SerialServiceImpl::SerialServiceImpl(
19 scoped_refptr<SerialConnectionFactory> connection_factory, 19 scoped_refptr<SerialConnectionFactory> connection_factory,
20 scoped_ptr<SerialDeviceEnumerator> device_enumerator) 20 scoped_ptr<SerialDeviceEnumerator> device_enumerator)
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::SingleThreadTaskRunner> io_task_runner,
31 scoped_refptr<base::MessageLoopProxy> ui_message_loop, 31 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
32 mojo::InterfaceRequest<serial::SerialService> request) { 32 mojo::InterfaceRequest<serial::SerialService> request) {
33 mojo::BindToRequest(new SerialServiceImpl(new SerialConnectionFactory( 33 mojo::BindToRequest(
34 base::Bind(SerialIoHandler::Create, 34 new SerialServiceImpl(new SerialConnectionFactory(
35 base::MessageLoopProxy::current(), 35 base::Bind(SerialIoHandler::Create,
36 ui_message_loop), 36 base::ThreadTaskRunnerHandle::Get(), ui_task_runner),
37 io_message_loop)), 37 io_task_runner)),
38 &request); 38 &request);
39 } 39 }
40 40
41 // static 41 // static
42 void SerialServiceImpl::CreateOnMessageLoop( 42 void SerialServiceImpl::CreateOnMessageLoop(
43 scoped_refptr<base::MessageLoopProxy> message_loop, 43 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
44 scoped_refptr<base::MessageLoopProxy> io_message_loop, 44 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
45 scoped_refptr<base::MessageLoopProxy> ui_message_loop, 45 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
46 mojo::InterfaceRequest<serial::SerialService> request) { 46 mojo::InterfaceRequest<serial::SerialService> request) {
47 message_loop->PostTask(FROM_HERE, 47 task_runner->PostTask(FROM_HERE,
48 base::Bind(&SerialServiceImpl::Create, 48 base::Bind(&SerialServiceImpl::Create, io_task_runner,
49 io_message_loop, 49 ui_task_runner, base::Passed(&request)));
50 ui_message_loop,
51 base::Passed(&request)));
52 } 50 }
53 51
54 void SerialServiceImpl::GetDevices( 52 void SerialServiceImpl::GetDevices(
55 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) { 53 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) {
56 callback.Run(GetDeviceEnumerator()->GetDevices()); 54 callback.Run(GetDeviceEnumerator()->GetDevices());
57 } 55 }
58 56
59 void SerialServiceImpl::Connect( 57 void SerialServiceImpl::Connect(
60 const mojo::String& path, 58 const mojo::String& path,
61 serial::ConnectionOptionsPtr options, 59 serial::ConnectionOptionsPtr options,
(...skipping 18 matching lines...) Expand all
80 mojo::Array<serial::DeviceInfoPtr> devices( 78 mojo::Array<serial::DeviceInfoPtr> devices(
81 GetDeviceEnumerator()->GetDevices()); 79 GetDeviceEnumerator()->GetDevices());
82 for (size_t i = 0; i < devices.size(); i++) { 80 for (size_t i = 0; i < devices.size(); i++) {
83 if (path == devices[i]->path) 81 if (path == devices[i]->path)
84 return true; 82 return true;
85 } 83 }
86 return false; 84 return false;
87 } 85 }
88 86
89 } // namespace device 87 } // 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