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

Unified Diff: net/disk_cache/simple/simple_synchronous_entry.cc

Issue 14295013: Simple Cache: DoomEntriesBetween() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix an actual bug in DoomEntry Created 7 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/simple/simple_synchronous_entry.h ('k') | net/disk_cache/simple/simple_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_synchronous_entry.cc
diff --git a/net/disk_cache/simple/simple_synchronous_entry.cc b/net/disk_cache/simple/simple_synchronous_entry.cc
index 41c8d8d3443c8288e866db7a77fd44cb9ed59eb7..f4bca0337ca905f03c30ee1ac4645395fd8473e1 100644
--- a/net/disk_cache/simple/simple_synchronous_entry.cc
+++ b/net/disk_cache/simple/simple_synchronous_entry.cc
@@ -40,6 +40,9 @@ using base::WritePlatformFile;
namespace disk_cache {
+using simple_util::ConvertEntryHashKeyToHexString;
+using simple_util::GetEntryHashKeyAsHexString;
+using simple_util::GetFilenameFromHexStringAndIndex;
using simple_util::GetFilenameFromKeyAndIndex;
using simple_util::GetDataSizeFromKeyAndFileSize;
using simple_util::GetFileSizeFromKeyAndDataSize;
@@ -82,18 +85,47 @@ void SimpleSynchronousEntry::CreateEntry(
}
// static
+bool SimpleSynchronousEntry::DeleteFilesForEntry(const FilePath& path,
+ const std::string& hash_key) {
+ bool result = true;
+ for (int i = 0; i < kSimpleEntryFileCount; ++i) {
+ FilePath to_delete = path.AppendASCII(
+ GetFilenameFromHexStringAndIndex(hash_key, i));
+ if (!file_util::Delete(to_delete, false)) {
+ result = false;
+ DLOG(ERROR) << "Could not delete " << to_delete.MaybeAsASCII();
+ }
+ }
+ return result;
+}
+
+// static
void SimpleSynchronousEntry::DoomEntry(
const FilePath& path,
const std::string& key,
SingleThreadTaskRunner* callback_runner,
const net::CompletionCallback& callback) {
- for (int i = 0; i < kSimpleEntryFileCount; ++i) {
- FilePath to_delete = path.AppendASCII(GetFilenameFromKeyAndIndex(key, i));
- bool ALLOW_UNUSED result = file_util::Delete(to_delete, false);
- DLOG_IF(ERROR, !result) << "Could not delete " << to_delete.MaybeAsASCII();
- }
+ bool deleted_well = DeleteFilesForEntry(path,
+ GetEntryHashKeyAsHexString(key));
+ int result = deleted_well ? net::OK : net::ERR_FAILED;
+ if (!callback.is_null())
+ callback_runner->PostTask(FROM_HERE, base::Bind(callback, result));
+}
+
+// static
+void SimpleSynchronousEntry::DoomEntrySet(
+ scoped_ptr<std::vector<uint64> > key_hashes,
+ const FilePath& path,
+ SingleThreadTaskRunner* callback_runner,
+ const net::CompletionCallback& callback) {
+ bool deleted_well = true;
+ for (std::vector<uint64>::const_iterator it = key_hashes->begin(),
+ end = key_hashes->end(); it != end; ++it)
+ deleted_well &= DeleteFilesForEntry(path,
+ ConvertEntryHashKeyToHexString((*it)));
+ int result = deleted_well ? net::OK : net::ERR_FAILED;
if (!callback.is_null())
- callback_runner->PostTask(FROM_HERE, base::Bind(callback, net::OK));
+ callback_runner->PostTask(FROM_HERE, base::Bind(callback, result));
}
void SimpleSynchronousEntry::Close() {
@@ -301,8 +333,7 @@ int SimpleSynchronousEntry::InitializeForCreate() {
void SimpleSynchronousEntry::Doom() {
// TODO(gavinp): Consider if we should guard against redundant Doom() calls.
- DoomEntry(path_, key_,
- scoped_refptr<SingleThreadTaskRunner>(), net::CompletionCallback());
+ DeleteFilesForEntry(path_, GetEntryHashKeyAsHexString(key_));
}
} // namespace disk_cache
« no previous file with comments | « net/disk_cache/simple/simple_synchronous_entry.h ('k') | net/disk_cache/simple/simple_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698