Improved the state machine in GuestView.
[chromium-blink-merge.git] / device / serial / serial_connection_factory.h
blob13b055cfe401863c77b2e42e203632cf826d1c20
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_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop/message_loop_proxy.h"
13 #include "device/serial/data_stream.mojom.h"
14 #include "device/serial/serial.mojom.h"
15 #include "mojo/public/cpp/bindings/interface_request.h"
17 namespace device {
19 class SerialIoHandler;
21 class SerialConnectionFactory
22 : public base::RefCountedThreadSafe<SerialConnectionFactory> {
23 public:
24 typedef base::Callback<scoped_refptr<SerialIoHandler>()> IoHandlerFactory;
26 SerialConnectionFactory(
27 const IoHandlerFactory& io_handler_factory,
28 scoped_refptr<base::MessageLoopProxy> connect_message_loop);
30 void CreateConnection(
31 const std::string& path,
32 serial::ConnectionOptionsPtr options,
33 mojo::InterfaceRequest<serial::Connection> connection_request,
34 mojo::InterfaceRequest<serial::DataSink> sink,
35 mojo::InterfaceRequest<serial::DataSource> source);
37 private:
38 friend class base::RefCountedThreadSafe<SerialConnectionFactory>;
39 class ConnectTask;
41 virtual ~SerialConnectionFactory();
43 const IoHandlerFactory io_handler_factory_;
44 scoped_refptr<base::MessageLoopProxy> connect_message_loop_;
46 DISALLOW_COPY_AND_ASSIGN(SerialConnectionFactory);
49 } // namespace device
51 #endif // DEVICE_SERIAL_SERIAL_CONNECTION_FACTORY_H_