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