[scheduler] Prevent deadlock when posting a task from task destructor.

When TaskQueueManager was shutdown, posted closure will be destroyed
synchronously. When a closure owns an object, the destructor of this object
may try to post a task. If the task is destroyed while holding scheduler locks,
it may result in deadlocks.

R=alexclarke@chromium.org, skyostil@chromium.org
TBR=altimin@chromium.org

(cherry picked from commit 021a4bf395642491d7734138f06326b178a11e9a)

Bug: 814031
Change-Id: I7550b767d094fbd99543dd6b7827d58bf1c2bee9
Reviewed-on: https://chromium-review.googlesource.com/928705
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Commit-Queue: Alexander Timin <altimin@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#538147}
Reviewed-on: https://chromium-review.googlesource.com/937466
Reviewed-by: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/branch-heads/3325@{#595}
Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369}
4 files changed