attestation: fix shutdown for dbus threads

Objects that communicate with trunksd and tpm_managerd over D-Bus
must be destroyed on the same thread that initialized them. Their
destructors call dbus::Bus::ShutdownAndBlock(), which require that
they are called on the same thread that created dbus::Bus objects.

That applies to:
 - tpm_manager::TpmOwnershipDBusProxy;
 - tpm_manager::TpmNvramDBusProxy;
 - trunks::TrunksDBusProxy
   (destructed in trunks::~TrunksFactoryImpl, in turn called from
    attestation::~TpmUtilityV2).

Destruct such objects in CleanUp() hooks of the threads that
created them. Doing it in these hooks, rather than posting a
special shutdown task to that thread from the owning object
destructor, ensures that these objects are not destructed while
there are tasks left in the thread's message queue that might
access the destructed objects.

BUG=chromium:684269
TEST=Login, corp enrollment still succeeds. Unit tests pass.
     "stop attestationd" doesn't lead to a crash.

Change-Id: I2576eb4cf8260092adb4d54cb3aeb5f662e85010
Reviewed-on: https://chromium-review.googlesource.com/444213
Commit-Ready: Andrey Pronin <apronin@chromium.org>
Tested-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
4 files changed