• gab's avatar
    Introduce SafeBrowsingDatabase::ThreadSafeStateManager. · b2f71d56
    gab authored
    This enforces thread-safety by design via transactions for any
    implementation code accessing shared SafeBrowsingDatabase members.
    
    Previously this was enforced by assuming everybody would make proper
    usage of |lookup_lock_| but this was deemed insufficient as programming
    mistakes proved easy to make twice.
    
    One of the subtleties of this transactional model (which made the previous
    ad-hoc locking even harder to prove (and keep) correct) is that only the
    main database thread is allowed to modify this state, allowing for
    unlocked reads on the main thread which are important to avoid
    contention when flushing to disk.
    
    BUG=440517
    
    Review URL: https://codereview.chromium.org/794273002
    
    Cr-Commit-Position: refs/heads/master@{#309611}
    b2f71d56
safe_browsing_database.cc 66.7 KB