• Devlin Cronin's avatar
    [Extensions] Add promise support to APIRequestHandler · 5c1d6041
    Devlin Cronin authored
    Add a StartPromiseBasedRequest() method to APIRequestHandler to begin an
    API request that returns a Promise.  The promise will be fulfilled or
    rejected once the API returns. An API error (i.e., one that would
    normally be presented in chrome.runtime.lastError) rejects the promise,
    and otherwise it is resolved with the result of the API call.  Add
    unittests for the same.
    
    Since promises can only be resolved with a single value, only APIs that
    return a single result are supported.
    
    Note this only adds support in the APIRequestHandler class; this is not
    currently hooked up to any APIs, and cannot be used directly from
    extensions yet.
    
    Bug: 978538
    
    Change-Id: I2bcd7c48b82656187d8303f088211b0557fc0ac4
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626654Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
    Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#676985}
    5c1d6041
api_request_handler.h 6.5 KB