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

Unified Diff: net/disk_cache/mem_entry_impl.h

Issue 120004: Introduce parent and child entries for MemEntryImpl... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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/mem_backend_impl.cc ('k') | net/disk_cache/mem_entry_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/mem_entry_impl.h
===================================================================
--- net/disk_cache/mem_entry_impl.h (revision 18335)
+++ net/disk_cache/mem_entry_impl.h (working copy)
@@ -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 @@
// 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 @@
prev_ = prev;
}
- void Open();
- bool InUse();
+ EntryType type() const {
+ return type_;
+ }
private:
enum {
@@ -81,14 +109,16 @@
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_
« no previous file with comments | « net/disk_cache/mem_backend_impl.cc ('k') | net/disk_cache/mem_entry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698