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

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

Issue 14295013: Simple Cache: DoomEntriesBetween() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: first round of comments 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_backend_impl.cc
diff --git a/net/disk_cache/simple/simple_backend_impl.cc b/net/disk_cache/simple/simple_backend_impl.cc
index 06176379a5b3d4bc0eebff201c12203d239d3611..828ea581b4d81127ef3a69e8ca074d08ad645b5f 100644
--- a/net/disk_cache/simple/simple_backend_impl.cc
+++ b/net/disk_cache/simple/simple_backend_impl.cc
@@ -13,6 +13,7 @@
#include "net/base/net_errors.h"
#include "net/disk_cache/simple/simple_entry_impl.h"
#include "net/disk_cache/simple/simple_index.h"
+#include "net/disk_cache/simple/simple_synchronous_entry.h"
using base::FilePath;
using base::MessageLoopProxy;
@@ -71,8 +72,8 @@ net::CacheType SimpleBackendImpl::GetCacheType() const {
}
int32 SimpleBackendImpl::GetEntryCount() const {
- NOTIMPLEMENTED();
- return 0;
+ // TODO(pasko): Use directory file count when index is not ready.
+ return index_->GetEntryCount();
}
int SimpleBackendImpl::OpenEntry(const std::string& key,
@@ -93,23 +94,40 @@ int SimpleBackendImpl::DoomEntry(const std::string& key,
}
int SimpleBackendImpl::DoomAllEntries(const CompletionCallback& callback) {
- NOTIMPLEMENTED();
- return net::ERR_FAILED;
+ return DoomEntriesBetween(Time(), Time(), callback);
+}
+
+void SimpleBackendImpl::IndexReadyForDoom(Time initial_time, Time end_time,
+ const CompletionCallback& callback,
+ int result) {
+ if (result != net::OK) {
+ callback.Run(result);
+ return;
+ }
+ scoped_ptr<std::set<uint64> > key_hashes(
+ index_->ExtractEntriesBetween(initial_time, end_time));
+ WorkerPool::PostTask(FROM_HERE,
+ base::Bind(&SimpleSynchronousEntry::DoomEntrySet,
+ base::Passed(&key_hashes),
+ path_,
+ MessageLoopProxy::current(),
+ callback),
+ true);
}
int SimpleBackendImpl::DoomEntriesBetween(
const Time initial_time,
const Time end_time,
const CompletionCallback& callback) {
- NOTIMPLEMENTED();
- return net::ERR_FAILED;
+ return index_->ExecuteWhenReady(
+ base::Bind(&SimpleBackendImpl::IndexReadyForDoom, AsWeakPtr(),
+ initial_time, end_time, callback));
}
int SimpleBackendImpl::DoomEntriesSince(
const Time initial_time,
const CompletionCallback& callback) {
- NOTIMPLEMENTED();
- return net::ERR_FAILED;
+ return DoomEntriesBetween(initial_time, Time(), callback);
}
int SimpleBackendImpl::OpenNextEntry(void** iter,
@@ -129,7 +147,7 @@ void SimpleBackendImpl::GetStats(
}
void SimpleBackendImpl::OnExternalCacheHit(const std::string& key) {
- NOTIMPLEMENTED();
+ index_->UseIfExists(key);
}
void SimpleBackendImpl::InitializeIndex(

Powered by Google App Engine
This is Rietveld 408576698