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

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

Issue 1212023004: Convert all usages of mojo::ErrorHandler in //device/serial to callbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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_sender.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 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 DataReceiver::DataReceiver( 110 DataReceiver::DataReceiver(
111 mojo::InterfacePtr<serial::DataSource> source, 111 mojo::InterfacePtr<serial::DataSource> source,
112 mojo::InterfaceRequest<serial::DataSourceClient> client, 112 mojo::InterfaceRequest<serial::DataSourceClient> client,
113 uint32_t buffer_size, 113 uint32_t buffer_size,
114 int32_t fatal_error_value) 114 int32_t fatal_error_value)
115 : source_(source.Pass()), 115 : source_(source.Pass()),
116 client_(this, client.Pass()), 116 client_(this, client.Pass()),
117 fatal_error_value_(fatal_error_value), 117 fatal_error_value_(fatal_error_value),
118 shut_down_(false), 118 shut_down_(false),
119 weak_factory_(this) { 119 weak_factory_(this) {
120 source_.set_error_handler(this); 120 source_.set_connection_error_handler(
121 base::Bind(&DataReceiver::OnConnectionError, base::Unretained(this)));
121 source_->Init(buffer_size); 122 source_->Init(buffer_size);
122 client_.set_error_handler(this); 123 client_.set_connection_error_handler(
124 base::Bind(&DataReceiver::OnConnectionError, base::Unretained(this)));
123 } 125 }
124 126
125 bool DataReceiver::Receive(const ReceiveDataCallback& callback, 127 bool DataReceiver::Receive(const ReceiveDataCallback& callback,
126 const ReceiveErrorCallback& error_callback) { 128 const ReceiveErrorCallback& error_callback) {
127 DCHECK(!callback.is_null() && !error_callback.is_null()); 129 DCHECK(!callback.is_null() && !error_callback.is_null());
128 if (pending_receive_ || shut_down_) 130 if (pending_receive_ || shut_down_)
129 return false; 131 return false;
130 // When the DataSource encounters an error, it pauses transmission. When the 132 // When the DataSource encounters an error, it pauses transmission. When the
131 // user starts a new receive following notification of the error (via 133 // user starts a new receive following notification of the error (via
132 // |error_callback| of the previous Receive call) of the error we can tell the 134 // |error_callback| of the previous Receive call) of the error we can tell the
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 buffer_size_ = 0; 281 buffer_size_ = 0;
280 } 282 }
281 283
282 void DataReceiver::PendingReceive::Buffer::DoneWithError( 284 void DataReceiver::PendingReceive::Buffer::DoneWithError(
283 uint32_t bytes_consumed, 285 uint32_t bytes_consumed,
284 int32_t error) { 286 int32_t error) {
285 Done(bytes_consumed); 287 Done(bytes_consumed);
286 } 288 }
287 289
288 } // namespace device 290 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/data_receiver.h ('k') | device/serial/data_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698