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