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

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: 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
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_message_loop,
31 scoped_refptr<base::MessageLoopProxy> ui_message_loop, 31 scoped_refptr<base::SingleThreadTaskRunner> ui_message_loop,
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_message_loop),
37 io_message_loop)), 37 io_message_loop)),
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> message_loop,
44 scoped_refptr<base::MessageLoopProxy> io_message_loop, 44 scoped_refptr<base::SingleThreadTaskRunner> io_message_loop,
45 scoped_refptr<base::MessageLoopProxy> ui_message_loop, 45 scoped_refptr<base::SingleThreadTaskRunner> ui_message_loop,
46 mojo::InterfaceRequest<serial::SerialService> request) { 46 mojo::InterfaceRequest<serial::SerialService> request) {
47 message_loop->PostTask(FROM_HERE, 47 message_loop->PostTask(FROM_HERE,
48 base::Bind(&SerialServiceImpl::Create, 48 base::Bind(&SerialServiceImpl::Create,
49 io_message_loop, 49 io_message_loop,
50 ui_message_loop, 50 ui_message_loop,
51 base::Passed(&request))); 51 base::Passed(&request)));
52 } 52 }
53 53
54 void SerialServiceImpl::GetDevices( 54 void SerialServiceImpl::GetDevices(
55 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) { 55 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) {
(...skipping 24 matching lines...) Expand all
80 mojo::Array<serial::DeviceInfoPtr> devices( 80 mojo::Array<serial::DeviceInfoPtr> devices(
81 GetDeviceEnumerator()->GetDevices()); 81 GetDeviceEnumerator()->GetDevices());
82 for (size_t i = 0; i < devices.size(); i++) { 82 for (size_t i = 0; i < devices.size(); i++) {
83 if (path == devices[i]->path) 83 if (path == devices[i]->path)
84 return true; 84 return true;
85 } 85 }
86 return false; 86 return false;
87 } 87 }
88 88
89 } // namespace device 89 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698