Chromium Code Reviews| Index: tools/battor_agent/battor_agent_bin.cc |
| diff --git a/tools/battor_agent/battor_agent_bin.cc b/tools/battor_agent/battor_agent_bin.cc |
| index 5cfce66a7b6492e795a36cacf8431941e366c80a..291f2d877d8c5b2c8b25cf023f5c806d536417af 100644 |
| --- a/tools/battor_agent/battor_agent_bin.cc |
| +++ b/tools/battor_agent/battor_agent_bin.cc |
| @@ -141,10 +141,13 @@ class BattOrAgentBin : public BattOrAgent::Listener { |
| ExitFromThreadStartFailure(kIoThreadName); |
| } |
| + base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| + base::WaitableEvent::InitialState::NOT_SIGNALED); |
|
aschulman
2016/06/15 14:51:03
I'd like to see a comment explaining why this part
|
| io_thread_.task_runner()->PostTask( |
| FROM_HERE, |
| base::Bind(&BattOrAgentBin::CreateAgent, base::Unretained(this), path, |
| - base::ThreadTaskRunnerHandle::Get())); |
| + base::ThreadTaskRunnerHandle::Get(), &done)); |
| + done.Wait(); |
| } |
| // Performs any cleanup necessary after the BattOr binary is done running. |
| @@ -272,7 +275,8 @@ class BattOrAgentBin : public BattOrAgent::Listener { |
| // and deleting it, MUST happen on the IO thread. |
| void CreateAgent( |
| const std::string& path, |
| - scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner) { |
| + scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner, |
| + base::WaitableEvent* done) { |
| // In Chrome, we already have a file thread running. Because the Chrome |
| // serial library relies on having it available, we have to spin up our own. |
| if (!file_thread_.Start()) |
| @@ -280,6 +284,7 @@ class BattOrAgentBin : public BattOrAgent::Listener { |
| agent_.reset(new BattOrAgent(path, this, file_thread_.task_runner(), |
| ui_thread_task_runner)); |
| + done->Signal(); |
| } |
| // Postable task for deleting the BattOrAgent. See the comment for |