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

Side by Side Diff: device/serial/data_receiver.cc

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.h ('k') | device/serial/data_sink_receiver.h » ('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 #include "device/serial/data_receiver.h" 5 #include "device/serial/data_receiver.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <memory>
8 #include <utility> 9 #include <utility>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
12 13
13 namespace device { 14 namespace device {
14 15
15 // Represents a receive that is not yet fulfilled. 16 // Represents a receive that is not yet fulfilled.
16 class DataReceiver::PendingReceive { 17 class DataReceiver::PendingReceive {
17 public: 18 public:
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 data->dispatched = true; 227 data->dispatched = true;
227 base::MessageLoop::current()->PostTask( 228 base::MessageLoop::current()->PostTask(
228 FROM_HERE, base::Bind(receive_error_callback_, data->error)); 229 FROM_HERE, base::Bind(receive_error_callback_, data->error));
229 return true; 230 return true;
230 } 231 }
231 buffer_in_use_ = true; 232 buffer_in_use_ = true;
232 base::MessageLoop::current()->PostTask( 233 base::MessageLoop::current()->PostTask(
233 FROM_HERE, 234 FROM_HERE,
234 base::Bind( 235 base::Bind(
235 receive_callback_, 236 receive_callback_,
236 base::Passed(scoped_ptr<ReadOnlyBuffer>(new Buffer( 237 base::Passed(std::unique_ptr<ReadOnlyBuffer>(new Buffer(
237 receiver_, 238 receiver_, this,
238 this,
239 reinterpret_cast<char*>(&data->data[0]) + data->offset, 239 reinterpret_cast<char*>(&data->data[0]) + data->offset,
240 static_cast<uint32_t>(data->data.size() - data->offset)))))); 240 static_cast<uint32_t>(data->data.size() - data->offset))))));
241 return false; 241 return false;
242 } 242 }
243 243
244 void DataReceiver::PendingReceive::DispatchFatalError() { 244 void DataReceiver::PendingReceive::DispatchFatalError() {
245 receive_error_callback_.Run(fatal_error_value_); 245 receive_error_callback_.Run(fatal_error_value_);
246 } 246 }
247 247
248 void DataReceiver::PendingReceive::Done(uint32_t bytes_consumed) { 248 void DataReceiver::PendingReceive::Done(uint32_t bytes_consumed) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 buffer_size_ = 0; 283 buffer_size_ = 0;
284 } 284 }
285 285
286 void DataReceiver::PendingReceive::Buffer::DoneWithError( 286 void DataReceiver::PendingReceive::Buffer::DoneWithError(
287 uint32_t bytes_consumed, 287 uint32_t bytes_consumed,
288 int32_t error) { 288 int32_t error) {
289 Done(bytes_consumed); 289 Done(bytes_consumed);
290 } 290 }
291 291
292 } // namespace device 292 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/data_receiver.h ('k') | device/serial/data_sink_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698