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_CONNECTION_FACTORY_H_
6 #define DEVICE_SERIAL_SERIAL_CONNECTION_FACTORY_H_
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h"
14 #include "device/serial/data_stream.mojom.h"
15 #include "device/serial/serial.mojom.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
20 class SerialIoHandler
;
22 class SerialConnectionFactory
23 : public base::RefCountedThreadSafe
<SerialConnectionFactory
> {
25 typedef base::Callback
<scoped_refptr
<SerialIoHandler
>()> IoHandlerFactory
;
27 SerialConnectionFactory(
28 const IoHandlerFactory
& io_handler_factory
,
29 scoped_refptr
<base::SingleThreadTaskRunner
> connect_task_runner
);
31 void CreateConnection(
32 const std::string
& path
,
33 serial::ConnectionOptionsPtr options
,
34 mojo::InterfaceRequest
<serial::Connection
> connection_request
,
35 mojo::InterfaceRequest
<serial::DataSink
> sink
,
36 mojo::InterfaceRequest
<serial::DataSource
> source
,
37 mojo::InterfacePtr
<serial::DataSourceClient
> source_client
);
40 friend class base::RefCountedThreadSafe
<SerialConnectionFactory
>;
43 virtual ~SerialConnectionFactory();
45 const IoHandlerFactory io_handler_factory_
;
46 scoped_refptr
<base::SingleThreadTaskRunner
> connect_task_runner_
;
48 DISALLOW_COPY_AND_ASSIGN(SerialConnectionFactory
);
53 #endif // DEVICE_SERIAL_SERIAL_CONNECTION_FACTORY_H_