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

Unified Diff: tools/battor_agent/battor_agent.cc

Issue 1524873002: Creates a BattOrConnection for communicating with the BattOr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: tools/battor_agent/battor_agent.cc
diff --git a/tools/battor_agent/battor_agent.cc b/tools/battor_agent/battor_agent.cc
index 71d3b6b9ea6d1ce417b632fc2d05f1f981af9d06..e164815611fa4555657a53e83d9820247637cddf 100644
--- a/tools/battor_agent/battor_agent.cc
+++ b/tools/battor_agent/battor_agent.cc
@@ -7,21 +7,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "device/serial/serial.mojom.h"
-#include "device/serial/serial_io_handler.h"
-
-namespace {
-
-// Serial configuration parameters for the BattOr.
-const uint32 kBattOrBitrate = 2000000;
-const device::serial::DataBits kBattOrDataBits =
- device::serial::DATA_BITS_EIGHT;
-const device::serial::ParityBit kBattOrParityBit =
- device::serial::PARITY_BIT_NONE;
-const device::serial::StopBits kBattOrStopBit = device::serial::STOP_BITS_ONE;
-const bool kBattOrCtsFlowControl = true;
-const bool kBattOrHasCtsFlowControl = true;
-
-} // namespace
namespace battor {
@@ -61,25 +46,16 @@ void BattOrAgent::ConnectIfNeeded(const base::Closure& success_callback,
const base::Closure& failure_callback) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (io_handler_) {
+ if (connection_) {
success_callback.Run();
return;
}
- io_handler_ = device::SerialIoHandler::Create(file_thread_task_runner_,
- ui_thread_task_runner_);
-
- device::serial::ConnectionOptions options;
- options.bitrate = kBattOrBitrate;
- options.data_bits = kBattOrDataBits;
- options.parity_bit = kBattOrParityBit;
- options.stop_bits = kBattOrStopBit;
- options.cts_flow_control = kBattOrCtsFlowControl;
- options.has_cts_flow_control = kBattOrHasCtsFlowControl;
-
- io_handler_->Open(path_, options,
- base::Bind(&BattOrAgent::OnConnectComplete, AsWeakPtr(),
- success_callback, failure_callback));
+ connection_.reset(
+ new BattOrConnection(file_thread_task_runner_, ui_thread_task_runner_));
+ connection_->Connect(path_,
+ base::Bind(&BattOrAgent::OnConnectComplete, AsWeakPtr(),
+ success_callback, failure_callback));
}
void BattOrAgent::OnConnectComplete(const base::Closure& success_callback,
@@ -90,7 +66,7 @@ void BattOrAgent::OnConnectComplete(const base::Closure& success_callback,
if (success) {
success_callback.Run();
} else {
- io_handler_ = nullptr;
+ connection_ = nullptr;
Primiano Tucci (use gerrit) 2015/12/15 11:07:19 typically I see this as connection_.reset() (doesn
charliea (OOO until 10-5) 2015/12/15 23:50:03 Done.
failure_callback.Run();
}
}

Powered by Google App Engine
This is Rietveld 408576698