Add *Callback::Then() to chain 2 callbacks together
a.Then(b) will return a new callback that when Run() will 1) run |a| 2) run |b|, passing it the return value from a 3) return the result from |b| OnceCallbacks must be destroyed when joining them together with Then(), so the method is rvalue-qualified. This means it is used in the same way as Run(), for example, this function posts two callbacks to run together as a single task: void PostTwoTasks(base::OnceClosure c1, base::OnceClosure c2) { PostTask(std::move(c1).Then(std::move(c2))); } RepeatingCallback can be joined destructively via the rvalue-qualified overload, or non-destructively otherwise. The latter is allowed for a RepeatingCallback because it is meant to have multiple callers and therefore having both the original callbacks and the joined callback pointing to the same underlying functor is not problematic. R=chrisha@chromium.org, gab@chromium.org Bug: 1140582 Change-Id: Ie147f01d1c8adeb5ed34e4933f211e7d247e3c6b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485642 Commit-Queue: danakj <danakj@chromium.org> Reviewed-by:Gabriel Charette <gab@chromium.org> Reviewed-by:
Chris Hamilton <chrisha@chromium.org> Reviewed-by:
Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/master@{#820319}
Showing
This diff is collapsed.
Please register or sign in to comment