| 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 "extensions/browser/api/serial/serial_connection.h" | 5 #include "extensions/browser/api/serial/serial_connection.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 357 |
| 358 void SerialConnection::OnAsyncReadComplete(int bytes_read, | 358 void SerialConnection::OnAsyncReadComplete(int bytes_read, |
| 359 device::serial::ReceiveError error) { | 359 device::serial::ReceiveError error) { |
| 360 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 360 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 361 DCHECK(!receive_complete_.is_null()); | 361 DCHECK(!receive_complete_.is_null()); |
| 362 ReceiveCompleteCallback callback = receive_complete_; | 362 ReceiveCompleteCallback callback = receive_complete_; |
| 363 receive_complete_.Reset(); | 363 receive_complete_.Reset(); |
| 364 receive_timeout_task_.reset(); | 364 receive_timeout_task_.reset(); |
| 365 callback.Run(std::string(receive_buffer_->data(), bytes_read), | 365 callback.Run(std::string(receive_buffer_->data(), bytes_read), |
| 366 ConvertReceiveErrorFromMojo(error)); | 366 ConvertReceiveErrorFromMojo(error)); |
| 367 receive_buffer_ = NULL; | 367 receive_buffer_ = nullptr; |
| 368 } | 368 } |
| 369 | 369 |
| 370 void SerialConnection::OnAsyncWriteComplete(int bytes_sent, | 370 void SerialConnection::OnAsyncWriteComplete(int bytes_sent, |
| 371 device::serial::SendError error) { | 371 device::serial::SendError error) { |
| 372 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 372 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 373 DCHECK(!send_complete_.is_null()); | 373 DCHECK(!send_complete_.is_null()); |
| 374 SendCompleteCallback callback = send_complete_; | 374 SendCompleteCallback callback = send_complete_; |
| 375 send_complete_.Reset(); | 375 send_complete_.Reset(); |
| 376 send_timeout_task_.reset(); | 376 send_timeout_task_.reset(); |
| 377 callback.Run(bytes_sent, ConvertSendErrorFromMojo(error)); | 377 callback.Run(bytes_sent, ConvertSendErrorFromMojo(error)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 output->parity_bit = extensions::ConvertParityBitToMojo(input.parity_bit); | 428 output->parity_bit = extensions::ConvertParityBitToMojo(input.parity_bit); |
| 429 output->stop_bits = extensions::ConvertStopBitsToMojo(input.stop_bits); | 429 output->stop_bits = extensions::ConvertStopBitsToMojo(input.stop_bits); |
| 430 if (input.cts_flow_control.get()) { | 430 if (input.cts_flow_control.get()) { |
| 431 output->has_cts_flow_control = true; | 431 output->has_cts_flow_control = true; |
| 432 output->cts_flow_control = *input.cts_flow_control; | 432 output->cts_flow_control = *input.cts_flow_control; |
| 433 } | 433 } |
| 434 return output.Pass(); | 434 return output.Pass(); |
| 435 } | 435 } |
| 436 | 436 |
| 437 } // namespace mojo | 437 } // namespace mojo |
| OLD | NEW |