Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: device/serial/serial_io_handler.h

Issue 1874313002: Convert device to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/serial/serial_device_enumerator_win.cc ('k') | device/serial/serial_io_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_H_ 5 #ifndef DEVICE_SERIAL_SERIAL_IO_HANDLER_H_
6 #define DEVICE_SERIAL_SERIAL_IO_HANDLER_H_ 6 #define DEVICE_SERIAL_SERIAL_IO_HANDLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
11
10 #include "base/callback.h" 12 #include "base/callback.h"
11 #include "base/files/file.h" 13 #include "base/files/file.h"
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
14 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
15 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
16 #include "base/threading/non_thread_safe.h" 18 #include "base/threading/non_thread_safe.h"
17 #include "build/build_config.h" 19 #include "build/build_config.h"
18 #include "device/serial/buffer.h" 20 #include "device/serial/buffer.h"
19 #include "device/serial/serial.mojom.h" 21 #include "device/serial/serial.mojom.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 dbus::FileDescriptor fd); 64 dbus::FileDescriptor fd);
63 65
64 // Reports the open error from the permission broker. 66 // Reports the open error from the permission broker.
65 void ReportPathOpenError(const std::string& error_name, 67 void ReportPathOpenError(const std::string& error_name,
66 const std::string& error_message); 68 const std::string& error_message);
67 #endif // defined(OS_CHROMEOS) 69 #endif // defined(OS_CHROMEOS)
68 70
69 // Performs an async Read operation. Behavior is undefined if this is called 71 // Performs an async Read operation. Behavior is undefined if this is called
70 // while a Read is already pending. Otherwise, the Done or DoneWithError 72 // while a Read is already pending. Otherwise, the Done or DoneWithError
71 // method on |buffer| will eventually be called with a result. 73 // method on |buffer| will eventually be called with a result.
72 void Read(scoped_ptr<WritableBuffer> buffer); 74 void Read(std::unique_ptr<WritableBuffer> buffer);
73 75
74 // Performs an async Write operation. Behavior is undefined if this is called 76 // Performs an async Write operation. Behavior is undefined if this is called
75 // while a Write is already pending. Otherwise, the Done or DoneWithError 77 // while a Write is already pending. Otherwise, the Done or DoneWithError
76 // method on |buffer| will eventually be called with a result. 78 // method on |buffer| will eventually be called with a result.
77 void Write(scoped_ptr<ReadOnlyBuffer> buffer); 79 void Write(std::unique_ptr<ReadOnlyBuffer> buffer);
78 80
79 // Indicates whether or not a read is currently pending. 81 // Indicates whether or not a read is currently pending.
80 bool IsReadPending() const; 82 bool IsReadPending() const;
81 83
82 // Indicates whether or not a write is currently pending. 84 // Indicates whether or not a write is currently pending.
83 bool IsWritePending() const; 85 bool IsWritePending() const;
84 86
85 // Attempts to cancel a pending read operation. 87 // Attempts to cancel a pending read operation.
86 void CancelRead(serial::ReceiveError reason); 88 void CancelRead(serial::ReceiveError reason);
87 89
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // Continues a Close operation on the FILE thread. 233 // Continues a Close operation on the FILE thread.
232 static void DoClose(base::File port); 234 static void DoClose(base::File port);
233 235
234 // File for the opened serial device. This value is only modified from the IO 236 // File for the opened serial device. This value is only modified from the IO
235 // thread. 237 // thread.
236 base::File file_; 238 base::File file_;
237 239
238 // Currently applied connection options. 240 // Currently applied connection options.
239 serial::ConnectionOptions options_; 241 serial::ConnectionOptions options_;
240 242
241 scoped_ptr<WritableBuffer> pending_read_buffer_; 243 std::unique_ptr<WritableBuffer> pending_read_buffer_;
242 serial::ReceiveError read_cancel_reason_; 244 serial::ReceiveError read_cancel_reason_;
243 bool read_canceled_; 245 bool read_canceled_;
244 246
245 scoped_ptr<ReadOnlyBuffer> pending_write_buffer_; 247 std::unique_ptr<ReadOnlyBuffer> pending_write_buffer_;
246 serial::SendError write_cancel_reason_; 248 serial::SendError write_cancel_reason_;
247 bool write_canceled_; 249 bool write_canceled_;
248 250
249 // Callback to handle the completion of a pending Open() request. 251 // Callback to handle the completion of a pending Open() request.
250 OpenCompleteCallback open_complete_; 252 OpenCompleteCallback open_complete_;
251 253
252 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_; 254 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_;
253 // On Chrome OS, PermissionBrokerClient should be called on the UI thread. 255 // On Chrome OS, PermissionBrokerClient should be called on the UI thread.
254 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner_; 256 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner_;
255 257
256 std::string port_; 258 std::string port_;
257 259
258 DISALLOW_COPY_AND_ASSIGN(SerialIoHandler); 260 DISALLOW_COPY_AND_ASSIGN(SerialIoHandler);
259 }; 261 };
260 262
261 } // namespace device 263 } // namespace device
262 264
263 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_H_ 265 #endif // DEVICE_SERIAL_SERIAL_IO_HANDLER_H_
OLDNEW
« no previous file with comments | « device/serial/serial_device_enumerator_win.cc ('k') | device/serial/serial_io_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698