Reduce leaks in PostTaskAndReplyImpl::PostTaskAndReply (reland #2).

This CL previously landed as
https://chromium-review.googlesource.com/997892. It was reverted because
of an access race in ChromeStorageImpl https://crbug.com/829122. This
CL fixes the issue by deleting both callbacks on the origin sequence
when they can't run.

Before, there was always leak when an internal task posted by
PostTaskAndReplyImpl didn't run. With this CL, PostTaskAndReplyImpl
notices when its internal callbacks aren't scheduled and schedules
deletion of all its internal state (including callbacks that didn't
run) on the origin sequence via a DeleteSoon(). Note that a deletion
scheduled via DeleteSoon() might not happen if Chrome is shutting
down.

R=gab@chromium.org

Bug: 807013
Change-Id: I17abffd3e7afcc861c8c92dce30c14ce8629b125
Reviewed-on: https://chromium-review.googlesource.com/1006045
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550189}

CrOS-Libchrome-Original-Commit: d3da450283253871dd1664290877990680bf2859
3 files changed
tree: 727c7c0ea7a04a84b68705fd0df1312526d5facb
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/