chaps: destroy sub-objects on correct thread

TrunksDBusProxy expects to have its API used by exactly one
thread. Unfortunately while this is not explicitly stated the
destructor also must be called from this one thread because it
shuts down a dbus::Bus. Because of this, the owning object
(TPM2UtilityImpl) should keep a reference to the task runner of
the thread which initialized the TrunksDBusProxy and use it
to clean up the proxy when it is being destroyed.

Because this restriction requires the task runner passed to
TPM2UtilityImpl to always use the same thread, we also need to
change the task runner it expects to be a SingleThreadTaskRunner.
This is fine because that's the only type of task runner we ever
used with it anyway.

BUG=chromium:754764
TEST=stop chaps and verify no crashes in /var/log/messages on eve;
  use pkcs11-tool while repeatedly restarting chapsd and ensure
  calls either work correctly or fail if they happened during a
  restart

Change-Id: Ie9124c1ee76029d4ff43f4c1398c7679e6fc37e9
Reviewed-on: https://chromium-review.googlesource.com/614121
Commit-Ready: Eric Caruso <ejcaruso@chromium.org>
Tested-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
(cherry picked from commit 464ceee52b908996896b94fa73d53ed3f5f64c8d)
Reviewed-on: https://chromium-review.googlesource.com/665857
Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
Commit-Queue: Andrey Pronin <apronin@chromium.org>
Tested-by: Andrey Pronin <apronin@chromium.org>
2 files changed