| 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 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/location.h" |
| 12 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/message_loop/message_loop.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "device/serial/buffer.h" | 16 #include "device/serial/buffer.h" |
| 15 #include "extensions/browser/api/api_resource_manager.h" | 17 #include "extensions/browser/api/api_resource_manager.h" |
| 16 #include "extensions/common/api/serial.h" | 18 #include "extensions/common/api/serial.h" |
| 17 | 19 |
| 18 namespace extensions { | 20 namespace extensions { |
| 19 | 21 |
| 20 namespace { | 22 namespace { |
| 21 | 23 |
| 22 const int kDefaultBufferSize = 4096; | 24 const int kDefaultBufferSize = 4096; |
| 23 | 25 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 DCHECK(!send_complete_.is_null()); | 359 DCHECK(!send_complete_.is_null()); |
| 358 SendCompleteCallback callback = send_complete_; | 360 SendCompleteCallback callback = send_complete_; |
| 359 send_complete_.Reset(); | 361 send_complete_.Reset(); |
| 360 send_timeout_task_.reset(); | 362 send_timeout_task_.reset(); |
| 361 callback.Run(bytes_sent, ConvertSendErrorFromMojo(error)); | 363 callback.Run(bytes_sent, ConvertSendErrorFromMojo(error)); |
| 362 } | 364 } |
| 363 | 365 |
| 364 SerialConnection::TimeoutTask::TimeoutTask(const base::Closure& closure, | 366 SerialConnection::TimeoutTask::TimeoutTask(const base::Closure& closure, |
| 365 const base::TimeDelta& delay) | 367 const base::TimeDelta& delay) |
| 366 : closure_(closure), delay_(delay), weak_factory_(this) { | 368 : closure_(closure), delay_(delay), weak_factory_(this) { |
| 367 base::MessageLoop::current()->PostDelayedTask( | 369 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 368 FROM_HERE, | 370 FROM_HERE, base::Bind(&TimeoutTask::Run, weak_factory_.GetWeakPtr()), |
| 369 base::Bind(&TimeoutTask::Run, weak_factory_.GetWeakPtr()), | |
| 370 delay_); | 371 delay_); |
| 371 } | 372 } |
| 372 | 373 |
| 373 SerialConnection::TimeoutTask::~TimeoutTask() { | 374 SerialConnection::TimeoutTask::~TimeoutTask() { |
| 374 } | 375 } |
| 375 | 376 |
| 376 void SerialConnection::TimeoutTask::Run() const { | 377 void SerialConnection::TimeoutTask::Run() const { |
| 377 closure_.Run(); | 378 closure_.Run(); |
| 378 } | 379 } |
| 379 | 380 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 output->parity_bit = extensions::ConvertParityBitToMojo(input.parity_bit); | 413 output->parity_bit = extensions::ConvertParityBitToMojo(input.parity_bit); |
| 413 output->stop_bits = extensions::ConvertStopBitsToMojo(input.stop_bits); | 414 output->stop_bits = extensions::ConvertStopBitsToMojo(input.stop_bits); |
| 414 if (input.cts_flow_control.get()) { | 415 if (input.cts_flow_control.get()) { |
| 415 output->has_cts_flow_control = true; | 416 output->has_cts_flow_control = true; |
| 416 output->cts_flow_control = *input.cts_flow_control; | 417 output->cts_flow_control = *input.cts_flow_control; |
| 417 } | 418 } |
| 418 return output; | 419 return output; |
| 419 } | 420 } |
| 420 | 421 |
| 421 } // namespace mojo | 422 } // namespace mojo |
| OLD | NEW |