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

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

Issue 2000743002: [battor agent] Add 'read more bytes' logic in the BattOr connection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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_connection_impl.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 4
5 #ifndef TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_ 5 #ifndef TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_
6 #define TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_ 6 #define TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_
7 7
8 #include <fstream> 8 #include <fstream>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 // Internal callback for when bytes are read. This method may trigger 63 // Internal callback for when bytes are read. This method may trigger
64 // additional reads if any newly read bytes are escape bytes. 64 // additional reads if any newly read bytes are escape bytes.
65 void OnBytesRead(int bytes_read, device::serial::ReceiveError error); 65 void OnBytesRead(int bytes_read, device::serial::ReceiveError error);
66 66
67 void EndReadBytes(bool success, 67 void EndReadBytes(bool success,
68 BattOrMessageType type, 68 BattOrMessageType type,
69 std::unique_ptr<std::vector<char>> data); 69 std::unique_ptr<std::vector<char>> data);
70 70
71 // Pulls off the next complete message from already_read_buffer_, returning 71 // Pulls off the next complete message from already_read_buffer_, returning
72 // its type and contents (via out parameters) and whether a complete message 72 // its type and contents through out parameters and any error that occurred
73 // was able to be read (via the return value). 73 // through the return value.
74 bool ParseMessage(BattOrMessageType* type, std::vector<char>* data); 74 enum ParseMessageError {
75 NONE = 0,
76 NOT_ENOUGH_BYTES = 1,
77 MISSING_START_BYTE = 2,
78 INVALID_MESSAGE_TYPE = 3,
79 TOO_MANY_START_BYTES = 4
80 };
81
82 ParseMessageError ParseMessage(BattOrMessageType* type,
83 std::vector<char>* data);
75 84
76 // Internal callback for when bytes are sent. 85 // Internal callback for when bytes are sent.
77 void OnBytesSent(int bytes_sent, device::serial::SendError error); 86 void OnBytesSent(int bytes_sent, device::serial::SendError error);
78 87
79 // Appends |str| to the serial log file if it exists. 88 // Appends |str| to the serial log file if it exists.
80 void LogSerial(const std::string& str); 89 void LogSerial(const std::string& str);
81 90
82 // The path of the BattOr. 91 // The path of the BattOr.
83 std::string path_; 92 std::string path_;
84 93
(...skipping 13 matching lines...) Expand all
98 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner_; 107 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner_;
99 108
100 std::fstream serial_log_; 109 std::fstream serial_log_;
101 110
102 DISALLOW_COPY_AND_ASSIGN(BattOrConnectionImpl); 111 DISALLOW_COPY_AND_ASSIGN(BattOrConnectionImpl);
103 }; 112 };
104 113
105 } // namespace battor 114 } // namespace battor
106 115
107 #endif // TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_ 116 #endif // TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | tools/battor_agent/battor_connection_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698