OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_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 "chrome/browser/extensions/api/serial/serial_io_handler.h" | 9 #include "chrome/browser/extensions/api/serial/serial_io_handler.h" |
10 | 10 |
11 namespace extensions { | 11 namespace extensions { |
12 | 12 |
13 class SerialIoHandlerPosix : public SerialIoHandler, | 13 class SerialIoHandlerPosix : public SerialIoHandler, |
14 public base::MessageLoopForIO::Watcher { | 14 public base::MessageLoopForIO::Watcher { |
15 protected: | 15 protected: |
16 // SerialIoHandler impl. | 16 // SerialIoHandler impl. |
17 virtual void ReadImpl() OVERRIDE; | 17 virtual void ReadImpl() OVERRIDE; |
18 virtual void WriteImpl() OVERRIDE; | 18 virtual void WriteImpl() OVERRIDE; |
19 virtual void CancelReadImpl() OVERRIDE; | 19 virtual void CancelReadImpl() OVERRIDE; |
20 virtual void CancelWriteImpl() OVERRIDE; | 20 virtual void CancelWriteImpl() OVERRIDE; |
21 virtual bool Flush() const OVERRIDE; | 21 virtual bool Flush() const OVERRIDE; |
22 virtual bool GetControlSignals( | 22 virtual device::serial::DeviceControlSignalsPtr GetControlSignals() |
23 api::serial::DeviceControlSignals* control_signals) const OVERRIDE; | 23 const OVERRIDE; |
24 virtual bool SetControlSignals( | 24 virtual bool SetControlSignals( |
25 const api::serial::HostControlSignals& control_signals) OVERRIDE; | 25 const device::serial::HostControlSignals& control_signals) OVERRIDE; |
26 virtual bool ConfigurePort( | 26 virtual bool ConfigurePort( |
27 const api::serial::ConnectionOptions& options) OVERRIDE; | 27 const device::serial::ConnectionOptions& options) OVERRIDE; |
28 virtual bool GetPortInfo(api::serial::ConnectionInfo* info) const OVERRIDE; | 28 virtual device::serial::ConnectionInfoPtr GetPortInfo() const OVERRIDE; |
29 virtual bool PostOpen() OVERRIDE; | 29 virtual bool PostOpen() OVERRIDE; |
30 | 30 |
31 private: | 31 private: |
32 friend class SerialIoHandler; | 32 friend class SerialIoHandler; |
33 | 33 |
34 SerialIoHandlerPosix(); | 34 SerialIoHandlerPosix(); |
35 virtual ~SerialIoHandlerPosix(); | 35 virtual ~SerialIoHandlerPosix(); |
36 | 36 |
37 // base::MessageLoopForIO::Watcher implementation. | 37 // base::MessageLoopForIO::Watcher implementation. |
38 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 38 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
39 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 39 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
40 | 40 |
41 void EnsureWatchingReads(); | 41 void EnsureWatchingReads(); |
42 void EnsureWatchingWrites(); | 42 void EnsureWatchingWrites(); |
43 | 43 |
44 base::MessageLoopForIO::FileDescriptorWatcher file_read_watcher_; | 44 base::MessageLoopForIO::FileDescriptorWatcher file_read_watcher_; |
45 base::MessageLoopForIO::FileDescriptorWatcher file_write_watcher_; | 45 base::MessageLoopForIO::FileDescriptorWatcher file_write_watcher_; |
46 | 46 |
47 // Flags indicating if the message loop is watching the device for IO events. | 47 // Flags indicating if the message loop is watching the device for IO events. |
48 bool is_watching_reads_; | 48 bool is_watching_reads_; |
49 bool is_watching_writes_; | 49 bool is_watching_writes_; |
50 | 50 |
51 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix); | 51 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix); |
52 }; | 52 }; |
53 | 53 |
54 } // namespace extensions | 54 } // namespace extensions |
55 | 55 |
56 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ | 56 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ |
OLD | NEW |