| 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::DeviceControlSignalsPtr GetControlSignals() const OVERRIDE; |
| 23 api::serial::DeviceControlSignals* control_signals) const OVERRIDE; | |
| 24 virtual bool SetControlSignals( | 23 virtual bool SetControlSignals( |
| 25 const api::serial::HostControlSignals& control_signals) OVERRIDE; | 24 const device::HostControlSignals& control_signals) OVERRIDE; |
| 26 virtual bool ConfigurePort( | 25 virtual bool ConfigurePort(const device::ConnectionOptions& options) OVERRIDE; |
| 27 const api::serial::ConnectionOptions& options) OVERRIDE; | 26 virtual device::ConnectionInfoPtr GetPortInfo() const OVERRIDE; |
| 28 virtual bool GetPortInfo(api::serial::ConnectionInfo* info) const OVERRIDE; | |
| 29 virtual bool PostOpen() OVERRIDE; | 27 virtual bool PostOpen() OVERRIDE; |
| 30 | 28 |
| 31 private: | 29 private: |
| 32 friend class SerialIoHandler; | 30 friend class SerialIoHandler; |
| 33 | 31 |
| 34 SerialIoHandlerPosix(); | 32 SerialIoHandlerPosix(); |
| 35 virtual ~SerialIoHandlerPosix(); | 33 virtual ~SerialIoHandlerPosix(); |
| 36 | 34 |
| 37 // base::MessageLoopForIO::Watcher implementation. | 35 // base::MessageLoopForIO::Watcher implementation. |
| 38 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 36 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
| 39 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 37 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
| 40 | 38 |
| 41 void EnsureWatchingReads(); | 39 void EnsureWatchingReads(); |
| 42 void EnsureWatchingWrites(); | 40 void EnsureWatchingWrites(); |
| 43 | 41 |
| 44 base::MessageLoopForIO::FileDescriptorWatcher file_read_watcher_; | 42 base::MessageLoopForIO::FileDescriptorWatcher file_read_watcher_; |
| 45 base::MessageLoopForIO::FileDescriptorWatcher file_write_watcher_; | 43 base::MessageLoopForIO::FileDescriptorWatcher file_write_watcher_; |
| 46 | 44 |
| 47 // Flags indicating if the message loop is watching the device for IO events. | 45 // Flags indicating if the message loop is watching the device for IO events. |
| 48 bool is_watching_reads_; | 46 bool is_watching_reads_; |
| 49 bool is_watching_writes_; | 47 bool is_watching_writes_; |
| 50 | 48 |
| 51 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix); | 49 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerPosix); |
| 52 }; | 50 }; |
| 53 | 51 |
| 54 } // namespace extensions | 52 } // namespace extensions |
| 55 | 53 |
| 56 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ | 54 #endif // CHROME_BROWSER_EXTENSIONS_API_SERIAL_SERIAL_IO_HANDLER_POSIX_H_ |
| OLD | NEW |