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

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

Issue 1544323002: Convert Pass()→std::move() in //device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 #include "device/serial/data_sender.h" 5 #include "device/serial/data_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
11 12
12 namespace device { 13 namespace device {
13 14
14 // Represents a send that is not yet fulfilled. 15 // Represents a send that is not yet fulfilled.
15 class DataSender::PendingSend { 16 class DataSender::PendingSend {
16 public: 17 public:
17 PendingSend(const base::StringPiece& data, 18 PendingSend(const base::StringPiece& data,
(...skipping 24 matching lines...) Expand all
42 // The callback to report errors. 43 // The callback to report errors.
43 const SendErrorCallback error_callback_; 44 const SendErrorCallback error_callback_;
44 45
45 // The DataSender that owns this PendingSend. 46 // The DataSender that owns this PendingSend.
46 DataSender* sender_; 47 DataSender* sender_;
47 }; 48 };
48 49
49 DataSender::DataSender(mojo::InterfacePtr<serial::DataSink> sink, 50 DataSender::DataSender(mojo::InterfacePtr<serial::DataSink> sink,
50 uint32_t buffer_size, 51 uint32_t buffer_size,
51 int32_t fatal_error_value) 52 int32_t fatal_error_value)
52 : sink_(sink.Pass()), 53 : sink_(std::move(sink)),
53 fatal_error_value_(fatal_error_value), 54 fatal_error_value_(fatal_error_value),
54 shut_down_(false) { 55 shut_down_(false) {
55 sink_.set_connection_error_handler( 56 sink_.set_connection_error_handler(
56 base::Bind(&DataSender::OnConnectionError, base::Unretained(this))); 57 base::Bind(&DataSender::OnConnectionError, base::Unretained(this)));
57 } 58 }
58 59
59 DataSender::~DataSender() { 60 DataSender::~DataSender() {
60 ShutDown(); 61 ShutDown();
61 } 62 }
62 63
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 void DataSender::PendingSend::DispatchFatalError() { 160 void DataSender::PendingSend::DispatchFatalError() {
160 base::MessageLoop::current()->PostTask( 161 base::MessageLoop::current()->PostTask(
161 FROM_HERE, base::Bind(error_callback_, 0, sender_->fatal_error_value_)); 162 FROM_HERE, base::Bind(error_callback_, 0, sender_->fatal_error_value_));
162 } 163 }
163 164
164 void DataSender::PendingSend::SendData() { 165 void DataSender::PendingSend::SendData() {
165 uint32_t num_bytes_to_send = static_cast<uint32_t>(data_.size()); 166 uint32_t num_bytes_to_send = static_cast<uint32_t>(data_.size());
166 mojo::Array<uint8_t> bytes(num_bytes_to_send); 167 mojo::Array<uint8_t> bytes(num_bytes_to_send);
167 memcpy(&bytes[0], data_.data(), num_bytes_to_send); 168 memcpy(&bytes[0], data_.data(), num_bytes_to_send);
168 sender_->sink_->OnData( 169 sender_->sink_->OnData(
169 bytes.Pass(), 170 std::move(bytes),
170 base::Bind(&DataSender::PendingSend::OnDataSent, base::Unretained(this))); 171 base::Bind(&DataSender::PendingSend::OnDataSent, base::Unretained(this)));
171 } 172 }
172 173
173 } // namespace device 174 } // namespace device
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