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

Side by Side Diff: storage/browser/fileapi/file_system_usage_cache.cc

Issue 1471073008: Do not do unnecessary recursive deletes for files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years 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
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 "storage/browser/fileapi/file_system_usage_cache.h" 5 #include "storage/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/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 bool FileSystemUsageCache::Exists(const base::FilePath& usage_file_path) { 144 bool FileSystemUsageCache::Exists(const base::FilePath& usage_file_path) {
145 TRACE_EVENT0("FileSystem", "UsageCache::Exists"); 145 TRACE_EVENT0("FileSystem", "UsageCache::Exists");
146 DCHECK(CalledOnValidThread()); 146 DCHECK(CalledOnValidThread());
147 return base::PathExists(usage_file_path); 147 return base::PathExists(usage_file_path);
148 } 148 }
149 149
150 bool FileSystemUsageCache::Delete(const base::FilePath& usage_file_path) { 150 bool FileSystemUsageCache::Delete(const base::FilePath& usage_file_path) {
151 TRACE_EVENT0("FileSystem", "UsageCache::Delete"); 151 TRACE_EVENT0("FileSystem", "UsageCache::Delete");
152 DCHECK(CalledOnValidThread()); 152 DCHECK(CalledOnValidThread());
153 CloseCacheFiles(); 153 CloseCacheFiles();
154 return base::DeleteFile(usage_file_path, true); 154 return base::DeleteFile(usage_file_path, false);
155 } 155 }
156 156
157 void FileSystemUsageCache::CloseCacheFiles() { 157 void FileSystemUsageCache::CloseCacheFiles() {
158 TRACE_EVENT0("FileSystem", "UsageCache::CloseCacheFiles"); 158 TRACE_EVENT0("FileSystem", "UsageCache::CloseCacheFiles");
159 DCHECK(CalledOnValidThread()); 159 DCHECK(CalledOnValidThread());
160 STLDeleteValues(&cache_files_); 160 STLDeleteValues(&cache_files_);
161 timer_.reset(); 161 timer_.reset();
162 } 162 }
163 163
164 bool FileSystemUsageCache::Read(const base::FilePath& usage_file_path, 164 bool FileSystemUsageCache::Read(const base::FilePath& usage_file_path,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 return !task_runner_.get() || task_runner_->RunsTasksOnCurrentThread(); 293 return !task_runner_.get() || task_runner_->RunsTasksOnCurrentThread();
294 } 294 }
295 295
296 bool FileSystemUsageCache::HasCacheFileHandle(const base::FilePath& file_path) { 296 bool FileSystemUsageCache::HasCacheFileHandle(const base::FilePath& file_path) {
297 DCHECK(CalledOnValidThread()); 297 DCHECK(CalledOnValidThread());
298 DCHECK_LE(cache_files_.size(), kMaxHandleCacheSize); 298 DCHECK_LE(cache_files_.size(), kMaxHandleCacheSize);
299 return ContainsKey(cache_files_, file_path); 299 return ContainsKey(cache_files_, file_path);
300 } 300 }
301 301
302 } // namespace storage 302 } // namespace storage
OLDNEW
« no previous file with comments | « chrome/installer/util/copy_tree_work_item_unittest.cc ('k') | storage/browser/fileapi/obfuscated_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698