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 #ifndef DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_ | 5 #ifndef DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_ |
6 #define DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_ | 6 #define DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" |
10 #include "device/serial/data_stream.mojom.h" | 11 #include "device/serial/data_stream.mojom.h" |
11 #include "device/serial/serial.mojom.h" | 12 #include "device/serial/serial.mojom.h" |
12 #include "device/serial/serial_connection_factory.h" | 13 #include "device/serial/serial_connection_factory.h" |
13 #include "device/serial/serial_device_enumerator.h" | 14 #include "device/serial/serial_device_enumerator.h" |
14 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h" | 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h" |
15 | 16 |
16 namespace device { | 17 namespace device { |
17 | 18 |
18 class SerialServiceImpl : public mojo::InterfaceImpl<serial::SerialService> { | 19 class SerialServiceImpl : public mojo::InterfaceImpl<serial::SerialService> { |
19 public: | 20 public: |
20 explicit SerialServiceImpl( | 21 explicit SerialServiceImpl( |
21 scoped_refptr<SerialConnectionFactory> connection_factory); | 22 scoped_refptr<SerialConnectionFactory> connection_factory); |
22 SerialServiceImpl(scoped_refptr<SerialConnectionFactory> connection_factory, | 23 SerialServiceImpl(scoped_refptr<SerialConnectionFactory> connection_factory, |
23 scoped_ptr<SerialDeviceEnumerator> device_enumerator); | 24 scoped_ptr<SerialDeviceEnumerator> device_enumerator); |
24 ~SerialServiceImpl() override; | 25 ~SerialServiceImpl() override; |
25 | 26 |
26 static void Create(scoped_refptr<base::MessageLoopProxy> io_message_loop, | 27 static void Create(scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
27 scoped_refptr<base::MessageLoopProxy> ui_message_loop, | 28 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
28 mojo::InterfaceRequest<serial::SerialService> request); | 29 mojo::InterfaceRequest<serial::SerialService> request); |
29 static void CreateOnMessageLoop( | 30 static void CreateOnMessageLoop( |
30 scoped_refptr<base::MessageLoopProxy> message_loop, | 31 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
31 scoped_refptr<base::MessageLoopProxy> io_message_loop, | 32 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
32 scoped_refptr<base::MessageLoopProxy> ui_message_loop, | 33 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
33 mojo::InterfaceRequest<serial::SerialService> request); | 34 mojo::InterfaceRequest<serial::SerialService> request); |
34 | 35 |
35 // mojo::InterfaceImpl<SerialService> overrides. | 36 // mojo::InterfaceImpl<SerialService> overrides. |
36 void GetDevices( | 37 void GetDevices( |
37 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) | 38 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) |
38 override; | 39 override; |
39 void Connect( | 40 void Connect( |
40 const mojo::String& path, | 41 const mojo::String& path, |
41 serial::ConnectionOptionsPtr options, | 42 serial::ConnectionOptionsPtr options, |
42 mojo::InterfaceRequest<serial::Connection> connection_request, | 43 mojo::InterfaceRequest<serial::Connection> connection_request, |
43 mojo::InterfaceRequest<serial::DataSink> sink, | 44 mojo::InterfaceRequest<serial::DataSink> sink, |
44 mojo::InterfaceRequest<serial::DataSource> source, | 45 mojo::InterfaceRequest<serial::DataSource> source, |
45 mojo::InterfacePtr<serial::DataSourceClient> source_client) override; | 46 mojo::InterfacePtr<serial::DataSourceClient> source_client) override; |
46 | 47 |
47 private: | 48 private: |
48 SerialDeviceEnumerator* GetDeviceEnumerator(); | 49 SerialDeviceEnumerator* GetDeviceEnumerator(); |
49 bool IsValidPath(const mojo::String& path); | 50 bool IsValidPath(const mojo::String& path); |
50 | 51 |
51 scoped_ptr<SerialDeviceEnumerator> device_enumerator_; | 52 scoped_ptr<SerialDeviceEnumerator> device_enumerator_; |
52 scoped_refptr<SerialConnectionFactory> connection_factory_; | 53 scoped_refptr<SerialConnectionFactory> connection_factory_; |
53 | 54 |
54 DISALLOW_COPY_AND_ASSIGN(SerialServiceImpl); | 55 DISALLOW_COPY_AND_ASSIGN(SerialServiceImpl); |
55 }; | 56 }; |
56 | 57 |
57 } // namespace device | 58 } // namespace device |
58 | 59 |
59 #endif // DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_ | 60 #endif // DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_ |
OLD | NEW |