• gavinp's avatar
    Connect SimpleCache Backend active_entries_ more closely to Entry lifetime. · b02ee6e3
    gavinp authored
    Entries remove themselves from their backend's |active_entries_| at two
    distinct points in their lifetime; after a successful doom and on
    destruction.
    
    Entries are also added to |active_entries_| in one of two possible places;
    early in opening/creating an entry from its key, and during iteration, after
    successfully opening an entry from its hash alone.
    
    We weren't carefully tracking this relationship, and so entries previously
    would double remove themselves from the backend, which could create
    races that could cause entries to not open. For instance, creating an entry,
    dooming it, closing it, then creating a new entry with the same key could
    race, and the doom's completion would remove the closing entry from
    |active_entries_|, allowing a subsequent OpenEntry() to fail because it
    found an half baked entry.
    
    To avoid exposing the state of the backend to the entry, this patch
    introduces an abstraction to Entry to allow observation of destruction. This
    abstraction is then used to register the backend as entries are placed in
    |active_entries_|.
    
    R=jkarlin@chromium.org,ttuttle@chromium.org,pasko@chromium.org
    BUG=317138,404676
    
    Review URL: https://codereview.chromium.org/478573003
    
    Cr-Commit-Position: refs/heads/master@{#291728}
    b02ee6e3
simple_backend_impl.cc 25.6 KB