summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-08 20:34:34 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-08 20:34:34 +0000
commit0b2b728a2b624bcfea3f68dd14a67736e066b4d9 (patch)
tree6fca11b276da9a5f1d2459006a92091296179a66 /net/disk_cache
parent5af2edb98c8ebde32dcc51dcde9b02bea82468a3 (diff)
downloadchromium_src-0b2b728a2b624bcfea3f68dd14a67736e066b4d9.zip
chromium_src-0b2b728a2b624bcfea3f68dd14a67736e066b4d9.tar.gz
chromium_src-0b2b728a2b624bcfea3f68dd14a67736e066b4d9.tar.bz2
Stop using SHFileOperation from the disk cache code.
Using SHFileOperation to delete old cache files has the disadvantage that once in a while somebody decides to perform COM operations assuming STA, and that doesn't work with the worker pool. BUG=1314744 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r--net/disk_cache/backend_impl.cc26
1 files changed, 16 insertions, 10 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index 930f4a3..0a09148 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -97,6 +97,20 @@ bool DeleteFiles(const wchar_t* path, const wchar_t* search_name) {
return true;
}
+// Deletes the cache files stored on |path|, and optionally also attempts to
+// delete the folder itself.
+void DeleteCache(const std::wstring& path, bool remove_folder) {
+ DeleteFiles(path.c_str(), L"\\f_*");
+ DeleteFiles(path.c_str(), L"\\data_*");
+
+ std::wstring index(path);
+ file_util::AppendToPath(&index, kIndexName);
+ DeleteFile(index.c_str());
+
+ if (remove_folder)
+ RemoveDirectory(path.c_str());
+}
+
int LowWaterAdjust(int high_water) {
if (high_water < kCleanUpMargin)
return 0;
@@ -134,10 +148,7 @@ class CleanupTask : public Task {
void CleanupTask::Run() {
for (int i = 0; i < kMaxOldFolders; i++) {
std::wstring to_delete = GetPrefixedName(path_, name_, i);
-
- // We do not create subfolders on the cache. If there is any subfolder, it
- // was created by someone else so we don't want to delete it.
- file_util::Delete(to_delete, false);
+ DeleteCache(to_delete, true);
}
}
@@ -418,12 +429,7 @@ bool BackendImpl::DoomAllEntries() {
index_ = NULL;
block_files_.CloseFiles();
rankings_.Reset();
- DeleteFiles(path_.c_str(), L"\\f_*");
- DeleteFiles(path_.c_str(), L"\\data_*");
-
- std::wstring index(path_);
- file_util::AppendToPath(&index, kIndexName);
- DeleteFile(index.c_str());
+ DeleteCache(path_.c_str(), false);
init_ = false;
restarted_ = true;
return Init();