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

Side by Side Diff: device/serial/data_receiver.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/hid/hid_service.cc ('k') | device/serial/data_sender.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_receiver.h" 5 #include "device/serial/data_receiver.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/location.h"
13 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread_task_runner_handle.h"
13 15
14 namespace device { 16 namespace device {
15 17
16 // Represents a receive that is not yet fulfilled. 18 // Represents a receive that is not yet fulfilled.
17 class DataReceiver::PendingReceive { 19 class DataReceiver::PendingReceive {
18 public: 20 public:
19 PendingReceive(DataReceiver* receiver, 21 PendingReceive(DataReceiver* receiver,
20 const ReceiveDataCallback& callback, 22 const ReceiveDataCallback& callback,
21 const ReceiveErrorCallback& error_callback, 23 const ReceiveErrorCallback& error_callback,
22 int32_t fatal_error_value); 24 int32_t fatal_error_value);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 buffer_in_use_(false) { 220 buffer_in_use_(false) {
219 } 221 }
220 222
221 bool DataReceiver::PendingReceive::DispatchDataFrame( 223 bool DataReceiver::PendingReceive::DispatchDataFrame(
222 DataReceiver::DataFrame* data) { 224 DataReceiver::DataFrame* data) {
223 DCHECK(!buffer_in_use_); 225 DCHECK(!buffer_in_use_);
224 DCHECK(!data->dispatched); 226 DCHECK(!data->dispatched);
225 227
226 if (data->is_error) { 228 if (data->is_error) {
227 data->dispatched = true; 229 data->dispatched = true;
228 base::MessageLoop::current()->PostTask( 230 base::ThreadTaskRunnerHandle::Get()->PostTask(
229 FROM_HERE, base::Bind(receive_error_callback_, data->error)); 231 FROM_HERE, base::Bind(receive_error_callback_, data->error));
230 return true; 232 return true;
231 } 233 }
232 buffer_in_use_ = true; 234 buffer_in_use_ = true;
233 base::MessageLoop::current()->PostTask( 235 base::ThreadTaskRunnerHandle::Get()->PostTask(
234 FROM_HERE, 236 FROM_HERE,
235 base::Bind( 237 base::Bind(
236 receive_callback_, 238 receive_callback_,
237 base::Passed(std::unique_ptr<ReadOnlyBuffer>(new Buffer( 239 base::Passed(std::unique_ptr<ReadOnlyBuffer>(new Buffer(
238 receiver_, this, 240 receiver_, this,
239 reinterpret_cast<char*>(&data->data[0]) + data->offset, 241 reinterpret_cast<char*>(&data->data[0]) + data->offset,
240 static_cast<uint32_t>(data->data.size() - data->offset)))))); 242 static_cast<uint32_t>(data->data.size() - data->offset))))));
241 return false; 243 return false;
242 } 244 }
243 245
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 buffer_size_ = 0; 285 buffer_size_ = 0;
284 } 286 }
285 287
286 void DataReceiver::PendingReceive::Buffer::DoneWithError( 288 void DataReceiver::PendingReceive::Buffer::DoneWithError(
287 uint32_t bytes_consumed, 289 uint32_t bytes_consumed,
288 int32_t error) { 290 int32_t error) {
289 Done(bytes_consumed); 291 Done(bytes_consumed);
290 } 292 }
291 293
292 } // namespace device 294 } // namespace device
OLDNEW
« no previous file with comments | « device/hid/hid_service.cc ('k') | device/serial/data_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698