diff options
author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-21 04:45:19 +0000 |
---|---|---|
committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-21 04:45:19 +0000 |
commit | b1bf19abcbde1ef1e669d72a71e4aab0320e65a9 (patch) | |
tree | 32a9dcaf373c91ac702796b24ba91194a2557b7e /chrome/browser/chromeos/drive/file_cache.h | |
parent | bbcf0555c6f5b9cd07768c346cd4b7fcb747f63f (diff) | |
download | chromium_src-b1bf19abcbde1ef1e669d72a71e4aab0320e65a9.zip chromium_src-b1bf19abcbde1ef1e669d72a71e4aab0320e65a9.tar.gz chromium_src-b1bf19abcbde1ef1e669d72a71e4aab0320e65a9.tar.bz2 |
drive: More reliable MD5 management of FileCacheEntry
Add FileCache::UpdateMd5().
Stop setting MD5 with FileCache::ClearDirty().
Remove UpdateOperation::ContentCheckMode. (Instead, use FileCacheEntry::md5 to determine whether content check is needed or not.)
MD5 of a FileCacheEntry changes as follows:
(md5.empty()==true means MD5 is unknown)
1. FileCache::Initialize clears MD5 of all dirty entries for backward compatibility.
2. FileCache::OpenForWrite clears MD5.
3. FileCache::UpdateMd5 calculates MD5.
4. FileCache::ClearDirty does nothing for MD5.
UpdateOperation behaves in the following way:
- Before upload, UpdateMD5() is called if FIleCacheEntry::MD5 is empty. IsOpenedForWrite() is used to prevent unneeded upload from starting.
- After upload, ResourceEntry's MD5 is checked against FileCacheEntry::MD5. If it doesn't match, it means someone has opened the file (i.e. clearing MD5) so shouldn't clear the dirty bit.
BUG=326054
TEST=unit_tests
R=kinaba@chromium.org
Review URL: https://codereview.chromium.org/114953003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/drive/file_cache.h')
-rw-r--r-- | chrome/browser/chromeos/drive/file_cache.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/chrome/browser/chromeos/drive/file_cache.h b/chrome/browser/chromeos/drive/file_cache.h index 4dcc3b1..db6f848d 100644 --- a/chrome/browser/chromeos/drive/file_cache.h +++ b/chrome/browser/chromeos/drive/file_cache.h @@ -115,8 +115,11 @@ class FileCache { // Returns true if the cache file corresponding to |id| is write-opened. bool IsOpenedForWrite(const std::string& id); - // Clears dirty state of the specified entry and updates its MD5. - FileError ClearDirty(const std::string& id, const std::string& md5); + // Calculates MD5 of the cache file and updates the stored value. + FileError UpdateMd5(const std::string& id); + + // Clears dirty state of the specified entry. + FileError ClearDirty(const std::string& id); // Removes the specified cache entry and delete cache files if available. FileError Remove(const std::string& id); |