Reduce scope of lock in TaskQueueImpl

We can safely reduce the scope of the lock given that
task_poster_->ShutdownAndWaitForZeroOperations() will make sure that
there will be no more post task calls.

This also addresses a CHECK fail that would happen if the unregister
would trigger a ScheduleWork, as we would hold the any_thread_lock_ in
TaskQueueImpl during the ScheduleWork call.

Bug: 943009
Change-Id: I633676ead5f81d41f5a1c7defc31bb507c53f377
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1529093
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Alex Clarke <alexclarke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#641871}
2 files changed