Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / device / serial / serial_service_impl.h
blob9ac5a10a32d91bbfa6c60df835fc83478f4cd9e9
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/interface_impl.h"
17 namespace device {
19 class SerialServiceImpl : public mojo::InterfaceImpl<serial::SerialService> {
20 public:
21 explicit SerialServiceImpl(
22 scoped_refptr<SerialConnectionFactory> connection_factory);
23 SerialServiceImpl(scoped_refptr<SerialConnectionFactory> connection_factory,
24 scoped_ptr<SerialDeviceEnumerator> device_enumerator);
25 ~SerialServiceImpl() override;
27 static void Create(scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
28 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
29 mojo::InterfaceRequest<serial::SerialService> request);
30 static void CreateOnMessageLoop(
31 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
32 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
33 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
34 mojo::InterfaceRequest<serial::SerialService> request);
36 // mojo::InterfaceImpl<SerialService> overrides.
37 void GetDevices(
38 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback)
39 override;
40 void Connect(
41 const mojo::String& path,
42 serial::ConnectionOptionsPtr options,
43 mojo::InterfaceRequest<serial::Connection> connection_request,
44 mojo::InterfaceRequest<serial::DataSink> sink,
45 mojo::InterfaceRequest<serial::DataSource> source,
46 mojo::InterfacePtr<serial::DataSourceClient> source_client) override;
48 private:
49 SerialDeviceEnumerator* GetDeviceEnumerator();
50 bool IsValidPath(const mojo::String& path);
52 scoped_ptr<SerialDeviceEnumerator> device_enumerator_;
53 scoped_refptr<SerialConnectionFactory> connection_factory_;
55 DISALLOW_COPY_AND_ASSIGN(SerialServiceImpl);
58 } // namespace device
60 #endif // DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_