Chromium Code Reviews| 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_agent.h" | 5 #include "tools/battor_agent/battor_agent.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 } | 152 } |
| 153 | 153 |
| 154 void BattOrAgent::RecordClockSyncMarker(const std::string& marker) { | 154 void BattOrAgent::RecordClockSyncMarker(const std::string& marker) { |
| 155 DCHECK(thread_checker_.CalledOnValidThread()); | 155 DCHECK(thread_checker_.CalledOnValidThread()); |
| 156 | 156 |
| 157 command_ = Command::RECORD_CLOCK_SYNC_MARKER; | 157 command_ = Command::RECORD_CLOCK_SYNC_MARKER; |
| 158 pending_clock_sync_marker_ = marker; | 158 pending_clock_sync_marker_ = marker; |
| 159 PerformAction(Action::REQUEST_CONNECTION); | 159 PerformAction(Action::REQUEST_CONNECTION); |
| 160 } | 160 } |
| 161 | 161 |
| 162 int BattOrAgent::Version() { | |
| 163 DCHECK(thread_checker_.CalledOnValidThread()); | |
|
charliea (OOO until 10-5)
2016/10/04 15:15:48
So after you make this look like:
void BattOrAgen
| |
| 164 return 1; // Actually return here. | |
| 165 return battor_eeprom_->version; | |
| 166 } | |
| 167 | |
| 162 void BattOrAgent::BeginConnect() { | 168 void BattOrAgent::BeginConnect() { |
| 163 DCHECK(thread_checker_.CalledOnValidThread()); | 169 DCHECK(thread_checker_.CalledOnValidThread()); |
| 164 | 170 |
| 165 connection_->Open(); | 171 connection_->Open(); |
| 166 } | 172 } |
| 167 | 173 |
| 168 void BattOrAgent::OnConnectionOpened(bool success) { | 174 void BattOrAgent::OnConnectionOpened(bool success) { |
| 169 // Return immediately if opening the connection already timed out. | 175 // Return immediately if opening the connection already timed out. |
| 170 if (timeout_callback_.IsCancelled()) | 176 if (timeout_callback_.IsCancelled()) |
| 171 return; | 177 return; |
| 172 timeout_callback_.Cancel(); | 178 timeout_callback_.Cancel(); |
| 173 | 179 |
| 174 if (!success) { | 180 if (!success) { |
| 175 CompleteCommand(BATTOR_ERROR_CONNECTION_FAILED); | 181 CompleteCommand(BATTOR_ERROR_CONNECTION_FAILED); |
| 176 return; | 182 return; |
| 177 } | 183 } |
| 178 | 184 |
| 179 switch (command_) { | 185 switch (command_) { |
| 180 case Command::START_TRACING: | 186 case Command::START_TRACING: |
| 181 num_init_attempts_ = 1; | 187 num_init_attempts_ = 1; |
| 182 PerformAction(Action::SEND_INIT); | 188 PerformAction(Action::SEND_INIT); |
| 183 return; | 189 return; |
| 184 case Command::STOP_TRACING: | 190 case Command::STOP_TRACING: |
| 185 PerformAction(Action::SEND_EEPROM_REQUEST); | 191 PerformAction(Action::SEND_EEPROM_REQUEST); |
| 186 return; | 192 return; |
| 187 case Command::RECORD_CLOCK_SYNC_MARKER: | 193 case Command::RECORD_CLOCK_SYNC_MARKER: |
| 188 PerformAction(Action::SEND_CURRENT_SAMPLE_REQUEST); | 194 PerformAction(Action::SEND_CURRENT_SAMPLE_REQUEST); |
| 189 return; | 195 return; |
| 196 case Command::VERSION: | |
| 197 return; | |
| 190 case Command::INVALID: | 198 case Command::INVALID: |
| 191 NOTREACHED(); | 199 NOTREACHED(); |
| 192 } | 200 } |
| 193 } | 201 } |
| 194 | 202 |
| 195 void BattOrAgent::OnBytesSent(bool success) { | 203 void BattOrAgent::OnBytesSent(bool success) { |
| 196 DCHECK(thread_checker_.CalledOnValidThread()); | 204 DCHECK(thread_checker_.CalledOnValidThread()); |
| 197 | 205 |
| 198 // Return immediately if whatever action we were trying to perform already | 206 // Return immediately if whatever action we were trying to perform already |
| 199 // timed out. | 207 // timed out. |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 base::ThreadTaskRunnerHandle::Get()->PostTask( | 531 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 524 FROM_HERE, | 532 FROM_HERE, |
| 525 base::Bind(&Listener::OnStopTracingComplete, | 533 base::Bind(&Listener::OnStopTracingComplete, |
| 526 base::Unretained(listener_), SamplesToString(), error)); | 534 base::Unretained(listener_), SamplesToString(), error)); |
| 527 break; | 535 break; |
| 528 case Command::RECORD_CLOCK_SYNC_MARKER: | 536 case Command::RECORD_CLOCK_SYNC_MARKER: |
| 529 base::ThreadTaskRunnerHandle::Get()->PostTask( | 537 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 530 FROM_HERE, base::Bind(&Listener::OnRecordClockSyncMarkerComplete, | 538 FROM_HERE, base::Bind(&Listener::OnRecordClockSyncMarkerComplete, |
| 531 base::Unretained(listener_), error)); | 539 base::Unretained(listener_), error)); |
| 532 break; | 540 break; |
| 541 case Command::VERSION: | |
| 542 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
| 543 FROM_HERE, base::Bind(&Listener::OnGetVersionComplete, | |
| 544 base::Unretained(listener_), error)); | |
| 533 case Command::INVALID: | 545 case Command::INVALID: |
| 534 NOTREACHED(); | 546 NOTREACHED(); |
| 535 } | 547 } |
| 536 | 548 |
| 537 last_action_ = Action::INVALID; | 549 last_action_ = Action::INVALID; |
| 538 command_ = Command::INVALID; | 550 command_ = Command::INVALID; |
| 539 pending_clock_sync_marker_.clear(); | 551 pending_clock_sync_marker_.clear(); |
| 540 battor_eeprom_.reset(); | 552 battor_eeprom_.reset(); |
| 541 calibration_frame_.clear(); | 553 calibration_frame_.clear(); |
| 542 samples_.clear(); | 554 samples_.clear(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 if (clock_sync_marker != clock_sync_markers_.end()) | 589 if (clock_sync_marker != clock_sync_markers_.end()) |
| 578 trace_stream << " <" << clock_sync_marker->second << ">"; | 590 trace_stream << " <" << clock_sync_marker->second << ">"; |
| 579 | 591 |
| 580 trace_stream << std::endl; | 592 trace_stream << std::endl; |
| 581 } | 593 } |
| 582 | 594 |
| 583 return trace_stream.str(); | 595 return trace_stream.str(); |
| 584 } | 596 } |
| 585 | 597 |
| 586 } // namespace battor | 598 } // namespace battor |
| OLD | NEW |