| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "tools/battor_agent/battor_connection_impl.h" | 5 #include "tools/battor_agent/battor_connection_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 if (!serial_log_path.empty()) { | 73 if (!serial_log_path.empty()) { |
| 74 serial_log_.open(serial_log_path.c_str(), | 74 serial_log_.open(serial_log_path.c_str(), |
| 75 std::fstream::out | std::fstream::trunc); | 75 std::fstream::out | std::fstream::trunc); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 BattOrConnectionImpl::~BattOrConnectionImpl() {} | 79 BattOrConnectionImpl::~BattOrConnectionImpl() {} |
| 80 | 80 |
| 81 void BattOrConnectionImpl::Open() { | 81 void BattOrConnectionImpl::Open() { |
| 82 if (io_handler_) { | 82 if (io_handler_) { |
| 83 // Opening new connection so flush serial data from old connection. |
| 84 Flush(); |
| 83 OnOpened(true); | 85 OnOpened(true); |
| 84 return; | 86 return; |
| 85 } | 87 } |
| 86 | 88 |
| 87 io_handler_ = CreateIoHandler(); | 89 io_handler_ = CreateIoHandler(); |
| 88 | 90 |
| 89 device::serial::ConnectionOptions options; | 91 device::serial::ConnectionOptions options; |
| 90 options.bitrate = kBattOrBitrate; | 92 options.bitrate = kBattOrBitrate; |
| 91 options.data_bits = kBattOrDataBits; | 93 options.data_bits = kBattOrDataBits; |
| 92 options.parity_bit = kBattOrParityBit; | 94 options.parity_bit = kBattOrParityBit; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 base::ThreadTaskRunnerHandle::Get()->PostTask( | 354 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 353 FROM_HERE, | 355 FROM_HERE, |
| 354 base::Bind(&Listener::OnBytesSent, base::Unretained(listener_), success)); | 356 base::Bind(&Listener::OnBytesSent, base::Unretained(listener_), success)); |
| 355 } | 357 } |
| 356 | 358 |
| 357 void BattOrConnectionImpl::LogSerial(const std::string& str) { | 359 void BattOrConnectionImpl::LogSerial(const std::string& str) { |
| 358 serial_log_ << str << std::endl << std::endl; | 360 serial_log_ << str << std::endl << std::endl; |
| 359 } | 361 } |
| 360 | 362 |
| 361 } // namespace battor | 363 } // namespace battor |
| OLD | NEW |