From b1bf19abcbde1ef1e669d72a71e4aab0320e65a9 Mon Sep 17 00:00:00 2001 From: "hashimoto@chromium.org" Date: Tue, 21 Jan 2014 04:45:19 +0000 Subject: 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 --- chrome/browser/chromeos/drive/file_cache.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'chrome/browser/chromeos/drive/file_cache.h') 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); -- cgit v1.1