Chromium Code Reviews| Index: components/drive/chromeos/file_cache.cc |
| diff --git a/components/drive/chromeos/file_cache.cc b/components/drive/chromeos/file_cache.cc |
| index 37c0e87ff9e96ba26a55fcd178ce18cae960bb68..5b554b839797750afb8bde4647ef441ba73cf068 100644 |
| --- a/components/drive/chromeos/file_cache.cc |
| +++ b/components/drive/chromeos/file_cache.cc |
| @@ -264,10 +264,31 @@ bool FileCache::FreeDiskSpaceIfNeededFor(int64_t num_bytes) { |
| return GetAvailableSpace() >= num_bytes; |
| } |
| -uint64_t FileCache::CalculateEvictableCacheSize() { |
| +int64_t FileCache::CalculateCacheSize() { |
| AssertOnSequencedWorkerPool(); |
| - uint64_t evictable_cache_size = 0; |
| + int64_t total_cache_size = 0; |
| + int64_t cache_size = 0; |
| + |
| + std::unique_ptr<ResourceMetadataStorage::Iterator> it = |
| + storage_->GetIterator(); |
| + for (; !it->IsAtEnd(); it->Advance()) { |
| + if (base::GetFileSize(GetCacheFilePath(it->GetID()), &cache_size)) { |
|
yawano
2016/06/08 11:53:44
We should check the existence of cache by checking
fukino
2016/06/09 04:36:47
Nice catch! Done.
yawano
2016/06/09 05:19:19
You also need to check is_present to know whether
fukino
2016/06/09 06:38:21
Done.
|
| + DCHECK_GE(cache_size, 0); |
| + total_cache_size += cache_size; |
| + } |
| + } |
| + |
| + if (it->HasError()) |
| + return 0; |
| + |
| + return total_cache_size; |
| +} |
| + |
| +int64_t FileCache::CalculateEvictableCacheSize() { |
| + AssertOnSequencedWorkerPool(); |
| + |
| + int64_t evictable_cache_size = 0; |
| int64_t cache_size = 0; |
| std::unique_ptr<ResourceMetadataStorage::Iterator> it = |