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

Unified Diff: tools/battor_agent/battor_agent.h

Issue 1524873002: Creates a BattOrConnection for communicating with the BattOr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing dep Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/battor_agent/DEPS ('k') | tools/battor_agent/battor_agent.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/battor_agent/battor_agent.h
diff --git a/tools/battor_agent/battor_agent.h b/tools/battor_agent/battor_agent.h
index 413890e4ec2294e531167d79c086b00a65c87f6b..a008b6c5baa96be3080654e2451797e8e993868a 100644
--- a/tools/battor_agent/battor_agent.h
+++ b/tools/battor_agent/battor_agent.h
@@ -5,17 +5,12 @@
#ifndef TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_
#define TOOLS_BATTOR_AGENT_BATTOR_AGENT_H_
-#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
#include "base/threading/thread_checker.h"
+#include "tools/battor_agent/battor_connection.h"
#include "tools/battor_agent/battor_error.h"
-namespace device {
-class SerialIoHandler;
-}
-
namespace battor {
// A BattOrAgent is a class used to asynchronously communicate with a BattOr for
@@ -32,7 +27,7 @@ namespace battor {
//
// This class is NOT thread safe, and must be interacted with only from the IO
// thread. The IO thread must also have a running MessageLoop.
-class BattOrAgent : public base::SupportsWeakPtr<BattOrAgent> {
+class BattOrAgent : public BattOrConnection::Listener {
public:
// The listener interface that must be implemented in order to interact with
// the BattOrAgent.
@@ -43,7 +38,7 @@ class BattOrAgent : public base::SupportsWeakPtr<BattOrAgent> {
BattOrAgent(
scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner,
- scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_rnuner,
+ scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner,
const std::string& path,
Listener* listener);
virtual ~BattOrAgent();
@@ -55,34 +50,26 @@ class BattOrAgent : public base::SupportsWeakPtr<BattOrAgent> {
// trace log.
static bool SupportsExplicitClockSync() { return true; }
+ // BattOrConnection::Listener implementation.
+ void OnConnectionOpened(bool success) override;
+ void OnBytesSent(bool success) override;
+ void OnBytesRead(bool success,
+ BattOrMessageType type,
+ scoped_ptr<std::vector<char>> bytes) override;
+
private:
- // Initializes the serial connection (if not done already) and calls one of
- // the two callbacks depending its success. The callback will be invoked on
- // the same thread that this method is called on.
- void ConnectIfNeeded(const base::Closure& success_callback,
- const base::Closure& failure_callback);
- void OnConnectComplete(const base::Closure& success_callback,
- const base::Closure& failure_callback,
- bool success);
+ // Initializes the serial connection (if not done already).
+ // OnConnectionOpened() will be called once the connection is made.
+ void ConnectIfNeeded();
// StartTracing continuation called once the connection is initialized.
void DoStartTracing();
- // Resets the connection to its unopened state.
- void ResetConnection();
-
- // Threads needed for serial communication.
- scoped_refptr<base::SingleThreadTaskRunner> file_thread_task_runner_;
- scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner_;
-
- // The path of the BattOr (e.g. "/dev/tty.battor_serial").
- std::string path_;
-
// The listener that handles the commands' results. It must outlive the agent.
Listener* listener_;
- // IO handler capable of reading and writing from the serial connection.
- scoped_refptr<device::SerialIoHandler> io_handler_;
+ // The serial connection to the BattOr.
+ scoped_ptr<BattOrConnection> connection_;
// Checker to make sure that this is only ever called on the IO thread.
base::ThreadChecker thread_checker_;
« no previous file with comments | « tools/battor_agent/DEPS ('k') | tools/battor_agent/battor_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698