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

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

Issue 2031743005: Remove use of deprecated MessageLoop methods in device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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_sink_receiver.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 #include "device/serial/data_source_sender.h" 5 #include "device/serial/data_source_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/location.h"
14 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread_task_runner_handle.h"
14 16
15 namespace device { 17 namespace device {
16 18
17 // Represents a send that is not yet fulfilled. 19 // Represents a send that is not yet fulfilled.
18 class DataSourceSender::PendingSend { 20 class DataSourceSender::PendingSend {
19 public: 21 public:
20 PendingSend(DataSourceSender* sender, const ReadyCallback& callback); 22 PendingSend(DataSourceSender* sender, const ReadyCallback& callback);
21 23
22 // Asynchronously fills |data_| with up to |num_bytes| of data. Following 24 // Asynchronously fills |data_| with up to |num_bytes| of data. Following
23 // this, one of Done() and DoneWithError() will be called with the result. 25 // this, one of Done() and DoneWithError() will be called with the result.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (shut_down_ || paused_ || pending_send_ || !available_buffer_capacity_) 133 if (shut_down_ || paused_ || pending_send_ || !available_buffer_capacity_)
132 return; 134 return;
133 135
134 pending_send_.reset(new PendingSend(this, ready_callback_)); 136 pending_send_.reset(new PendingSend(this, ready_callback_));
135 pending_send_->GetData(available_buffer_capacity_); 137 pending_send_->GetData(available_buffer_capacity_);
136 } 138 }
137 139
138 void DataSourceSender::Done(const std::vector<char>& data) { 140 void DataSourceSender::Done(const std::vector<char>& data) {
139 DoneInternal(data); 141 DoneInternal(data);
140 if (!shut_down_ && available_buffer_capacity_) { 142 if (!shut_down_ && available_buffer_capacity_) {
141 base::MessageLoop::current()->PostTask( 143 base::ThreadTaskRunnerHandle::Get()->PostTask(
142 FROM_HERE, 144 FROM_HERE,
143 base::Bind(&DataSourceSender::GetMoreData, weak_factory_.GetWeakPtr())); 145 base::Bind(&DataSourceSender::GetMoreData, weak_factory_.GetWeakPtr()));
144 } 146 }
145 } 147 }
146 148
147 void DataSourceSender::DoneWithError(const std::vector<char>& data, 149 void DataSourceSender::DoneWithError(const std::vector<char>& data,
148 int32_t error) { 150 int32_t error) {
149 DoneInternal(data); 151 DoneInternal(data);
150 if (!shut_down_) 152 if (!shut_down_)
151 client_->OnError(error); 153 client_->OnError(error);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 uint32_t bytes_written, 245 uint32_t bytes_written,
244 int32_t error) { 246 int32_t error) {
245 DCHECK(sender_.get()); 247 DCHECK(sender_.get());
246 PendingSend* send = pending_send_; 248 PendingSend* send = pending_send_;
247 pending_send_ = nullptr; 249 pending_send_ = nullptr;
248 send->DoneWithError(bytes_written, error); 250 send->DoneWithError(bytes_written, error);
249 sender_ = nullptr; 251 sender_ = nullptr;
250 } 252 }
251 253
252 } // namespace device 254 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/data_sink_receiver.cc ('k') | device/serial/serial_io_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698