Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: device/serial/serial_service_impl.h

Issue 401563002: Add a partial Mojo serial connection interface and implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/serial/serial_io_handler_win.cc ('k') | device/serial/serial_service_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_ 5 #ifndef DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_
6 #define DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_ 6 #define DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "device/serial/serial.mojom.h" 10 #include "device/serial/serial.mojom.h"
11 #include "device/serial/serial_connection_factory.h"
11 #include "device/serial/serial_device_enumerator.h" 12 #include "device/serial/serial_device_enumerator.h"
12 #include "mojo/public/cpp/bindings/interface_impl.h" 13 #include "mojo/public/cpp/bindings/interface_impl.h"
13 14
14 namespace device { 15 namespace device {
15 16
16 class SerialServiceImpl : public mojo::InterfaceImpl<serial::SerialService> { 17 class SerialServiceImpl : public mojo::InterfaceImpl<serial::SerialService> {
17 public: 18 public:
18 SerialServiceImpl(); 19 explicit SerialServiceImpl(
20 scoped_refptr<SerialConnectionFactory> connection_factory);
21 SerialServiceImpl(scoped_refptr<SerialConnectionFactory> connection_factory,
22 scoped_ptr<SerialDeviceEnumerator> device_enumerator);
19 virtual ~SerialServiceImpl(); 23 virtual ~SerialServiceImpl();
20 24
21 static void Create(mojo::InterfaceRequest<serial::SerialService> request); 25 static void Create(scoped_refptr<base::MessageLoopProxy> io_message_loop,
26 mojo::InterfaceRequest<serial::SerialService> request);
22 static void CreateOnMessageLoop( 27 static void CreateOnMessageLoop(
23 scoped_refptr<base::MessageLoopProxy> message_loop, 28 scoped_refptr<base::MessageLoopProxy> message_loop,
29 scoped_refptr<base::MessageLoopProxy> io_message_loop,
24 mojo::InterfaceRequest<serial::SerialService> request); 30 mojo::InterfaceRequest<serial::SerialService> request);
25 31
26 // mojo::InterfaceImpl<SerialService> overrides. 32 // mojo::InterfaceImpl<SerialService> overrides.
27 virtual void GetDevices(const mojo::Callback< 33 virtual void GetDevices(const mojo::Callback<
28 void(mojo::Array<serial::DeviceInfoPtr>)>& callback) OVERRIDE; 34 void(mojo::Array<serial::DeviceInfoPtr>)>& callback) OVERRIDE;
35 virtual void Connect(
36 const mojo::String& path,
37 serial::ConnectionOptionsPtr options,
38 mojo::InterfaceRequest<serial::Connection> connection_request) OVERRIDE;
29 virtual void OnConnectionError() OVERRIDE; 39 virtual void OnConnectionError() OVERRIDE;
30 40
31 private: 41 private:
42 SerialDeviceEnumerator* GetDeviceEnumerator();
43 bool IsValidPath(const mojo::String& path);
44 void OnConnected(
45 const mojo::Callback<void(serial::ConnectionInfoPtr)>& callback,
46 serial::ConnectionInfoPtr result);
47
32 scoped_ptr<SerialDeviceEnumerator> device_enumerator_; 48 scoped_ptr<SerialDeviceEnumerator> device_enumerator_;
49 scoped_refptr<SerialConnectionFactory> connection_factory_;
50
51 DISALLOW_COPY_AND_ASSIGN(SerialServiceImpl);
33 }; 52 };
34 53
35 } // namespace device 54 } // namespace device
36 55
37 #endif // DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_ 56 #endif // DEVICE_SERIAL_SERIAL_SERVICE_IMPL_H_
OLDNEW
« no previous file with comments | « device/serial/serial_io_handler_win.cc ('k') | device/serial/serial_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698