blob: 796a1d42ea52568fa3328f2283a2f4b45e94865b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_
#define DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
#include "device/serial/data_stream.mojom.h"
#include "device/serial/serial.mojom.h"
#include "device/serial/serial_connection_factory.h"
#include "device/serial/serial_device_enumerator.h"
#include "mojo/public/cpp/bindings/interface_impl.h"
namespace device {
class SerialServiceImpl : public mojo::InterfaceImpl<serial::SerialService> {
public:
explicit SerialServiceImpl(
scoped_refptr<SerialConnectionFactory> connection_factory);
SerialServiceImpl(scoped_refptr<SerialConnectionFactory> connection_factory,
scoped_ptr<SerialDeviceEnumerator> device_enumerator);
virtual ~SerialServiceImpl();
static void Create(scoped_refptr<base::MessageLoopProxy> io_message_loop,
scoped_refptr<base::MessageLoopProxy> ui_message_loop,
mojo::InterfaceRequest<serial::SerialService> request);
static void CreateOnMessageLoop(
scoped_refptr<base::MessageLoopProxy> message_loop,
scoped_refptr<base::MessageLoopProxy> io_message_loop,
scoped_refptr<base::MessageLoopProxy> ui_message_loop,
mojo::InterfaceRequest<serial::SerialService> request);
// mojo::InterfaceImpl<SerialService> overrides.
virtual void GetDevices(const mojo::Callback<
void(mojo::Array<serial::DeviceInfoPtr>)>& callback) override;
virtual void Connect(
const mojo::String& path,
serial::ConnectionOptionsPtr options,
mojo::InterfaceRequest<serial::Connection> connection_request,
mojo::InterfaceRequest<serial::DataSink> sink,
mojo::InterfaceRequest<serial::DataSource> source) override;
private:
SerialDeviceEnumerator* GetDeviceEnumerator();
bool IsValidPath(const mojo::String& path);
scoped_ptr<SerialDeviceEnumerator> device_enumerator_;
scoped_refptr<SerialConnectionFactory> connection_factory_;
DISALLOW_COPY_AND_ASSIGN(SerialServiceImpl);
};
} // namespace device
#endif // DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_
|