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 "webkit/browser/fileapi/file_system_usage_cache.h" | 5 #include "webkit/browser/fileapi/file_system_usage_cache.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 bool FileSystemUsageCache::Exists(const base::FilePath& usage_file_path) { | 149 bool FileSystemUsageCache::Exists(const base::FilePath& usage_file_path) { |
150 TRACE_EVENT0("FileSystem", "UsageCache::Exists"); | 150 TRACE_EVENT0("FileSystem", "UsageCache::Exists"); |
151 DCHECK(CalledOnValidThread()); | 151 DCHECK(CalledOnValidThread()); |
152 return base::PathExists(usage_file_path); | 152 return base::PathExists(usage_file_path); |
153 } | 153 } |
154 | 154 |
155 bool FileSystemUsageCache::Delete(const base::FilePath& usage_file_path) { | 155 bool FileSystemUsageCache::Delete(const base::FilePath& usage_file_path) { |
156 TRACE_EVENT0("FileSystem", "UsageCache::Delete"); | 156 TRACE_EVENT0("FileSystem", "UsageCache::Delete"); |
157 DCHECK(CalledOnValidThread()); | 157 DCHECK(CalledOnValidThread()); |
158 CloseCacheFiles(); | 158 CloseCacheFiles(); |
159 return base::Delete(usage_file_path, true); | 159 return base::DeleteFile(usage_file_path, true); |
160 } | 160 } |
161 | 161 |
162 void FileSystemUsageCache::CloseCacheFiles() { | 162 void FileSystemUsageCache::CloseCacheFiles() { |
163 TRACE_EVENT0("FileSystem", "UsageCache::CloseCacheFiles"); | 163 TRACE_EVENT0("FileSystem", "UsageCache::CloseCacheFiles"); |
164 DCHECK(CalledOnValidThread()); | 164 DCHECK(CalledOnValidThread()); |
165 for (CacheFiles::iterator itr = cache_files_.begin(); | 165 for (CacheFiles::iterator itr = cache_files_.begin(); |
166 itr != cache_files_.end(); ++itr) { | 166 itr != cache_files_.end(); ++itr) { |
167 if (itr->second != base::kInvalidPlatformFileValue) | 167 if (itr->second != base::kInvalidPlatformFileValue) |
168 base::ClosePlatformFile(itr->second); | 168 base::ClosePlatformFile(itr->second); |
169 } | 169 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 return !task_runner_.get() || task_runner_->RunsTasksOnCurrentThread(); | 307 return !task_runner_.get() || task_runner_->RunsTasksOnCurrentThread(); |
308 } | 308 } |
309 | 309 |
310 bool FileSystemUsageCache::HasCacheFileHandle(const base::FilePath& file_path) { | 310 bool FileSystemUsageCache::HasCacheFileHandle(const base::FilePath& file_path) { |
311 DCHECK(CalledOnValidThread()); | 311 DCHECK(CalledOnValidThread()); |
312 DCHECK_LE(cache_files_.size(), kMaxHandleCacheSize); | 312 DCHECK_LE(cache_files_.size(), kMaxHandleCacheSize); |
313 return ContainsKey(cache_files_, file_path); | 313 return ContainsKey(cache_files_, file_path); |
314 } | 314 } |
315 | 315 |
316 } // namespace fileapi | 316 } // namespace fileapi |
OLD | NEW |