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 <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
12 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
13 #include "device/serial/serial_io_handler.h" | 14 #include "device/serial/serial_io_handler.h" |
14 | 15 |
15 namespace device { | 16 namespace device { |
16 | 17 |
17 class SerialIoHandlerWin : public SerialIoHandler, | 18 class SerialIoHandlerWin : public SerialIoHandler, |
18 public base::MessageLoopForIO::IOHandler { | 19 public base::MessageLoopForIO::IOHandler { |
19 protected: | 20 protected: |
(...skipping 22 matching lines...) Expand all Loading... |
42 ~SerialIoHandlerWin() override; | 43 ~SerialIoHandlerWin() override; |
43 | 44 |
44 // base::MessageLoopForIO::IOHandler implementation. | 45 // base::MessageLoopForIO::IOHandler implementation. |
45 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, | 46 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, |
46 DWORD bytes_transfered, | 47 DWORD bytes_transfered, |
47 DWORD error) override; | 48 DWORD error) override; |
48 | 49 |
49 void OnDeviceRemoved(const std::string& device_path); | 50 void OnDeviceRemoved(const std::string& device_path); |
50 | 51 |
51 // Context used for asynchronous WaitCommEvent calls. | 52 // Context used for asynchronous WaitCommEvent calls. |
52 scoped_ptr<base::MessageLoopForIO::IOContext> comm_context_; | 53 std::unique_ptr<base::MessageLoopForIO::IOContext> comm_context_; |
53 | 54 |
54 // Context used for overlapped reads. | 55 // Context used for overlapped reads. |
55 scoped_ptr<base::MessageLoopForIO::IOContext> read_context_; | 56 std::unique_ptr<base::MessageLoopForIO::IOContext> read_context_; |
56 | 57 |
57 // Context used for overlapped writes. | 58 // Context used for overlapped writes. |
58 scoped_ptr<base::MessageLoopForIO::IOContext> write_context_; | 59 std::unique_ptr<base::MessageLoopForIO::IOContext> write_context_; |
59 | 60 |
60 // Asynchronous event mask state | 61 // Asynchronous event mask state |
61 DWORD event_mask_; | 62 DWORD event_mask_; |
62 | 63 |
63 // Indicates if a pending read is waiting on initial data arrival via | 64 // Indicates if a pending read is waiting on initial data arrival via |
64 // WaitCommEvent, as opposed to waiting on actual ReadFile completion | 65 // WaitCommEvent, as opposed to waiting on actual ReadFile completion |
65 // after a corresponding WaitCommEvent has completed. | 66 // after a corresponding WaitCommEvent has completed. |
66 bool is_comm_pending_; | 67 bool is_comm_pending_; |
67 | 68 |
68 // The helper lives on the UI thread and holds a weak reference back to the | 69 // The helper lives on the UI thread and holds a weak reference back to the |
69 // handler that owns it. | 70 // handler that owns it. |
70 UiThreadHelper* helper_; | 71 UiThreadHelper* helper_; |
71 base::WeakPtrFactory<SerialIoHandlerWin> weak_factory_; | 72 base::WeakPtrFactory<SerialIoHandlerWin> weak_factory_; |
72 | 73 |
73 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerWin); | 74 DISALLOW_COPY_AND_ASSIGN(SerialIoHandlerWin); |
74 }; | 75 }; |
75 | 76 |
76 } // namespace device | 77 } // namespace device |
77 | 78 |
78 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_WIN_H_ | 79 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_WIN_H_ |
OLD | NEW |