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

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

Issue 23486006: Track entries pending Doom in SimpleCache backend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediation and test update Created 7 years, 4 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.h
diff --git a/net/disk_cache/simple/simple_backend_impl.h b/net/disk_cache/simple/simple_backend_impl.h
index 4f01351752e1bd80893966732bca1a5f5d448f15..b7b4eeb5793faf99308f64b065be11cb8f16b25d 100644
--- a/net/disk_cache/simple/simple_backend_impl.h
+++ b/net/disk_cache/simple/simple_backend_impl.h
@@ -9,6 +9,7 @@
#include <utility>
#include <vector>
+#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/containers/hash_tables.h"
#include "base/files/file_path.h"
@@ -64,6 +65,15 @@ class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend,
// operations to construct a new object.
void OnDeactivated(const SimpleEntryImpl* entry);
+ // The entry for |entry_hash| is being doomed; the backend will not attempt
+ // run new operations for this |entry_hash| until the Doom is completed.
+ void OnDoomStart(uint64 entry_hash);
+
+ // The entry for |entry_hash| has been successfully doomed, we can now allow
+ // operations on this entry, and we can run any operations enqueued while the
+ // doom completed.
+ void OnDoomComplete(uint64 entry_hash);
+
// Backend:
virtual net::CacheType GetCacheType() const OVERRIDE;
virtual int32 GetEntryCount() const OVERRIDE;
@@ -118,6 +128,7 @@ class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend,
// Searches |active_entries_| for the entry corresponding to |key|. If found,
// returns the found entry. Otherwise, creates a new entry and returns that.
scoped_refptr<SimpleEntryImpl> CreateOrFindActiveEntry(
+ uint64 entry_hash,
const std::string& key);
// Given a hash, will try to open the corresponding Entry. If we have an Entry
@@ -170,10 +181,14 @@ class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend,
int orig_max_size_;
const SimpleEntryImpl::OperationsMode entry_operations_mode_;
- // TODO(gavinp): Store the entry_hash in SimpleEntryImpl, and index this map
- // by hash. This will save memory, and make IndexReadyForDoom easier.
EntryMap active_entries_;
+ // The set of all entries which are currently being doomed. To avoid races,
+ // these entries cannot have Doom/Create/Open operations run until the doom
+ // is complete. The base::Closure map target is used to store deferred
+ // operations to be run at the completion of the Doom.
+ base::hash_map<uint64, base::Closure> entries_pending_doom_;
+
net::NetLog* const net_log_;
};

Powered by Google App Engine
This is Rietveld 408576698