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

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

Issue 2622003005: [BattOr] Initialize BattOr before getting firmware git hash. (Closed)
Patch Set: fix spelling Created 3 years, 11 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 | tools/battor_agent/battor_agent_unittest.cc » ('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 #include "tools/battor_agent/battor_agent.h" 4 #include "tools/battor_agent/battor_agent.h"
5 5
6 #include <iomanip> 6 #include <iomanip>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "tools/battor_agent/battor_connection_impl.h" 10 #include "tools/battor_agent/battor_connection_impl.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 num_init_attempts_ = 1; 191 num_init_attempts_ = 1;
192 PerformAction(Action::SEND_INIT); 192 PerformAction(Action::SEND_INIT);
193 return; 193 return;
194 case Command::STOP_TRACING: 194 case Command::STOP_TRACING:
195 PerformAction(Action::SEND_EEPROM_REQUEST); 195 PerformAction(Action::SEND_EEPROM_REQUEST);
196 return; 196 return;
197 case Command::RECORD_CLOCK_SYNC_MARKER: 197 case Command::RECORD_CLOCK_SYNC_MARKER:
198 PerformAction(Action::SEND_CURRENT_SAMPLE_REQUEST); 198 PerformAction(Action::SEND_CURRENT_SAMPLE_REQUEST);
199 return; 199 return;
200 case Command::GET_FIRMWARE_GIT_HASH: 200 case Command::GET_FIRMWARE_GIT_HASH:
201 PerformAction(Action::SEND_GIT_HASH_REQUEST); 201 num_init_attempts_ = 1;
202 PerformAction(Action::SEND_INIT);
202 return; 203 return;
203 case Command::INVALID: 204 case Command::INVALID:
204 NOTREACHED(); 205 NOTREACHED();
205 } 206 }
206 } 207 }
207 208
208 void BattOrAgent::OnBytesSent(bool success) { 209 void BattOrAgent::OnBytesSent(bool success) {
209 DCHECK(thread_checker_.CalledOnValidThread()); 210 DCHECK(thread_checker_.CalledOnValidThread());
210 211
211 // Return immediately if whatever action we were trying to perform already 212 // Return immediately if whatever action we were trying to perform already
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 if (num_init_attempts_++ < kMaxInitAttempts) { 311 if (num_init_attempts_++ < kMaxInitAttempts) {
311 PerformDelayedAction(Action::SEND_INIT, 312 PerformDelayedAction(Action::SEND_INIT,
312 base::TimeDelta::FromMilliseconds(kInitRetryDelayMilliseconds)); 313 base::TimeDelta::FromMilliseconds(kInitRetryDelayMilliseconds));
313 } else { 314 } else {
314 CompleteCommand(BATTOR_ERROR_TOO_MANY_INIT_RETRIES); 315 CompleteCommand(BATTOR_ERROR_TOO_MANY_INIT_RETRIES);
315 } 316 }
316 317
317 return; 318 return;
318 } 319 }
319 320
320 PerformAction(Action::SEND_SET_GAIN); 321 switch (command_) {
321 return; 322 case Command::START_TRACING:
323 PerformAction(Action::SEND_SET_GAIN);
324 return;
325 case Command::GET_FIRMWARE_GIT_HASH:
326 PerformAction(Action::SEND_GIT_HASH_REQUEST);
327 return;
328 default:
329 CompleteCommand(BATTOR_ERROR_UNEXPECTED_MESSAGE);
330 return;
331 }
322 332
323 case Action::READ_SET_GAIN_ACK: 333 case Action::READ_SET_GAIN_ACK:
324 if (!IsAckOfControlCommand(type, BATTOR_CONTROL_MESSAGE_TYPE_SET_GAIN, 334 if (!IsAckOfControlCommand(type, BATTOR_CONTROL_MESSAGE_TYPE_SET_GAIN,
325 *bytes)) { 335 *bytes)) {
326 CompleteCommand(BATTOR_ERROR_UNEXPECTED_MESSAGE); 336 CompleteCommand(BATTOR_ERROR_UNEXPECTED_MESSAGE);
327 return; 337 return;
328 } 338 }
329 339
330 PerformAction(Action::SEND_START_TRACING); 340 PerformAction(Action::SEND_START_TRACING);
331 return; 341 return;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 if (clock_sync_marker != clock_sync_markers_.end()) 661 if (clock_sync_marker != clock_sync_markers_.end())
652 trace_stream << " <" << clock_sync_marker->second << ">"; 662 trace_stream << " <" << clock_sync_marker->second << ">";
653 663
654 trace_stream << std::endl; 664 trace_stream << std::endl;
655 } 665 }
656 666
657 return trace_stream.str(); 667 return trace_stream.str();
658 } 668 }
659 669
660 } // namespace battor 670 } // namespace battor
OLDNEW
« no previous file with comments | « no previous file | tools/battor_agent/battor_agent_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698