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

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

Issue 1991403002: [battor agent] Fix the init sequence so it retries inits instead of resets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comment Created 4 years, 6 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 | « tools/battor_agent/battor_connection_impl.h ('k') | tools/battor_agent/battor_error.h » ('j') | 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 "the 'already read' buffer had an irrecoverable error with code: %d.", 174 "the 'already read' buffer had an irrecoverable error with code: %d.",
175 parse_message_error)); 175 parse_message_error));
176 EndReadBytes(false, BATTOR_MESSAGE_TYPE_CONTROL, nullptr); 176 EndReadBytes(false, BATTOR_MESSAGE_TYPE_CONTROL, nullptr);
177 return; 177 return;
178 } 178 }
179 179
180 LogSerial("No complete message found in the 'already read' buffer."); 180 LogSerial("No complete message found in the 'already read' buffer.");
181 BeginReadBytes(message_max_bytes - already_read_buffer_.size()); 181 BeginReadBytes(message_max_bytes - already_read_buffer_.size());
182 } 182 }
183 183
184 void BattOrConnectionImpl::CancelReadMessage() {
185 io_handler_->CancelRead(device::serial::ReceiveError::TIMEOUT);
186 }
187
184 void BattOrConnectionImpl::Flush() { 188 void BattOrConnectionImpl::Flush() {
185 io_handler_->Flush(); 189 io_handler_->Flush();
186 already_read_buffer_.clear(); 190 already_read_buffer_.clear();
187 } 191 }
188 192
189 scoped_refptr<device::SerialIoHandler> BattOrConnectionImpl::CreateIoHandler() { 193 scoped_refptr<device::SerialIoHandler> BattOrConnectionImpl::CreateIoHandler() {
190 return device::SerialIoHandler::Create(file_thread_task_runner_, 194 return device::SerialIoHandler::Create(file_thread_task_runner_,
191 ui_thread_task_runner_); 195 ui_thread_task_runner_);
192 } 196 }
193 197
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 base::ThreadTaskRunnerHandle::Get()->PostTask( 344 base::ThreadTaskRunnerHandle::Get()->PostTask(
341 FROM_HERE, 345 FROM_HERE,
342 base::Bind(&Listener::OnBytesSent, base::Unretained(listener_), success)); 346 base::Bind(&Listener::OnBytesSent, base::Unretained(listener_), success));
343 } 347 }
344 348
345 void BattOrConnectionImpl::LogSerial(const std::string& str) { 349 void BattOrConnectionImpl::LogSerial(const std::string& str) {
346 serial_log_ << str << std::endl << std::endl; 350 serial_log_ << str << std::endl << std::endl;
347 } 351 }
348 352
349 } // namespace battor 353 } // namespace battor
OLDNEW
« no previous file with comments | « tools/battor_agent/battor_connection_impl.h ('k') | tools/battor_agent/battor_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698