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