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/message_loop/message_loop_proxy.h"
10 #include "device/serial/data_stream.mojom.h"
11 #include "device/serial/serial.mojom.h"
12 #include "device/serial/serial_connection_factory.h"
13 #include "device/serial/serial_device_enumerator.h"
14 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
18 class SerialServiceImpl
: public mojo::InterfaceImpl
<serial::SerialService
> {
20 explicit SerialServiceImpl(
21 scoped_refptr
<SerialConnectionFactory
> connection_factory
);
22 SerialServiceImpl(scoped_refptr
<SerialConnectionFactory
> connection_factory
,
23 scoped_ptr
<SerialDeviceEnumerator
> device_enumerator
);
24 ~SerialServiceImpl() override
;
26 static void Create(scoped_refptr
<base::MessageLoopProxy
> io_message_loop
,
27 scoped_refptr
<base::MessageLoopProxy
> ui_message_loop
,
28 mojo::InterfaceRequest
<serial::SerialService
> request
);
29 static void CreateOnMessageLoop(
30 scoped_refptr
<base::MessageLoopProxy
> message_loop
,
31 scoped_refptr
<base::MessageLoopProxy
> io_message_loop
,
32 scoped_refptr
<base::MessageLoopProxy
> ui_message_loop
,
33 mojo::InterfaceRequest
<serial::SerialService
> request
);
35 // mojo::InterfaceImpl<SerialService> overrides.
37 const mojo::Callback
<void(mojo::Array
<serial::DeviceInfoPtr
>)>& callback
)
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
;
48 SerialDeviceEnumerator
* GetDeviceEnumerator();
49 bool IsValidPath(const mojo::String
& path
);
51 scoped_ptr
<SerialDeviceEnumerator
> device_enumerator_
;
52 scoped_refptr
<SerialConnectionFactory
> connection_factory_
;
54 DISALLOW_COPY_AND_ASSIGN(SerialServiceImpl
);
59 #endif // DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_