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

Side by Side Diff: net/disk_cache/mem_backend_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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/entry_unittest.cc ('k') | net/disk_cache/mem_backend_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // See net/disk_cache/disk_cache.h for the public interface of the cache. 5 // See net/disk_cache/disk_cache.h for the public interface of the cache.
6 6
7 #ifndef NET_DISK_CACHE_MEM_BACKEND_IMPL_H__ 7 #ifndef NET_DISK_CACHE_MEM_BACKEND_IMPL_H__
8 #define NET_DISK_CACHE_MEM_BACKEND_IMPL_H__ 8 #define NET_DISK_CACHE_MEM_BACKEND_IMPL_H__
9 9
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
11 11
12 #include "net/disk_cache/disk_cache.h" 12 #include "net/disk_cache/disk_cache.h"
13 #include "net/disk_cache/mem_rankings.h" 13 #include "net/disk_cache/mem_rankings.h"
14 14
15 namespace disk_cache { 15 namespace disk_cache {
16 16
17 class MemEntryImpl; 17 class MemEntryImpl;
18 18
19 // This class implements the Backend interface. An object of this class handles 19 // This class implements the Backend interface. An object of this class handles
20 // the operations of the cache without writting to disk. 20 // the operations of the cache without writing to disk.
21 class MemBackendImpl : public Backend { 21 class MemBackendImpl : public Backend {
22 public: 22 public:
23 MemBackendImpl() : max_size_(0), current_size_(0) {} 23 MemBackendImpl() : max_size_(0), current_size_(0) {}
24 ~MemBackendImpl(); 24 ~MemBackendImpl();
25 25
26 // Performs general initialization for this current instance of the cache. 26 // Performs general initialization for this current instance of the cache.
27 bool Init(); 27 bool Init();
28 28
29 // Backend interface. 29 // Backend interface.
30 virtual int32 GetEntryCount() const; 30 virtual int32 GetEntryCount() const;
(...skipping 17 matching lines...) Expand all
48 48
49 // Updates the ranking information for an entry. 49 // Updates the ranking information for an entry.
50 void UpdateRank(MemEntryImpl* node); 50 void UpdateRank(MemEntryImpl* node);
51 51
52 // A user data block is being created, extended or truncated. 52 // A user data block is being created, extended or truncated.
53 void ModifyStorageSize(int32 old_size, int32 new_size); 53 void ModifyStorageSize(int32 old_size, int32 new_size);
54 54
55 // Returns the maximum size for a file to reside on the cache. 55 // Returns the maximum size for a file to reside on the cache.
56 int MaxFileSize() const; 56 int MaxFileSize() const;
57 57
58 // Insert an MemEntryImpl into the ranking list. This method is only called
59 // from MemEntryImpl to insert child entries. The reference can be removed
60 // by calling RemoveFromRankingList(|entry|).
61 void InsertIntoRankingList(MemEntryImpl* entry);
62
63 // Remove |entry| from ranking list. This method is only called from
64 // MemEntryImpl to remove a child entry from the ranking list.
65 void RemoveFromRankingList(MemEntryImpl* entry);
66
58 private: 67 private:
59 // Deletes entries from the cache until the current size is below the limit. 68 // Deletes entries from the cache until the current size is below the limit.
60 // If empty is true, the whole cache will be trimmed, regardless of being in 69 // If empty is true, the whole cache will be trimmed, regardless of being in
61 // use. 70 // use.
62 void TrimCache(bool empty); 71 void TrimCache(bool empty);
63 72
64 // Handles the used storage count. 73 // Handles the used storage count.
65 void AddStorageSize(int32 bytes); 74 void AddStorageSize(int32 bytes);
66 void SubstractStorageSize(int32 bytes); 75 void SubstractStorageSize(int32 bytes);
67 76
68 typedef base::hash_map<std::string, MemEntryImpl*> EntryMap; 77 typedef base::hash_map<std::string, MemEntryImpl*> EntryMap;
69 78
70 EntryMap entries_; 79 EntryMap entries_;
71 MemRankings rankings_; // Rankings to be able to trim the cache. 80 MemRankings rankings_; // Rankings to be able to trim the cache.
72 int32 max_size_; // Maximum data size for this instance. 81 int32 max_size_; // Maximum data size for this instance.
73 int32 current_size_; 82 int32 current_size_;
74 83
75 DISALLOW_EVIL_CONSTRUCTORS(MemBackendImpl); 84 DISALLOW_EVIL_CONSTRUCTORS(MemBackendImpl);
76 }; 85 };
77 86
78 } // namespace disk_cache 87 } // namespace disk_cache
79 88
80 #endif // NET_DISK_CACHE_MEM_BACKEND_IMPL_H__ 89 #endif // NET_DISK_CACHE_MEM_BACKEND_IMPL_H__
OLDNEW
« no previous file with comments | « net/disk_cache/entry_unittest.cc ('k') | net/disk_cache/mem_backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698