summaryrefslogtreecommitdiffstats
path: root/tools/battor_agent
diff options
context:
space:
mode:
authorcharliea <charliea@chromium.org>2016-01-15 08:43:09 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-15 16:44:14 +0000
commitb3b22c10bef845a3fb5b643e41a27a7e55ab9e0c (patch)
tree1f9ab2e80c93e5510de10e902f1f065d482451d0 /tools/battor_agent
parent373d14fff4cd98c3a725b068882967c828c5c700 (diff)
downloadchromium_src-b3b22c10bef845a3fb5b643e41a27a7e55ab9e0c.zip
chromium_src-b3b22c10bef845a3fb5b643e41a27a7e55ab9e0c.tar.gz
chromium_src-b3b22c10bef845a3fb5b643e41a27a7e55ab9e0c.tar.bz2
tools/battor_agent: Loosen the BattOrAgent construction requirements
Constructing a BattOrAgent doesn't perform any IO, so it's not critical that it be done on the IO thread. Loosening this restriction allows us to create the BattOrAgent without having to switch threads when we're inside the Chrome tracing agent and on the UI thread. TBR=nednguyen@google.com BUG=542837 Review URL: https://codereview.chromium.org/1595563002 Cr-Commit-Position: refs/heads/master@{#369768}
Diffstat (limited to 'tools/battor_agent')
-rw-r--r--tools/battor_agent/battor_agent.cc4
-rw-r--r--tools/battor_agent/battor_agent.h5
2 files changed, 6 insertions, 3 deletions
diff --git a/tools/battor_agent/battor_agent.cc b/tools/battor_agent/battor_agent.cc
index 28ecee8..06928d7 100644
--- a/tools/battor_agent/battor_agent.cc
+++ b/tools/battor_agent/battor_agent.cc
@@ -105,7 +105,9 @@ BattOrAgent::BattOrAgent(
last_action_(Action::INVALID),
command_(Command::INVALID),
num_read_attempts_(0) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ // We don't care what thread the constructor is called on - we only care that
+ // all of the other method invocations happen on the same thread.
+ thread_checker_.DetachFromThread();
}
BattOrAgent::~BattOrAgent() {
diff --git a/tools/battor_agent/battor_agent.h b/tools/battor_agent/battor_agent.h
index 430e4b6..c13bc4a 100644
--- a/tools/battor_agent/battor_agent.h
+++ b/tools/battor_agent/battor_agent.h
@@ -26,8 +26,9 @@ namespace battor {
// same BattOrAgent for multiple commands and thus avoid having to reinitialize
// the serial connection.
//
-// 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.
+// This class is NOT thread safe. Any interactions with this class that involve
+// IO (i.e. any interactions that require a callback) must be done from the
+// same IO thread, which must also have a running MessageLoop.
class BattOrAgent : public BattOrConnection::Listener,
public base::SupportsWeakPtr<BattOrAgent> {
public: