• Colin Blundell's avatar
    Fix bug in IdentityGetAuthToken / IdentityAPI relationship · c841b285
    Colin Blundell authored
    https://codereview.chromium.org/2673443002 introduced a bug in the
    Identity extension API implementation: it assumed that there would be
    only one IdentityGetAuthToken instance that needed to listen for
    IdentityAPI shutdown at a given time, but in fact, there can be many.
    An example is if the user has multiple tabs open that each call the
    getAuthToken() function with interactive set to true, so that they
    end up hanging waiting for the user to authenticate.
    
    The result of this bug is that if the browser shuts down with multiple
    getAuthToken() calls active, only the last call will receive notice of
    IdentityAPI shutdown. Other calls can then end up calling back into
    Profile during its shutdown process, e.g. if they get notified by
    OAuth2TokenService as part of *its* shutdown process that it has failed
    their token requests. These calls can result in CHECKs (see crash
    reports linked from crbug.com/720073).
    
    This CL fixes the bug while maintaining the property that
    IdentityGetAuthToken does not require an interface dependence on
    IdentityAPI (i.e., the property that was the motivation of the original
    CL). To do so, it changes IdentityAPI to maintain a CallbackList that
    gets invoked on its shutdown.
    
    This CL also introduces a browsertest that fails without this change.
    
    Bug: 720073
    Change-Id: I44daaa0c0bbc27e54da9ab826e256c70f3d5a2a8
    Reviewed-on: https://chromium-review.googlesource.com/680974Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
    Commit-Queue: Colin Blundell <blundell@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#504289}
    c841b285
identity_apitest.cc 90.8 KB