• Istiaque Ahmed's avatar
    Always pass ContentHash creation through IO thread. · 3641f523
    Istiaque Ahmed authored
    This will allow ContentHash caching to be (trivially)
    implemented in the future in ContentVerifier::GetContentHash().
    This CL also makes extension load at startup to queue all inflight
    requests to load verified_contents and computed_hashes reading
    from disk. This is because inflight requests will be served by
    single file read.
    
    Summary of changes:
    The primary method is ContentVerifier::GetContentHash(). This
    method is responsible for retrieving ContentHash on IO thread. It
    uses ContentVerifier::HashHelper to manage thread hops and such.
    HashHelper is not thread safe and it uses static method + weak
    pointers to safely call ContentHash methods on blocking thread.
    
    ContentHash class is responsible for fetching verified_contents.json
    from network, using ContentHashFetcher. ContentHashFetcher
    manages its own lifetime and is no longer ref-counted. Also,
    ContentHashFetcherJob is no longer required.
    ContentHashFetcher is currently an implementation detail of
    ContentHash, and can be further restricted so that it cannot be
    instantiated outside of ContentHash.
    Because of async nature requirement of net fetch, ContentHash::Create
    is now async.
    
    Since ContentHash instance can travel between sequences, they are
    RefCountedThreadSafe now.
    
    ContentVerifier::VerifyFailed used to be (also) called when we fail to
    retrieve hashes on disk and it would fall back to ContentHashFetcher
    for fetching the hashes. As GetContentHash currently takes care of
    this through ContentHash::Create, ContentVerifier is only made aware
    of failures on when hash mismatch occurs, simplifying things further.
    
    Bug: 796395
    Change-Id: I7eb6bf93daba908258ae604a8cd45ea643b4e00d
    Reviewed-on: https://chromium-review.googlesource.com/933863
    Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
    Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#545623}
    3641f523
extension_protocols.cc 41.5 KB