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 #ifndef TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_ | 5 #ifndef TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_ |
6 #define TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_ | 6 #define TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 // Returns whether the BattOr is able to record clock sync markers in its own | 59 // Returns whether the BattOr is able to record clock sync markers in its own |
60 // trace log. | 60 // trace log. |
61 static bool SupportsExplicitClockSync() { return true; } | 61 static bool SupportsExplicitClockSync() { return true; } |
62 | 62 |
63 // BattOrConnection::Listener implementation. | 63 // BattOrConnection::Listener implementation. |
64 void OnConnectionOpened(bool success) override; | 64 void OnConnectionOpened(bool success) override; |
65 void OnBytesSent(bool success) override; | 65 void OnBytesSent(bool success) override; |
66 void OnMessageRead(bool success, | 66 void OnMessageRead(bool success, |
67 BattOrMessageType type, | 67 BattOrMessageType type, |
68 scoped_ptr<std::vector<char>> bytes) override; | 68 std::unique_ptr<std::vector<char>> bytes) override; |
69 | 69 |
70 protected: | 70 protected: |
71 // The connection that knows how to communicate with the BattOr in terms of | 71 // The connection that knows how to communicate with the BattOr in terms of |
72 // protocol primitives. This is protected so that it can be replaced with a | 72 // protocol primitives. This is protected so that it can be replaced with a |
73 // fake in testing. | 73 // fake in testing. |
74 scoped_ptr<BattOrConnection> connection_; | 74 std::unique_ptr<BattOrConnection> connection_; |
75 | 75 |
76 // Timeout for when an action isn't completed within the allotted time. This | 76 // Timeout for when an action isn't completed within the allotted time. This |
77 // is virtual and protected so that timeouts can be disabled in testing. The | 77 // is virtual and protected so that timeouts can be disabled in testing. The |
78 // testing task runner that runs delayed tasks immediately deals poorly with | 78 // testing task runner that runs delayed tasks immediately deals poorly with |
79 // timeouts posted as future tasks. | 79 // timeouts posted as future tasks. |
80 virtual void OnActionTimeout(); | 80 virtual void OnActionTimeout(); |
81 | 81 |
82 private: | 82 private: |
83 enum class Command { | 83 enum class Command { |
84 INVALID, | 84 INVALID, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // The clock sync marker being recorded (if we're currently recording one). | 154 // The clock sync marker being recorded (if we're currently recording one). |
155 std::string pending_clock_sync_marker_; | 155 std::string pending_clock_sync_marker_; |
156 | 156 |
157 // The time at which the last clock sync marker was recorded. | 157 // The time at which the last clock sync marker was recorded. |
158 base::TimeTicks last_clock_sync_time_; | 158 base::TimeTicks last_clock_sync_time_; |
159 | 159 |
160 // Checker to make sure that this is only ever called on the IO thread. | 160 // Checker to make sure that this is only ever called on the IO thread. |
161 base::ThreadChecker thread_checker_; | 161 base::ThreadChecker thread_checker_; |
162 | 162 |
163 // The BattOr's EEPROM (which is required for calibration). | 163 // The BattOr's EEPROM (which is required for calibration). |
164 scoped_ptr<BattOrEEPROM> battor_eeprom_; | 164 std::unique_ptr<BattOrEEPROM> battor_eeprom_; |
165 | 165 |
166 // The first frame (required for calibration). | 166 // The first frame (required for calibration). |
167 std::vector<RawBattOrSample> calibration_frame_; | 167 std::vector<RawBattOrSample> calibration_frame_; |
168 | 168 |
169 // The actual data samples recorded. | 169 // The actual data samples recorded. |
170 std::vector<RawBattOrSample> samples_; | 170 std::vector<RawBattOrSample> samples_; |
171 | 171 |
172 // The expected sequence number of the next frame. We use this to ensure that | 172 // The expected sequence number of the next frame. We use this to ensure that |
173 // we receive frames in order. | 173 // we receive frames in order. |
174 uint32_t next_sequence_number_; | 174 uint32_t next_sequence_number_; |
175 | 175 |
176 // The number of times that we've attempted to read the last message. | 176 // The number of times that we've attempted to read the last message. |
177 uint8_t num_read_attempts_; | 177 uint8_t num_read_attempts_; |
178 | 178 |
179 // The timeout that's run when an action times out. | 179 // The timeout that's run when an action times out. |
180 base::CancelableClosure timeout_callback_; | 180 base::CancelableClosure timeout_callback_; |
181 | 181 |
182 DISALLOW_COPY_AND_ASSIGN(BattOrAgent); | 182 DISALLOW_COPY_AND_ASSIGN(BattOrAgent); |
183 }; | 183 }; |
184 | 184 |
185 } // namespace battor | 185 } // namespace battor |
186 | 186 |
187 #endif // TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_ | 187 #endif // TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_ |
OLD | NEW |