Reland (2) Promises: Implement Promise<> handle with Then and Catch

It turns out SmallUniqueObject casting itself to the derived
object is undefined behavior... There is an ugly workaround
similar to unique_any we need to roll our own vtable :(

At least UBSan is happy with it.

Tests failed on UBSanVptr bot

They pass with this CL.

Original patch

Implements Then and Catch on top of AbstractPromise as well as
ManualPromiseResolver<> which is needed for testing at this
stage (PostTask doesn't yet return a promise). It's also
necessary for promises to interface with old style callback
based libraries which are extremely common in Chromium.


Bug: 906125
Change-Id: I5ae1412f01d64c4d06b9208a41dfc5b8b51435fe
Commit-Queue: Alex Clarke <>
Reviewed-by: Fran├žois Doray <>
Reviewed-by: Etienne Pierre-Doray <>
Cr-Commit-Position: refs/heads/master@{#661888}
17 files changed