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

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

Issue 16338005: drive: Remove FakeCacheMetadata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/logging.h" 10 #include "base/logging.h"
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 673 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
674 DCHECK(!callback.is_null()); 674 DCHECK(!callback.is_null());
675 675
676 base::PostTaskAndReplyWithResult( 676 base::PostTaskAndReplyWithResult(
677 blocking_task_runner_, 677 blocking_task_runner_,
678 FROM_HERE, 678 FROM_HERE,
679 base::Bind(&FileCache::InitializeOnBlockingPool, base::Unretained(this)), 679 base::Bind(&FileCache::InitializeOnBlockingPool, base::Unretained(this)),
680 callback); 680 callback);
681 } 681 }
682 682
683 void FileCache::RequestInitializeForTesting() {
684 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
685
686 blocking_task_runner_->PostTask(
687 FROM_HERE,
688 base::Bind(&FileCache::InitializeOnBlockingPoolForTesting,
689 base::Unretained(this)));
690 }
691
692 void FileCache::Destroy() { 683 void FileCache::Destroy() {
693 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 684 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
694 685
695 // Invalidate the weak pointer. 686 // Invalidate the weak pointer.
696 weak_ptr_factory_.InvalidateWeakPtrs(); 687 weak_ptr_factory_.InvalidateWeakPtrs();
697 688
698 // Destroy myself on the blocking pool. 689 // Destroy myself on the blocking pool.
699 // Note that base::DeletePointer<> cannot be used as the destructor of this 690 // Note that base::DeletePointer<> cannot be used as the destructor of this
700 // class is private. 691 // class is private.
701 blocking_task_runner_->PostTask( 692 blocking_task_runner_->PostTask(
702 FROM_HERE, 693 FROM_HERE,
703 base::Bind(&FileCache::DestroyOnBlockingPool, base::Unretained(this))); 694 base::Bind(&FileCache::DestroyOnBlockingPool, base::Unretained(this)));
704 } 695 }
705 696
706 bool FileCache::InitializeOnBlockingPool() { 697 bool FileCache::InitializeOnBlockingPool() {
707 AssertOnSequencedWorkerPool(); 698 AssertOnSequencedWorkerPool();
708 699
709 if (!InitCachePaths(cache_paths_)) 700 if (!InitCachePaths(cache_paths_))
710 return false; 701 return false;
711 702
712 metadata_ = FileCacheMetadata::CreateCacheMetadata( 703 metadata_.reset(new FileCacheMetadata(blocking_task_runner_));
713 blocking_task_runner_);
714 return metadata_->Initialize(cache_paths_); 704 return metadata_->Initialize(cache_paths_);
715 } 705 }
716 706
717 void FileCache::InitializeOnBlockingPoolForTesting() {
718 AssertOnSequencedWorkerPool();
719
720 InitCachePaths(cache_paths_);
721 metadata_ = FileCacheMetadata::CreateCacheMetadataForTesting(
722 blocking_task_runner_);
723 metadata_->Initialize(cache_paths_);
724 }
725
726 void FileCache::DestroyOnBlockingPool() { 707 void FileCache::DestroyOnBlockingPool() {
727 AssertOnSequencedWorkerPool(); 708 AssertOnSequencedWorkerPool();
728 delete this; 709 delete this;
729 } 710 }
730 711
731 FileError FileCache::StoreInternal(const std::string& resource_id, 712 FileError FileCache::StoreInternal(const std::string& resource_id,
732 const std::string& md5, 713 const std::string& md5,
733 const base::FilePath& source_path, 714 const base::FilePath& source_path,
734 FileOperationType file_operation_type, 715 FileOperationType file_operation_type,
735 CachedFileOrigin origin) { 716 CachedFileOrigin origin) {
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 } 1097 }
1117 1098
1118 // static 1099 // static
1119 FileCache::CacheSubDirectoryType FileCache::GetSubDirectoryType( 1100 FileCache::CacheSubDirectoryType FileCache::GetSubDirectoryType(
1120 const FileCacheEntry& cache_entry) { 1101 const FileCacheEntry& cache_entry) {
1121 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP; 1102 return cache_entry.is_persistent() ? CACHE_TYPE_PERSISTENT : CACHE_TYPE_TMP;
1122 } 1103 }
1123 1104
1124 } // namespace internal 1105 } // namespace internal
1125 } // namespace drive 1106 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698