OLD | NEW |
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_IO_HANDLER_POSIX_H_ | 5 #ifndef DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ |
6 #define DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ | 6 #define DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" |
9 #include "device/serial/serial_io_handler.h" | 11 #include "device/serial/serial_io_handler.h" |
10 | 12 |
11 namespace device { | 13 namespace device { |
12 | 14 |
13 class SerialIoHandlerPosix : public SerialIoHandler, | 15 class SerialIoHandlerPosix : public SerialIoHandler, |
14 public base::MessageLoopForIO::Watcher { | 16 public base::MessageLoopForIO::Watcher { |
15 protected: | 17 protected: |
16 // SerialIoHandler impl. | 18 // SerialIoHandler impl. |
17 void ReadImpl() override; | 19 void ReadImpl() override; |
18 void WriteImpl() override; | 20 void WriteImpl() override; |
19 void CancelReadImpl() override; | 21 void CancelReadImpl() override; |
20 void CancelWriteImpl() override; | 22 void CancelWriteImpl() override; |
21 bool ConfigurePortImpl() override; | 23 bool ConfigurePortImpl() override; |
22 bool Flush() const override; | 24 bool Flush() const override; |
23 serial::DeviceControlSignalsPtr GetControlSignals() const override; | 25 serial::DeviceControlSignalsPtr GetControlSignals() const override; |
24 bool SetControlSignals( | 26 bool SetControlSignals( |
25 const serial::HostControlSignals& control_signals) override; | 27 const serial::HostControlSignals& control_signals) override; |
26 serial::ConnectionInfoPtr GetPortInfo() const override; | 28 serial::ConnectionInfoPtr GetPortInfo() const override; |
27 void RequestAccess( | 29 void RequestAccess( |
28 const std::string& port, | 30 const std::string& port, |
29 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 31 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner, |
30 scoped_refptr<base::MessageLoopProxy> ui_message_loop) override; | 32 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) override; |
31 | 33 |
32 private: | 34 private: |
33 friend class SerialIoHandler; | 35 friend class SerialIoHandler; |
34 | 36 |
35 SerialIoHandlerPosix( | 37 SerialIoHandlerPosix( |
36 scoped_refptr<base::MessageLoopProxy> file_thread_message_loop, | 38 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, |
37 scoped_refptr<base::MessageLoopProxy> ui_thread_message_loop); | 39 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner); |
38 ~SerialIoHandlerPosix() override; | 40 ~SerialIoHandlerPosix() override; |
39 | 41 |
40 // base::MessageLoopForIO::Watcher implementation. | 42 // base::MessageLoopForIO::Watcher implementation. |
41 void OnFileCanWriteWithoutBlocking(int fd) override; | 43 void OnFileCanWriteWithoutBlocking(int fd) override; |
42 void OnFileCanReadWithoutBlocking(int fd) override; | 44 void OnFileCanReadWithoutBlocking(int fd) override; |
43 | 45 |
44 void EnsureWatchingReads(); | 46 void EnsureWatchingReads(); |
45 void EnsureWatchingWrites(); | 47 void EnsureWatchingWrites(); |
46 | 48 |
47 base::MessageLoopForIO::FileDescriptorWatcher file_read_watcher_; | 49 base::MessageLoopForIO::FileDescriptorWatcher file_read_watcher_; |
48 base::MessageLoopForIO::FileDescriptorWatcher file_write_watcher_; | 50 base::MessageLoopForIO::FileDescriptorWatcher file_write_watcher_; |
49 | 51 |
50 // Flags indicating if the message loop is watching the device for IO events. | 52 // Flags indicating if the message loop is watching the device for IO events. |
51 bool is_watching_reads_; | 53 bool is_watching_reads_; |
52 bool is_watching_writes_; | 54 bool is_watching_writes_; |
53 | 55 |
54 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix); | 56 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix); |
55 }; | 57 }; |
56 | 58 |
57 } // namespace device | 59 } // namespace device |
58 | 60 |
59 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ | 61 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ |
OLD | NEW |