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 "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 bool Flush() const override; | 25 bool Flush() const override; |
26 serial::DeviceControlSignalsPtr GetControlSignals() const override; | 26 serial::DeviceControlSignalsPtr GetControlSignals() const override; |
27 bool SetControlSignals( | 27 bool SetControlSignals( |
28 const serial::HostControlSignals& control_signals) override; | 28 const serial::HostControlSignals& control_signals) override; |
29 serial::ConnectionInfoPtr GetPortInfo() const override; | 29 serial::ConnectionInfoPtr GetPortInfo() const override; |
30 bool SetBreak() override; | 30 bool SetBreak() override; |
31 bool ClearBreak() override; | 31 bool ClearBreak() override; |
32 bool PostOpen() override; | 32 bool PostOpen() override; |
33 | 33 |
34 private: | 34 private: |
| 35 class UiThreadHelper; |
35 friend class SerialIoHandler; | 36 friend class SerialIoHandler; |
36 | 37 |
37 explicit SerialIoHandlerWin( | 38 explicit SerialIoHandlerWin( |
38 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, | 39 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, |
39 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner); | 40 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner); |
40 ~SerialIoHandlerWin() override; | 41 ~SerialIoHandlerWin() override; |
41 | 42 |
42 // base::MessageLoopForIO::IOHandler implementation. | 43 // base::MessageLoopForIO::IOHandler implementation. |
43 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, | 44 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, |
44 DWORD bytes_transfered, | 45 DWORD bytes_transfered, |
45 DWORD error) override; | 46 DWORD error) override; |
46 | 47 |
| 48 void OnDeviceRemoved(const std::string& device_path); |
| 49 |
47 // Context used for asynchronous WaitCommEvent calls. | 50 // Context used for asynchronous WaitCommEvent calls. |
48 scoped_ptr<base::MessageLoopForIO::IOContext> comm_context_; | 51 scoped_ptr<base::MessageLoopForIO::IOContext> comm_context_; |
49 | 52 |
50 // Context used for overlapped reads. | 53 // Context used for overlapped reads. |
51 scoped_ptr<base::MessageLoopForIO::IOContext> read_context_; | 54 scoped_ptr<base::MessageLoopForIO::IOContext> read_context_; |
52 | 55 |
53 // Context used for overlapped writes. | 56 // Context used for overlapped writes. |
54 scoped_ptr<base::MessageLoopForIO::IOContext> write_context_; | 57 scoped_ptr<base::MessageLoopForIO::IOContext> write_context_; |
55 | 58 |
56 // Asynchronous event mask state | 59 // Asynchronous event mask state |
57 DWORD event_mask_; | 60 DWORD event_mask_; |
58 | 61 |
59 // Indicates if a pending read is waiting on initial data arrival via | 62 // Indicates if a pending read is waiting on initial data arrival via |
60 // WaitCommEvent, as opposed to waiting on actual ReadFile completion | 63 // WaitCommEvent, as opposed to waiting on actual ReadFile completion |
61 // after a corresponding WaitCommEvent has completed. | 64 // after a corresponding WaitCommEvent has completed. |
62 bool is_comm_pending_; | 65 bool is_comm_pending_; |
63 | 66 |
| 67 // The helper lives on the UI thread and holds a weak reference back to the |
| 68 // handler that owns it. |
| 69 UiThreadHelper* helper_ = nullptr; |
| 70 base::WeakPtrFactory<SerialIoHandlerWin> weak_factory_; |
| 71 |
64 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerWin); | 72 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerWin); |
65 }; | 73 }; |
66 | 74 |
67 } // namespace device | 75 } // namespace device |
68 | 76 |
69 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_WIN_H_ | 77 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_WIN_H_ |
OLD | NEW |