summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/mem_entry_impl.h
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-15 20:41:30 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-15 20:41:30 +0000
commit658c173725ff824f22a103e2e984ef580260d593 (patch)
tree8fd52c1325e78c3f80b889fe8d9b2535e30442cd /net/disk_cache/mem_entry_impl.h
parentaf97358f77a8cd000e37d05ec204f8d3f6cc62e7 (diff)
downloadchromium_src-658c173725ff824f22a103e2e984ef580260d593.zip
chromium_src-658c173725ff824f22a103e2e984ef580260d593.tar.gz
chromium_src-658c173725ff824f22a103e2e984ef580260d593.tar.bz2
Introduce parent and child entries for MemEntryImpl
Defines enums for kParentEntry and kChildEntry in MemEntryImpl. Also has code in MemBackendImpl to create a slave entry. Parent entries are non-sparse entries until sparse API are called on them, and they would start to keep a list of child entries. Child entries hold partial content and are not susposed to be accessible from the public and are managed by the parent entry that created it. Child entries are registered in the backend's ranking list to allow individual eviction. More details about how child entries are to be used are in the comments. TEST=DiskCacheEntryTest.MemoryOnlyEnumerationWithSlaveEntries Review URL: http://codereview.chromium.org/120004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18432 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/mem_entry_impl.h')
-rw-r--r--net/disk_cache/mem_entry_impl.h48
1 files changed, 39 insertions, 9 deletions
diff --git a/net/disk_cache/mem_entry_impl.h b/net/disk_cache/mem_entry_impl.h
index 65eb450..c63f928 100644
--- a/net/disk_cache/mem_entry_impl.h
+++ b/net/disk_cache/mem_entry_impl.h
@@ -1,20 +1,38 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_DISK_CACHE_MEM_ENTRY_IMPL_H__
-#define NET_DISK_CACHE_MEM_ENTRY_IMPL_H__
+#ifndef NET_DISK_CACHE_MEM_ENTRY_IMPL_H_
+#define NET_DISK_CACHE_MEM_ENTRY_IMPL_H_
#include "net/disk_cache/disk_cache.h"
+#include "testing/gtest/include/gtest/gtest_prod.h"
namespace disk_cache {
class MemBackendImpl;
// This class implements the Entry interface for the memory-only cache. An
-// object of this class represents a single entry on the cache.
+// object of this class represents a single entry on the cache. We use two
+// types of entries, parent and child to support sparse caching.
+// A parent entry is non-sparse until a sparse method is invoked (i.e.
+// ReadSparseData, WriteSparseData, GetAvailableRange) when sparse information
+// is initialized. It then manages a list of child entries and delegates the
+// sparse API calls to the child entries. It creates and deletes child entries
+// and updates the list when needed.
+// A child entry is used to carry partial cache content, non-sparse methods like
+// ReadData and WriteData cannot be applied to them. The lifetime of a child
+// entry is managed by the parent entry that created it except that the entry
+// can be evicted independently. A child entry does not have a key and it is not
+// registered in the backend's entry map. It is registered in the backend's
+// ranking list to enable eviction of a partial content.
class MemEntryImpl : public Entry {
public:
+ enum EntryType {
+ kParentEntry,
+ kChildEntry,
+ };
+
explicit MemEntryImpl(MemBackendImpl* backend);
// Entry interface.
@@ -39,9 +57,18 @@ class MemEntryImpl : public Entry {
// cache.
bool CreateEntry(const std::string& key);
- // Permamently destroys this entry
+ // Performs the initialization of a MemEntryImpl as a child entry.
+ // TODO(hclam): this method should be private. Leave this as public because
+ // this is the only way to create a child entry. Move this method to private
+ // once child entries are created by parent entry.
+ bool CreateChildEntry(MemEntryImpl* parent);
+
+ // Permanently destroys this entry.
void InternalDoom();
+ void Open();
+ bool InUse();
+
MemEntryImpl* next() const {
return next_;
}
@@ -58,8 +85,9 @@ class MemEntryImpl : public Entry {
prev_ = prev;
}
- void Open();
- bool InUse();
+ EntryType type() const {
+ return type_;
+ }
private:
enum {
@@ -81,14 +109,16 @@ class MemEntryImpl : public Entry {
MemEntryImpl* next_; // Pointers for the LRU list.
MemEntryImpl* prev_;
- base::Time last_modified_; // LRU information.
+ MemEntryImpl* parent_; // Pointer to the parent entry.
+ base::Time last_modified_; // LRU information.
base::Time last_used_;
MemBackendImpl* backend_; // Back pointer to the cache.
bool doomed_; // True if this entry was removed from the cache.
+ EntryType type_; // The type of this entry.
DISALLOW_EVIL_CONSTRUCTORS(MemEntryImpl);
};
} // namespace disk_cache
-#endif // NET_DISK_CACHE_MEM_ENTRY_IMPL_H__
+#endif // NET_DISK_CACHE_MEM_ENTRY_IMPL_H_