• Colin Blundell's avatar
    [Safe Browsing] Pull out timeout tracking of token fetches for reuse · b6f3b558
    Colin Blundell authored
    This CL separates separates the mechanism via which
    SafeBrowsingPrimaryAccountTokenFetcher fetches access tokens and the
    mechanisms via which it tracks and responds to ongoing token fetches,
    moving the latter into a new SafeBrowsingTokenFetchTracker helper class
    for reuse by WebLayer. This class includes the following:
    
    - Tracking of ongoing access token fetch requests coming from the client
      of SafeBrowsingTokenFetcher, responding to these requests when
      notified that a given access token has been fetched, and gating these
      requests on a given time threshold (responding with an empty access
      token if a request times out)
    - Responding to all active token requests with an empty access token on
      destruction
    
    This CL also adds unittests of SafeBrowsingTokenFetchTracker.
    
    Via this helper class, WebLayer will be able to share the key
    functionality of gating safe browsing access token fetches on a timeout
    rather than duplicating this functionality and risking divergence over
    time.
    
    The only subtlety is the behavior on token fetch timeout:
    SafeBrowsingPrimaryAccountTokenFetcher needs to be notified in addition
    to its client so that the former can destroy the corresponding
    AccessTokenFetcher. To facilitate this,
    SafeBrowsingTokenFetchTracker::StartTrackingTokenFetch() takes in both
    the SafeBrowsingTokenFetcher::Callback that the client passed in and a
    callback to be invoked on timeout, via which its owner can clean up any
    state associated with the request.
    
    Bug: 1080748
    Change-Id: I79bb83096cc2094c7cf9916eccf382271a5f46a5
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2624630
    Commit-Queue: Colin Blundell <blundell@chromium.org>
    Reviewed-by: default avatarXinghui Lu <xinghuilu@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#843441}
    b6f3b558
BUILD.gn 31.7 KB