Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: tools/battor_agent/battor_connection_impl.cc

Issue 2217513002: [battor_agent] Clear pending read buffer if it contains an irrevocable error. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698