| 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_WIN_H_ | 5 #ifndef DEVICE_SERIAL_SERIAL_IO_HANDLER_WIN_H_ |
| 6 #define DEVICE_SERIAL_SERIAL_IO_HANDLER_WIN_H_ | 6 #define DEVICE_SERIAL_SERIAL_IO_HANDLER_WIN_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "device/serial/serial_io_handler.h" | 10 #include "device/serial/serial_io_handler.h" |
| 11 | 11 |
| 12 namespace device { | 12 namespace device { |
| 13 | 13 |
| 14 class SerialIoHandlerWin : public SerialIoHandler, | 14 class SerialIoHandlerWin : public SerialIoHandler, |
| 15 public base::MessageLoopForIO::IOHandler { | 15 public base::MessageLoopForIO::IOHandler { |
| 16 protected: | 16 protected: |
| 17 // SerialIoHandler implementation. | 17 // SerialIoHandler implementation. |
| 18 virtual void ReadImpl() override; | 18 void ReadImpl() override; |
| 19 virtual void WriteImpl() override; | 19 void WriteImpl() override; |
| 20 virtual void CancelReadImpl() override; | 20 void CancelReadImpl() override; |
| 21 virtual void CancelWriteImpl() override; | 21 void CancelWriteImpl() override; |
| 22 virtual bool ConfigurePortImpl() override; | 22 bool ConfigurePortImpl() override; |
| 23 virtual bool Flush() const override; | 23 bool Flush() const override; |
| 24 virtual serial::DeviceControlSignalsPtr GetControlSignals() const override; | 24 serial::DeviceControlSignalsPtr GetControlSignals() const override; |
| 25 virtual bool SetControlSignals( | 25 bool SetControlSignals( |
| 26 const serial::HostControlSignals& control_signals) override; | 26 const serial::HostControlSignals& control_signals) override; |
| 27 virtual serial::ConnectionInfoPtr GetPortInfo() const override; | 27 serial::ConnectionInfoPtr GetPortInfo() const override; |
| 28 virtual bool PostOpen() override; | 28 bool PostOpen() override; |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 friend class SerialIoHandler; | 31 friend class SerialIoHandler; |
| 32 | 32 |
| 33 explicit SerialIoHandlerWin( | 33 explicit SerialIoHandlerWin( |
| 34 scoped_refptr<base::MessageLoopProxy> file_thread_message_loop, | 34 scoped_refptr<base::MessageLoopProxy> file_thread_message_loop, |
| 35 scoped_refptr<base::MessageLoopProxy> ui_thread_message_loop); | 35 scoped_refptr<base::MessageLoopProxy> ui_thread_message_loop); |
| 36 virtual ~SerialIoHandlerWin(); | 36 ~SerialIoHandlerWin() override; |
| 37 | 37 |
| 38 // base::MessageLoopForIO::IOHandler implementation. | 38 // base::MessageLoopForIO::IOHandler implementation. |
| 39 virtual void OnIOCompleted(base::MessageLoopForIO::IOContext* context, | 39 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, |
| 40 DWORD bytes_transfered, | 40 DWORD bytes_transfered, |
| 41 DWORD error) override; | 41 DWORD error) override; |
| 42 | 42 |
| 43 // Context used for asynchronous WaitCommEvent calls. | 43 // Context used for asynchronous WaitCommEvent calls. |
| 44 scoped_ptr<base::MessageLoopForIO::IOContext> comm_context_; | 44 scoped_ptr<base::MessageLoopForIO::IOContext> comm_context_; |
| 45 | 45 |
| 46 // Context used for overlapped reads. | 46 // Context used for overlapped reads. |
| 47 scoped_ptr<base::MessageLoopForIO::IOContext> read_context_; | 47 scoped_ptr<base::MessageLoopForIO::IOContext> read_context_; |
| 48 | 48 |
| 49 // Context used for overlapped writes. | 49 // Context used for overlapped writes. |
| 50 scoped_ptr<base::MessageLoopForIO::IOContext> write_context_; | 50 scoped_ptr<base::MessageLoopForIO::IOContext> write_context_; |
| 51 | 51 |
| 52 // Asynchronous event mask state | 52 // Asynchronous event mask state |
| 53 DWORD event_mask_; | 53 DWORD event_mask_; |
| 54 | 54 |
| 55 // Indicates if a pending read is waiting on initial data arrival via | 55 // Indicates if a pending read is waiting on initial data arrival via |
| 56 // WaitCommEvent, as opposed to waiting on actual ReadFile completion | 56 // WaitCommEvent, as opposed to waiting on actual ReadFile completion |
| 57 // after a corresponding WaitCommEvent has completed. | 57 // after a corresponding WaitCommEvent has completed. |
| 58 bool is_comm_pending_; | 58 bool is_comm_pending_; |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerWin); | 60 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerWin); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace device | 63 } // namespace device |
| 64 | 64 |
| 65 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_WIN_H_ | 65 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_WIN_H_ |
| OLD | NEW |