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

Side by Side Diff: device/serial/data_sink_receiver.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/data_receiver.cc ('k') | device/serial/data_sink_receiver.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_DATA_SINK_RECEIVER_H_ 5 #ifndef DEVICE_SERIAL_DATA_SINK_RECEIVER_H_
6 #define DEVICE_SERIAL_DATA_SINK_RECEIVER_H_ 6 #define DEVICE_SERIAL_DATA_SINK_RECEIVER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory>
10 #include <queue> 11 #include <queue>
11 12
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
17 #include "device/serial/buffer.h" 18 #include "device/serial/buffer.h"
18 #include "device/serial/data_stream.mojom.h" 19 #include "device/serial/data_stream.mojom.h"
19 #include "mojo/public/cpp/bindings/binding.h" 20 #include "mojo/public/cpp/bindings/binding.h"
20 #include "mojo/public/cpp/system/data_pipe.h" 21 #include "mojo/public/cpp/system/data_pipe.h"
21 22
22 namespace device { 23 namespace device {
23 24
24 class DataSinkReceiver : public base::RefCounted<DataSinkReceiver>, 25 class DataSinkReceiver : public base::RefCounted<DataSinkReceiver>,
25 public serial::DataSink { 26 public serial::DataSink {
26 public: 27 public:
27 typedef base::Callback<void(scoped_ptr<ReadOnlyBuffer>)> ReadyCallback; 28 typedef base::Callback<void(std::unique_ptr<ReadOnlyBuffer>)> ReadyCallback;
28 typedef base::Callback<void(int32_t error)> CancelCallback; 29 typedef base::Callback<void(int32_t error)> CancelCallback;
29 typedef base::Callback<void()> ErrorCallback; 30 typedef base::Callback<void()> ErrorCallback;
30 31
31 // Constructs a DataSinkReceiver. Whenever the pipe is ready for reading, the 32 // Constructs a DataSinkReceiver. Whenever the pipe is ready for reading, the
32 // |ready_callback| will be called with the ReadOnlyBuffer to read. 33 // |ready_callback| will be called with the ReadOnlyBuffer to read.
33 // |ready_callback| will not be called again until the previous ReadOnlyBuffer 34 // |ready_callback| will not be called again until the previous ReadOnlyBuffer
34 // is destroyed. If a connection error occurs, |error_callback| will be called 35 // is destroyed. If a connection error occurs, |error_callback| will be called
35 // and the DataSinkReceiver will act as if ShutDown() had been called. If 36 // and the DataSinkReceiver will act as if ShutDown() had been called. If
36 // |cancel_callback| is valid, it will be called when the DataSink client 37 // |cancel_callback| is valid, it will be called when the DataSink client
37 // requests cancellation of the in-progress read. 38 // requests cancellation of the in-progress read.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 bool shut_down_; 105 bool shut_down_;
105 106
106 base::WeakPtrFactory<DataSinkReceiver> weak_factory_; 107 base::WeakPtrFactory<DataSinkReceiver> weak_factory_;
107 108
108 DISALLOW_COPY_AND_ASSIGN(DataSinkReceiver); 109 DISALLOW_COPY_AND_ASSIGN(DataSinkReceiver);
109 }; 110 };
110 111
111 } // namespace device 112 } // namespace device
112 113
113 #endif // DEVICE_SERIAL_DATA_SINK_RECEIVER_H_ 114 #endif // DEVICE_SERIAL_DATA_SINK_RECEIVER_H_
OLDNEW
« no previous file with comments | « device/serial/data_receiver.cc ('k') | device/serial/data_sink_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698