| 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_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 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 const ErrorCallback& error_callback) | 78 const ErrorCallback& error_callback) |
| 79 : binding_(this, source.Pass()), | 79 : binding_(this, source.Pass()), |
| 80 client_(client.Pass()), | 80 client_(client.Pass()), |
| 81 ready_callback_(ready_callback), | 81 ready_callback_(ready_callback), |
| 82 error_callback_(error_callback), | 82 error_callback_(error_callback), |
| 83 available_buffer_capacity_(0), | 83 available_buffer_capacity_(0), |
| 84 paused_(false), | 84 paused_(false), |
| 85 shut_down_(false), | 85 shut_down_(false), |
| 86 weak_factory_(this) { | 86 weak_factory_(this) { |
| 87 DCHECK(!ready_callback.is_null() && !error_callback.is_null()); | 87 DCHECK(!ready_callback.is_null() && !error_callback.is_null()); |
| 88 binding_.set_error_handler(this); | 88 binding_.set_connection_error_handler( |
| 89 client_.set_error_handler(this); | 89 base::Bind(&DataSourceSender::OnConnectionError, base::Unretained(this))); |
| 90 client_.set_connection_error_handler( |
| 91 base::Bind(&DataSourceSender::OnConnectionError, base::Unretained(this))); |
| 90 } | 92 } |
| 91 | 93 |
| 92 void DataSourceSender::ShutDown() { | 94 void DataSourceSender::ShutDown() { |
| 93 shut_down_ = true; | 95 shut_down_ = true; |
| 94 ready_callback_.Reset(); | 96 ready_callback_.Reset(); |
| 95 error_callback_.Reset(); | 97 error_callback_.Reset(); |
| 96 } | 98 } |
| 97 | 99 |
| 98 DataSourceSender::~DataSourceSender() { | 100 DataSourceSender::~DataSourceSender() { |
| 99 DCHECK(shut_down_); | 101 DCHECK(shut_down_); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 uint32_t bytes_written, | 242 uint32_t bytes_written, |
| 241 int32_t error) { | 243 int32_t error) { |
| 242 DCHECK(sender_.get()); | 244 DCHECK(sender_.get()); |
| 243 PendingSend* send = pending_send_; | 245 PendingSend* send = pending_send_; |
| 244 pending_send_ = nullptr; | 246 pending_send_ = nullptr; |
| 245 send->DoneWithError(bytes_written, error); | 247 send->DoneWithError(bytes_written, error); |
| 246 sender_ = nullptr; | 248 sender_ = nullptr; |
| 247 } | 249 } |
| 248 | 250 |
| 249 } // namespace device | 251 } // namespace device |
| OLD | NEW |