Refactor content verification hashes into ContentHash class.
There are two hash files that are involved for content verification: verified_contents.json and computed_hashes.json. The new class aims to pull all operations related to these files into ContentHash to improve content verification code and also facilitates further improvements to the code. This CL moves both hash files' reading code into ContentHash class avoiding the need to read verified_contents.json from multiple places. This CL also moves computed_hashes.json file generation/writing to ContentHash. The Cancel() behavior of ContentHashFetcherJob is retained in this CL, and is moved primarily to ContentHash. ContentHash uses CancellationStatus interface to consult ContentHashFetcherJob about cross thread cancellation of ContentHashFetcherJob. Update ContentHashReader and ContentHashFetcher accordingly to use ContentHash to deal with the hashes. Fetching verified_contents.json from network is still kept in ContentHashFetcher to keep the change simpler. Behavior changes: We used to write computed_hashes.json after computing hashes but didn't read that file at that step, this CL reads them back to ContentHash::Reader right after writing it. This avoids special cases and makes ContentHash always have both hashes ready. Other than that, expect no behavior change in this CL. Bug: 796395 Change-Id: I00e03cf208982e1cbd8be7951e06da97173a3ffc Reviewed-on: https://chromium-review.googlesource.com/831341 Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org> Reviewed-by:Devlin <rdevlin.cronin@chromium.org> Cr-Commit-Position: refs/heads/master@{#530422}
Showing
This diff is collapsed.
Please register or sign in to comment