Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / device / serial / serial_service_impl.h
blob09f2fd08c0683d3c7ba5ff2dddc4d693f1858ac0
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.
5 #ifndef DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_
6 #define DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h"
11 #include "device/serial/data_stream.mojom.h"
12 #include "device/serial/serial.mojom.h"
13 #include "device/serial/serial_connection_factory.h"
14 #include "device/serial/serial_device_enumerator.h"
15 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
17 namespace device {
19 class SerialServiceImpl : public serial::SerialService {
20 public:
21 SerialServiceImpl(scoped_refptr<SerialConnectionFactory> connection_factory,
22 mojo::InterfaceRequest<serial::SerialService> request);
23 SerialServiceImpl(scoped_refptr<SerialConnectionFactory> connection_factory,
24 scoped_ptr<SerialDeviceEnumerator> device_enumerator,
25 mojo::InterfaceRequest<serial::SerialService> request);
26 ~SerialServiceImpl() override;
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);
37 // SerialService overrides.
38 void GetDevices(
39 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback)
40 override;
41 void Connect(
42 const mojo::String& path,
43 serial::ConnectionOptionsPtr options,
44 mojo::InterfaceRequest<serial::Connection> connection_request,
45 mojo::InterfaceRequest<serial::DataSink> sink,
46 mojo::InterfaceRequest<serial::DataSource> source,
47 mojo::InterfacePtr<serial::DataSourceClient> source_client) override;
49 private:
50 SerialDeviceEnumerator* GetDeviceEnumerator();
51 bool IsValidPath(const mojo::String& path);
53 scoped_ptr<SerialDeviceEnumerator> device_enumerator_;
54 scoped_refptr<SerialConnectionFactory> connection_factory_;
55 mojo::StrongBinding<serial::SerialService> binding_;
57 DISALLOW_COPY_AND_ASSIGN(SerialServiceImpl);
60 } // namespace device
62 #endif // DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_