OLD | NEW |
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_sink_receiver.h" | 5 #include "device/serial/data_sink_receiver.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 mojo::Array<uint8_t> data_; | 65 mojo::Array<uint8_t> data_; |
66 uint32_t offset_; | 66 uint32_t offset_; |
67 const mojo::Callback<void(uint32_t, int32_t)> callback_; | 67 const mojo::Callback<void(uint32_t, int32_t)> callback_; |
68 }; | 68 }; |
69 | 69 |
70 DataSinkReceiver::DataSinkReceiver( | 70 DataSinkReceiver::DataSinkReceiver( |
71 mojo::InterfaceRequest<serial::DataSink> request, | 71 mojo::InterfaceRequest<serial::DataSink> request, |
72 const ReadyCallback& ready_callback, | 72 const ReadyCallback& ready_callback, |
73 const CancelCallback& cancel_callback, | 73 const CancelCallback& cancel_callback, |
74 const ErrorCallback& error_callback) | 74 const ErrorCallback& error_callback) |
75 : binding_(this, std::move(request)), | 75 : ready_callback_(ready_callback), |
76 ready_callback_(ready_callback), | |
77 cancel_callback_(cancel_callback), | 76 cancel_callback_(cancel_callback), |
78 error_callback_(error_callback), | 77 error_callback_(error_callback), |
79 current_error_(0), | 78 current_error_(0), |
80 buffer_in_use_(NULL), | 79 buffer_in_use_(NULL), |
81 shut_down_(false), | 80 shut_down_(false), |
| 81 binding_(this, std::move(request)), |
82 weak_factory_(this) { | 82 weak_factory_(this) { |
83 binding_.set_connection_error_handler( | 83 binding_.set_connection_error_handler( |
84 base::Bind(&DataSinkReceiver::OnConnectionError, base::Unretained(this))); | 84 base::Bind(&DataSinkReceiver::OnConnectionError, base::Unretained(this))); |
85 } | 85 } |
86 | 86 |
87 void DataSinkReceiver::ShutDown() { | 87 void DataSinkReceiver::ShutDown() { |
88 shut_down_ = true; | 88 shut_down_ = true; |
89 } | 89 } |
90 | 90 |
91 DataSinkReceiver::~DataSinkReceiver() { | 91 DataSinkReceiver::~DataSinkReceiver() { |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 callback_.Run(offset_, 0); | 277 callback_.Run(offset_, 0); |
278 } | 278 } |
279 void DataSinkReceiver::DataFrame::ReportError(uint32_t bytes_read, | 279 void DataSinkReceiver::DataFrame::ReportError(uint32_t bytes_read, |
280 int32_t error) { | 280 int32_t error) { |
281 offset_ += bytes_read; | 281 offset_ += bytes_read; |
282 DCHECK_LE(offset_, data_.size()); | 282 DCHECK_LE(offset_, data_.size()); |
283 callback_.Run(offset_, error); | 283 callback_.Run(offset_, error); |
284 } | 284 } |
285 | 285 |
286 } // namespace device | 286 } // namespace device |
OLD | NEW |