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

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

Issue 2390893002: [BattOr] Make BattOr able to return firmware version. (Closed)
Patch Set: Created 4 years, 2 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.cc » ('j') | tools/battor_agent/battor_agent.cc » ('J')
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_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 25 matching lines...) Expand all
36 public base::SupportsWeakPtr<BattOrAgent> { 36 public base::SupportsWeakPtr<BattOrAgent> {
37 public: 37 public:
38 // The listener interface that must be implemented in order to interact with 38 // The listener interface that must be implemented in order to interact with
39 // the BattOrAgent. 39 // the BattOrAgent.
40 class Listener { 40 class Listener {
41 public: 41 public:
42 virtual void OnStartTracingComplete(BattOrError error) = 0; 42 virtual void OnStartTracingComplete(BattOrError error) = 0;
43 virtual void OnStopTracingComplete(const std::string& trace, 43 virtual void OnStopTracingComplete(const std::string& trace,
44 BattOrError error) = 0; 44 BattOrError error) = 0;
45 virtual void OnRecordClockSyncMarkerComplete(BattOrError error) = 0; 45 virtual void OnRecordClockSyncMarkerComplete(BattOrError error) = 0;
46 virtual void OnGetVersionComplete(const int version, BattOrError error) = 0;
46 }; 47 };
47 48
48 BattOrAgent( 49 BattOrAgent(
49 const std::string& path, 50 const std::string& path,
50 Listener* listener, 51 Listener* listener,
51 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner, 52 scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
52 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner); 53 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner);
53 virtual ~BattOrAgent(); 54 virtual ~BattOrAgent();
54 55
55 void StartTracing(); 56 void StartTracing();
56 void StopTracing(); 57 void StopTracing();
57 void RecordClockSyncMarker(const std::string& marker); 58 void RecordClockSyncMarker(const std::string& marker);
58 59
charliea (OOO until 10-5) 2016/10/04 15:15:48 Rather than `int Version()` below, I think you wan
59 // Returns whether the BattOr is able to record clock sync markers in its own 60 // Returns whether the BattOr is able to record clock sync markers in its own
60 // trace log. 61 // trace log.
61 static bool SupportsExplicitClockSync() { return true; } 62 static bool SupportsExplicitClockSync() { return true; }
62 63
63 // BattOrConnection::Listener implementation. 64 // BattOrConnection::Listener implementation.
64 void OnConnectionOpened(bool success) override; 65 void OnConnectionOpened(bool success) override;
65 void OnBytesSent(bool success) override; 66 void OnBytesSent(bool success) override;
66 void OnMessageRead(bool success, 67 void OnMessageRead(bool success,
67 BattOrMessageType type, 68 BattOrMessageType type,
68 std::unique_ptr<std::vector<char>> bytes) override; 69 std::unique_ptr<std::vector<char>> bytes) override;
70 int Version();
69 71
70 protected: 72 protected:
71 // The connection that knows how to communicate with the BattOr in terms of 73 // 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 74 // protocol primitives. This is protected so that it can be replaced with a
73 // fake in testing. 75 // fake in testing.
74 std::unique_ptr<BattOrConnection> connection_; 76 std::unique_ptr<BattOrConnection> connection_;
75 77
76 // Timeout for when an action isn't completed within the allotted time. This 78 // 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 79 // 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 80 // testing task runner that runs delayed tasks immediately deals poorly with
79 // timeouts posted as future tasks. 81 // timeouts posted as future tasks.
80 virtual void OnActionTimeout(); 82 virtual void OnActionTimeout();
81 83
82 private: 84 private:
83 enum class Command { 85 enum class Command {
84 INVALID, 86 INVALID,
85 START_TRACING, 87 START_TRACING,
86 STOP_TRACING, 88 STOP_TRACING,
87 RECORD_CLOCK_SYNC_MARKER, 89 RECORD_CLOCK_SYNC_MARKER,
90 VERSION,
88 }; 91 };
89 92
90 enum class Action { 93 enum class Action {
91 INVALID, 94 INVALID,
92 95
93 // Actions required to connect to a BattOr. 96 // Actions required to connect to a BattOr.
94 REQUEST_CONNECTION, 97 REQUEST_CONNECTION,
95 98
96 // Actions required for starting tracing. 99 // Actions required for starting tracing.
97 SEND_INIT, 100 SEND_INIT,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 183
181 // The timeout that's run when an action times out. 184 // The timeout that's run when an action times out.
182 base::CancelableClosure timeout_callback_; 185 base::CancelableClosure timeout_callback_;
183 186
184 DISALLOW_COPY_AND_ASSIGN(BattOrAgent); 187 DISALLOW_COPY_AND_ASSIGN(BattOrAgent);
185 }; 188 };
186 189
187 } // namespace battor 190 } // namespace battor
188 191
189 #endif // TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_ 192 #endif // TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_
OLDNEW
« no previous file with comments | « no previous file | tools/battor_agent/battor_agent.cc » ('j') | tools/battor_agent/battor_agent.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698