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

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

Issue 1970243002: [battor agent] Add option to log serial communication (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@char_array_to_str
Patch Set: Explicitly cast serial::ReceiveError 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 <vector> 9 #include <vector>
9 10
10 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "device/serial/serial.mojom.h" 15 #include "device/serial/serial.mojom.h"
15 #include "tools/battor_agent/battor_connection.h" 16 #include "tools/battor_agent/battor_connection.h"
16 #include "tools/battor_agent/battor_error.h" 17 #include "tools/battor_agent/battor_error.h"
17 #include "tools/battor_agent/battor_protocol_types.h" 18 #include "tools/battor_agent/battor_protocol_types.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 std::unique_ptr<std::vector<char>> data); 69 std::unique_ptr<std::vector<char>> data);
69 70
70 // Pulls off the next complete message from already_read_buffer_, returning 71 // Pulls off the next complete message from already_read_buffer_, returning
71 // its type and contents (via out parameters) and whether a complete message 72 // its type and contents (via out parameters) and whether a complete message
72 // was able to be read (via the return value). 73 // was able to be read (via the return value).
73 bool ParseMessage(BattOrMessageType* type, std::vector<char>* data); 74 bool ParseMessage(BattOrMessageType* type, std::vector<char>* data);
74 75
75 // Internal callback for when bytes are sent. 76 // Internal callback for when bytes are sent.
76 void OnBytesSent(int bytes_sent, device::serial::SendError error); 77 void OnBytesSent(int bytes_sent, device::serial::SendError error);
77 78
79 // Appends |str| to the serial log file if it exists.
80 void LogSerial(const std::string& str);
81
78 // The path of the BattOr. 82 // The path of the BattOr.
79 std::string path_; 83 std::string path_;
80 84
81 // All bytes that have already been read from the serial stream, but have not 85 // All bytes that have already been read from the serial stream, but have not
82 // yet been given to the listener as a complete message. 86 // yet been given to the listener as a complete message.
83 std::vector<char> already_read_buffer_; 87 std::vector<char> already_read_buffer_;
84 // The bytes that were read in the pending read. 88 // The bytes that were read in the pending read.
85 scoped_refptr<net::IOBuffer> pending_read_buffer_; 89 scoped_refptr<net::IOBuffer> pending_read_buffer_;
86 // The type of message we're looking for in the pending read. 90 // The type of message we're looking for in the pending read.
87 BattOrMessageType pending_read_message_type_; 91 BattOrMessageType pending_read_message_type_;
88 92
89 // The total number of bytes that we're expecting to send. 93 // The total number of bytes that we're expecting to send.
90 size_t pending_write_length_; 94 size_t pending_write_length_;
91 95
92 // Threads needed for serial communication. 96 // Threads needed for serial communication.
93 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_; 97 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_;
94 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner_; 98 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner_;
95 99
100 std::fstream serial_log_;
101
96 DISALLOW_COPY_AND_ASSIGN(BattOrConnectionImpl); 102 DISALLOW_COPY_AND_ASSIGN(BattOrConnectionImpl);
97 }; 103 };
98 104
99 } // namespace battor 105 } // namespace battor
100 106
101 #endif // TOOLS_BATTOR_AGENT_BATTOR_CONNECTION_IMPL_H_ 107 #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