| OLD | NEW |
| 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 "storage/browser/fileapi/file_system_usage_cache.h" | 5 #include "storage/browser/fileapi/file_system_usage_cache.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 bool FileSystemUsageCache::Delete(const base::FilePath& usage_file_path) { | 154 bool FileSystemUsageCache::Delete(const base::FilePath& usage_file_path) { |
| 155 TRACE_EVENT0("FileSystem", "UsageCache::Delete"); | 155 TRACE_EVENT0("FileSystem", "UsageCache::Delete"); |
| 156 DCHECK(CalledOnValidThread()); | 156 DCHECK(CalledOnValidThread()); |
| 157 CloseCacheFiles(); | 157 CloseCacheFiles(); |
| 158 return base::DeleteFile(usage_file_path, false); | 158 return base::DeleteFile(usage_file_path, false); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void FileSystemUsageCache::CloseCacheFiles() { | 161 void FileSystemUsageCache::CloseCacheFiles() { |
| 162 TRACE_EVENT0("FileSystem", "UsageCache::CloseCacheFiles"); | 162 TRACE_EVENT0("FileSystem", "UsageCache::CloseCacheFiles"); |
| 163 DCHECK(CalledOnValidThread()); | 163 DCHECK(CalledOnValidThread()); |
| 164 STLDeleteValues(&cache_files_); | 164 base::STLDeleteValues(&cache_files_); |
| 165 timer_.reset(); | 165 timer_.reset(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 bool FileSystemUsageCache::Read(const base::FilePath& usage_file_path, | 168 bool FileSystemUsageCache::Read(const base::FilePath& usage_file_path, |
| 169 bool* is_valid, | 169 bool* is_valid, |
| 170 uint32_t* dirty_out, | 170 uint32_t* dirty_out, |
| 171 int64_t* usage_out) { | 171 int64_t* usage_out) { |
| 172 TRACE_EVENT0("FileSystem", "UsageCache::Read"); | 172 TRACE_EVENT0("FileSystem", "UsageCache::Read"); |
| 173 DCHECK(CalledOnValidThread()); | 173 DCHECK(CalledOnValidThread()); |
| 174 DCHECK(is_valid); | 174 DCHECK(is_valid); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 weak_factory_.GetWeakPtr())); | 293 weak_factory_.GetWeakPtr())); |
| 294 } | 294 } |
| 295 | 295 |
| 296 bool FileSystemUsageCache::CalledOnValidThread() { | 296 bool FileSystemUsageCache::CalledOnValidThread() { |
| 297 return !task_runner_.get() || task_runner_->RunsTasksOnCurrentThread(); | 297 return !task_runner_.get() || task_runner_->RunsTasksOnCurrentThread(); |
| 298 } | 298 } |
| 299 | 299 |
| 300 bool FileSystemUsageCache::HasCacheFileHandle(const base::FilePath& file_path) { | 300 bool FileSystemUsageCache::HasCacheFileHandle(const base::FilePath& file_path) { |
| 301 DCHECK(CalledOnValidThread()); | 301 DCHECK(CalledOnValidThread()); |
| 302 DCHECK_LE(cache_files_.size(), kMaxHandleCacheSize); | 302 DCHECK_LE(cache_files_.size(), kMaxHandleCacheSize); |
| 303 return ContainsKey(cache_files_, file_path); | 303 return base::ContainsKey(cache_files_, file_path); |
| 304 } | 304 } |
| 305 | 305 |
| 306 } // namespace storage | 306 } // namespace storage |
| OLD | NEW |