Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/chromeos/drive/file_cache.cc

Issue 18948004: drive: Remove MD5 argument from FileCache::MarkDirty (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/drive/file_cache.h" 5 #include "chrome/browser/chromeos/drive/file_cache.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 base::PostTaskAndReplyWithResult( 384 base::PostTaskAndReplyWithResult(
385 blocking_task_runner_.get(), 385 blocking_task_runner_.get(),
386 FROM_HERE, 386 FROM_HERE,
387 base::Bind( 387 base::Bind(
388 &FileCache::MarkAsUnmounted, base::Unretained(this), file_path), 388 &FileCache::MarkAsUnmounted, base::Unretained(this), file_path),
389 callback); 389 callback);
390 } 390 }
391 391
392 void FileCache::MarkDirtyOnUIThread(const std::string& resource_id, 392 void FileCache::MarkDirtyOnUIThread(const std::string& resource_id,
393 const std::string& md5,
394 const FileOperationCallback& callback) { 393 const FileOperationCallback& callback) {
395 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 394 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
396 DCHECK(!callback.is_null()); 395 DCHECK(!callback.is_null());
397 396
398 base::PostTaskAndReplyWithResult( 397 base::PostTaskAndReplyWithResult(
399 blocking_task_runner_.get(), 398 blocking_task_runner_.get(),
400 FROM_HERE, 399 FROM_HERE,
401 base::Bind( 400 base::Bind(&FileCache::MarkDirty, base::Unretained(this), resource_id),
402 &FileCache::MarkDirty, base::Unretained(this), resource_id, md5),
403 callback); 401 callback);
404 } 402 }
405 403
406 FileError FileCache::MarkDirty(const std::string& resource_id, 404 FileError FileCache::MarkDirty(const std::string& resource_id) {
407 const std::string& md5) {
408 AssertOnSequencedWorkerPool(); 405 AssertOnSequencedWorkerPool();
409 406
410 // If file has already been marked dirty in previous instance of chrome, we
411 // would have lost the md5 info during cache initialization, because the file
412 // would have been renamed to .local extension.
413 // So, search for entry in cache without comparing md5.
414
415 // Marking a file dirty means its entry and actual file blob must exist in 407 // Marking a file dirty means its entry and actual file blob must exist in
416 // cache. 408 // cache.
417 FileCacheEntry cache_entry; 409 FileCacheEntry cache_entry;
418 if (!GetCacheEntry(resource_id, md5, &cache_entry) || 410 if (!storage_->GetCacheEntry(resource_id, &cache_entry) ||
419 !cache_entry.is_present()) { 411 !cache_entry.is_present()) {
420 LOG(WARNING) << "Can't mark dirty a file that wasn't cached: res_id=" 412 LOG(WARNING) << "Can't mark dirty a file that wasn't cached: "
421 << resource_id 413 << resource_id;
422 << ", md5=" << md5;
423 return FILE_ERROR_NOT_FOUND; 414 return FILE_ERROR_NOT_FOUND;
424 } 415 }
425 416
426 if (cache_entry.is_dirty()) 417 if (cache_entry.is_dirty())
427 return FILE_ERROR_OK; 418 return FILE_ERROR_OK;
428 419
429 // Now that file operations have completed, update metadata. 420 // Now that file operations have completed, update metadata.
430 cache_entry.set_is_dirty(true); 421 cache_entry.set_is_dirty(true);
431 return storage_->PutCacheEntry(resource_id, cache_entry) ? 422 return storage_->PutCacheEntry(resource_id, cache_entry) ?
432 FILE_ERROR_OK : FILE_ERROR_FAILED; 423 FILE_ERROR_OK : FILE_ERROR_FAILED;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 false, // not recursive 723 false, // not recursive
733 base::FileEnumerator::FILES); 724 base::FileEnumerator::FILES);
734 for (base::FilePath current = enumerator.Next(); !current.empty(); 725 for (base::FilePath current = enumerator.Next(); !current.empty();
735 current = enumerator.Next()) 726 current = enumerator.Next())
736 base::Move(current, current.RemoveExtension()); 727 base::Move(current, current.RemoveExtension());
737 } 728 }
738 } 729 }
739 730
740 } // namespace internal 731 } // namespace internal
741 } // namespace drive 732 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_cache.h ('k') | chrome/browser/chromeos/drive/file_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698