| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 return; | 251 return; |
| 252 } | 252 } |
| 253 | 253 |
| 254 LogSerial("(Message still incomplete: reading more bytes.)"); | 254 LogSerial("(Message still incomplete: reading more bytes.)"); |
| 255 BeginReadBytes(message_max_bytes - already_read_buffer_.size()); | 255 BeginReadBytes(message_max_bytes - already_read_buffer_.size()); |
| 256 return; | 256 return; |
| 257 } | 257 } |
| 258 | 258 |
| 259 if (parse_message_error != ParseMessageError::NONE) { | 259 if (parse_message_error != ParseMessageError::NONE) { |
| 260 LogSerial(StringPrintf( | 260 LogSerial(StringPrintf( |
| 261 "Read failed due to the message containing an irrecoverable error: %d.", | 261 "Read failed due to the message containing an irrecoverable error: %d, " |
| 262 "clearing the pending read buffer.", |
| 262 parse_message_error)); | 263 parse_message_error)); |
| 264 already_read_buffer_.clear(); |
| 263 EndReadBytes(false, BATTOR_MESSAGE_TYPE_CONTROL, nullptr); | 265 EndReadBytes(false, BATTOR_MESSAGE_TYPE_CONTROL, nullptr); |
| 264 return; | 266 return; |
| 265 } | 267 } |
| 266 | 268 |
| 267 if (type != pending_read_message_type_) { | 269 if (type != pending_read_message_type_) { |
| 268 LogSerial("Read failed due to receiving a message of the wrong type."); | 270 LogSerial("Read failed due to receiving a message of the wrong type."); |
| 269 EndReadBytes(false, BATTOR_MESSAGE_TYPE_CONTROL, nullptr); | 271 EndReadBytes(false, BATTOR_MESSAGE_TYPE_CONTROL, nullptr); |
| 270 return; | 272 return; |
| 271 } | 273 } |
| 272 | 274 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 base::ThreadTaskRunnerHandle::Get()->PostTask( | 346 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 345 FROM_HERE, | 347 FROM_HERE, |
| 346 base::Bind(&Listener::OnBytesSent, base::Unretained(listener_), success)); | 348 base::Bind(&Listener::OnBytesSent, base::Unretained(listener_), success)); |
| 347 } | 349 } |
| 348 | 350 |
| 349 void BattOrConnectionImpl::LogSerial(const std::string& str) { | 351 void BattOrConnectionImpl::LogSerial(const std::string& str) { |
| 350 serial_log_ << str << std::endl << std::endl; | 352 serial_log_ << str << std::endl << std::endl; |
| 351 } | 353 } |
| 352 | 354 |
| 353 } // namespace battor | 355 } // namespace battor |
| OLD | NEW |