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

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: 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
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 11a742199335d65dbd6af118ca01d15467ad2074..b9051eafe6586988bb4248e9c17c28c8b6ddeeca 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,
scoped_refptr<TaskRunner> 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::set<uint64> > key_hashes,
+ const FilePath& path,
+ scoped_refptr<TaskRunner> callback_runner,
+ const net::CompletionCallback& callback) {
+ bool deleted_well = true;
+ for (std::set<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() {

Powered by Google App Engine
This is Rietveld 408576698