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

Side by Side Diff: device/serial/data_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/nfc/nfc_tag_chromeos.h ('k') | device/serial/data_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_RECEIVER_H_ 5 #ifndef DEVICE_SERIAL_DATA_RECEIVER_H_
6 #define DEVICE_SERIAL_DATA_RECEIVER_H_ 6 #define DEVICE_SERIAL_DATA_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 // A DataReceiver receives data from a DataSource. 25 // A DataReceiver receives data from a DataSource.
25 class DataReceiver : public base::RefCounted<DataReceiver>, 26 class DataReceiver : public base::RefCounted<DataReceiver>,
26 public serial::DataSourceClient { 27 public serial::DataSourceClient {
27 public: 28 public:
28 typedef base::Callback<void(scoped_ptr<ReadOnlyBuffer>)> ReceiveDataCallback; 29 typedef base::Callback<void(std::unique_ptr<ReadOnlyBuffer>)>
30 ReceiveDataCallback;
29 typedef base::Callback<void(int32_t error)> ReceiveErrorCallback; 31 typedef base::Callback<void(int32_t error)> ReceiveErrorCallback;
30 32
31 // Constructs a DataReceiver to receive data from |source|, using a buffer 33 // Constructs a DataReceiver to receive data from |source|, using a buffer
32 // size of |buffer_size|, with connection errors reported as 34 // size of |buffer_size|, with connection errors reported as
33 // |fatal_error_value|. 35 // |fatal_error_value|.
34 DataReceiver(mojo::InterfacePtr<serial::DataSource> source, 36 DataReceiver(mojo::InterfacePtr<serial::DataSource> source,
35 mojo::InterfaceRequest<serial::DataSourceClient> client, 37 mojo::InterfaceRequest<serial::DataSourceClient> client,
36 uint32_t buffer_size, 38 uint32_t buffer_size,
37 int32_t fatal_error_value); 39 int32_t fatal_error_value);
38 40
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 mojo::InterfacePtr<serial::DataSource> source_; 80 mojo::InterfacePtr<serial::DataSource> source_;
79 mojo::Binding<serial::DataSourceClient> client_; 81 mojo::Binding<serial::DataSourceClient> client_;
80 82
81 // The error value to report in the event of a fatal error. 83 // The error value to report in the event of a fatal error.
82 const int32_t fatal_error_value_; 84 const int32_t fatal_error_value_;
83 85
84 // Whether we have encountered a fatal error and shut down. 86 // Whether we have encountered a fatal error and shut down.
85 bool shut_down_; 87 bool shut_down_;
86 88
87 // The current pending receive operation if there is one. 89 // The current pending receive operation if there is one.
88 scoped_ptr<PendingReceive> pending_receive_; 90 std::unique_ptr<PendingReceive> pending_receive_;
89 91
90 // The queue of pending data frames (data or an error) received from the 92 // The queue of pending data frames (data or an error) received from the
91 // DataSource. 93 // DataSource.
92 std::queue<linked_ptr<DataFrame>> pending_data_frames_; 94 std::queue<linked_ptr<DataFrame>> pending_data_frames_;
93 95
94 base::WeakPtrFactory<DataReceiver> weak_factory_; 96 base::WeakPtrFactory<DataReceiver> weak_factory_;
95 97
96 DISALLOW_COPY_AND_ASSIGN(DataReceiver); 98 DISALLOW_COPY_AND_ASSIGN(DataReceiver);
97 }; 99 };
98 100
99 } // namespace device 101 } // namespace device
100 102
101 #endif // DEVICE_SERIAL_DATA_RECEIVER_H_ 103 #endif // DEVICE_SERIAL_DATA_RECEIVER_H_
OLDNEW
« no previous file with comments | « device/nfc/nfc_tag_chromeos.h ('k') | device/serial/data_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698