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

Side by Side Diff: net/disk_cache/simple/simple_index.h

Issue 14746019: net/disk_cache/simple: Reduce size of EntrySet nodes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: remove comment Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 21 matching lines...) Expand all
32 32
33 namespace base { 33 namespace base {
34 class SingleThreadTaskRunner; 34 class SingleThreadTaskRunner;
35 } 35 }
36 36
37 namespace disk_cache { 37 namespace disk_cache {
38 38
39 class NET_EXPORT_PRIVATE EntryMetadata { 39 class NET_EXPORT_PRIVATE EntryMetadata {
40 public: 40 public:
41 EntryMetadata(); 41 EntryMetadata();
42 EntryMetadata(uint64 hash_key, 42 EntryMetadata(base::Time last_used_time, uint64 entry_size);
43 base::Time last_used_time,
44 uint64 entry_size);
45 43
46 uint64 GetHashKey() const { return hash_key_; }
47 base::Time GetLastUsedTime() const; 44 base::Time GetLastUsedTime() const;
48 void SetLastUsedTime(const base::Time& last_used_time); 45 void SetLastUsedTime(const base::Time& last_used_time);
49 46
50 uint64 GetEntrySize() const { return entry_size_; } 47 uint64 GetEntrySize() const { return entry_size_; }
51 void SetEntrySize(uint64 entry_size) { entry_size_ = entry_size; } 48 void SetEntrySize(uint64 entry_size) { entry_size_ = entry_size; }
52 49
53 // Serialize the data into the provided pickle. 50 // Serialize the data into the provided pickle.
54 void Serialize(Pickle* pickle) const; 51 void Serialize(Pickle* pickle) const;
55 bool Deserialize(PickleIterator* it); 52 bool Deserialize(PickleIterator* it);
56 53
57 // Merge two EntryMetadata instances. 54 // Merge two EntryMetadata instances.
58 // The existing current valid data in |this| will prevail. 55 // The existing current valid data in |this| will prevail.
59 void MergeWith(const EntryMetadata& entry_metadata); 56 void MergeWith(const EntryMetadata& entry_metadata);
60 57
61 private: 58 private:
62 friend class SimpleIndexFileTest; 59 friend class SimpleIndexFileTest;
63 60
64 // When adding new members here, you should update the Serialize() and 61 // When adding new members here, you should update the Serialize() and
65 // Deserialize() methods. 62 // Deserialize() methods.
66 uint64 hash_key_;
67 63
68 // This is the serialized format from Time::ToInternalValue(). 64 // This is the serialized format from Time::ToInternalValue().
69 // If you want to make calculations/comparisons, you should use the 65 // If you want to make calculations/comparisons, you should use the
70 // base::Time() class. Use the GetLastUsedTime() method above. 66 // base::Time() class. Use the GetLastUsedTime() method above.
71 // TODO(felipeg): Use Time() here. 67 // TODO(felipeg): Use Time() here.
72 int64 last_used_time_; 68 int64 last_used_time_;
73 69
74 uint64 entry_size_; // Storage size in bytes. 70 uint64 entry_size_; // Storage size in bytes.
75 }; 71 };
76 72
(...skipping 26 matching lines...) Expand all
103 // Update the size (in bytes) of an entry, in the metadata stored in the 99 // Update the size (in bytes) of an entry, in the metadata stored in the
104 // index. This should be the total disk-file size including all streams of the 100 // index. This should be the total disk-file size including all streams of the
105 // entry. 101 // entry.
106 bool UpdateEntrySize(const std::string& key, uint64 entry_size); 102 bool UpdateEntrySize(const std::string& key, uint64 entry_size);
107 103
108 // TODO(felipeg): This way we are storing the hash_key twice, as the 104 // TODO(felipeg): This way we are storing the hash_key twice, as the
109 // hash_map::key and as a member of EntryMetadata. We could save space if we 105 // hash_map::key and as a member of EntryMetadata. We could save space if we
110 // use a hash_set. 106 // use a hash_set.
111 typedef base::hash_map<uint64, EntryMetadata> EntrySet; 107 typedef base::hash_map<uint64, EntryMetadata> EntrySet;
112 108
113 static void InsertInEntrySet(const EntryMetadata& entry_metadata, 109 static void InsertInEntrySet(uint64 hash_key,
110 const EntryMetadata& entry_metadata,
114 EntrySet* entry_set); 111 EntrySet* entry_set);
115 112
116 // Executes the |callback| when the index is ready. Allows multiple callbacks. 113 // Executes the |callback| when the index is ready. Allows multiple callbacks.
117 int ExecuteWhenReady(const net::CompletionCallback& callback); 114 int ExecuteWhenReady(const net::CompletionCallback& callback);
118 115
119 // Takes out entries from the index that have last accessed time matching the 116 // Takes out entries from the index that have last accessed time matching the
120 // range between |initial_time| and |end_time| where open intervals are 117 // range between |initial_time| and |end_time| where open intervals are
121 // possible according to the definition given in |DoomEntriesBetween()| in the 118 // possible according to the definition given in |DoomEntriesBetween()| in the
122 // disk cache backend interface. Returns the set of hashes taken out. 119 // disk cache backend interface. Returns the set of hashes taken out.
123 scoped_ptr<std::vector<uint64> > RemoveEntriesBetween( 120 scoped_ptr<std::vector<uint64> > RemoveEntriesBetween(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 197
201 // Set to true when the app is on the background. When the app is in the 198 // Set to true when the app is on the background. When the app is in the
202 // background we can write the index much more frequently, to insure fresh 199 // background we can write the index much more frequently, to insure fresh
203 // index on next startup. 200 // index on next startup.
204 bool app_on_background_; 201 bool app_on_background_;
205 }; 202 };
206 203
207 } // namespace disk_cache 204 } // namespace disk_cache
208 205
209 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 206 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_index.cc » ('j') | net/disk_cache/simple/simple_index.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698