• kylechar's avatar
    Implement base::BindPostTask() · dde7d239
    kylechar authored
    This function binds a callback to a task runner. The functionality
    already existed in media::BindToLoop() so it's intended to replace it
    and is built on the same BindPostTaskTrampoline logic. BindToLoop() and
    BindToCurrentLoop() will be replaced in a follow up CL since they are
    used rather widely already.
    
    There are some changes to the existing BindToLoop implementation:
    1. Get the FROM_HERE location from the caller automatically rather than
       using the BindPostTask() location.
    2. If BindPostTaskTrampoline has a OnceClosure, don't rebind the closure
       before posting a task.
    3. Add static_assert to provide a readable error message explaining the
       input callback must have a void return type.
    4. Don't support RepeatingCallback. This is more problematic since we
       will always PostTask() to destroy the callback. This is easier to add
       later than it would be to remove support.
    
    Bug: 1140582
    Change-Id: Ibb224b44c0b0c01dd88d29e94c7e9449d3353ef5
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495055
    Commit-Queue: kylechar <kylechar@chromium.org>
    Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
    Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
    Reviewed-by: default avatardanakj <danakj@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#827818}
    dde7d239
callback.md 27.2 KB