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

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

Issue 2789683002: Speed up SimpleCache eviction set computation (Closed)
Patch Set: git cl try Created 3 years, 8 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
« no previous file with comments | « net/disk_cache/disk_cache_perftest.cc ('k') | net/disk_cache/simple/simple_index.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) 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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 class NET_EXPORT_PRIVATE EntryMetadata { 45 class NET_EXPORT_PRIVATE EntryMetadata {
46 public: 46 public:
47 EntryMetadata(); 47 EntryMetadata();
48 EntryMetadata(base::Time last_used_time, 48 EntryMetadata(base::Time last_used_time,
49 base::StrictNumeric<uint32_t> entry_size); 49 base::StrictNumeric<uint32_t> entry_size);
50 50
51 base::Time GetLastUsedTime() const; 51 base::Time GetLastUsedTime() const;
52 void SetLastUsedTime(const base::Time& last_used_time); 52 void SetLastUsedTime(const base::Time& last_used_time);
53 53
54 uint32_t RawTimeForSorting() const {
55 return last_used_time_seconds_since_epoch_;
56 }
57
54 uint32_t GetEntrySize() const; 58 uint32_t GetEntrySize() const;
55 void SetEntrySize(base::StrictNumeric<uint32_t> entry_size); 59 void SetEntrySize(base::StrictNumeric<uint32_t> entry_size);
56 60
57 // Serialize the data into the provided pickle. 61 // Serialize the data into the provided pickle.
58 void Serialize(base::Pickle* pickle) const; 62 void Serialize(base::Pickle* pickle) const;
59 bool Deserialize(base::PickleIterator* it); 63 bool Deserialize(base::PickleIterator* it);
60 64
61 static base::TimeDelta GetLowerEpsilonForTimeComparisons() { 65 static base::TimeDelta GetLowerEpsilonForTimeComparisons() {
62 return base::TimeDelta::FromSeconds(1); 66 return base::TimeDelta::FromSeconds(1);
63 } 67 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // entry. 132 // entry.
129 bool UpdateEntrySize(uint64_t entry_hash, 133 bool UpdateEntrySize(uint64_t entry_hash,
130 base::StrictNumeric<uint32_t> entry_size); 134 base::StrictNumeric<uint32_t> entry_size);
131 135
132 using EntrySet = std::unordered_map<uint64_t, EntryMetadata>; 136 using EntrySet = std::unordered_map<uint64_t, EntryMetadata>;
133 137
134 static void InsertInEntrySet(uint64_t entry_hash, 138 static void InsertInEntrySet(uint64_t entry_hash,
135 const EntryMetadata& entry_metadata, 139 const EntryMetadata& entry_metadata,
136 EntrySet* entry_set); 140 EntrySet* entry_set);
137 141
142 // For use in tests only. Updates cache_size_, but will not start evictions
143 // or adjust index writing time. Requires entry to not already be in the set.
144 void InsertEntryForTesting(uint64_t entry_hash,
145 const EntryMetadata& entry_metadata);
146
138 // Executes the |callback| when the index is ready. Allows multiple callbacks. 147 // Executes the |callback| when the index is ready. Allows multiple callbacks.
139 int ExecuteWhenReady(const net::CompletionCallback& callback); 148 int ExecuteWhenReady(const net::CompletionCallback& callback);
140 149
141 // Returns entries from the index that have last accessed time matching the 150 // Returns entries from the index that have last accessed time matching the
142 // range between |initial_time| and |end_time| where open intervals are 151 // range between |initial_time| and |end_time| where open intervals are
143 // possible according to the definition given in |DoomEntriesBetween()| in the 152 // possible according to the definition given in |DoomEntriesBetween()| in the
144 // disk cache backend interface. 153 // disk cache backend interface.
145 std::unique_ptr<HashList> GetEntriesBetween(const base::Time initial_time, 154 std::unique_ptr<HashList> GetEntriesBetween(const base::Time initial_time,
146 const base::Time end_time); 155 const base::Time end_time);
147 156
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 243
235 // Set to true when the app is on the background. When the app is in the 244 // Set to true when the app is on the background. When the app is in the
236 // background we can write the index much more frequently, to insure fresh 245 // background we can write the index much more frequently, to insure fresh
237 // index on next startup. 246 // index on next startup.
238 bool app_on_background_; 247 bool app_on_background_;
239 }; 248 };
240 249
241 } // namespace disk_cache 250 } // namespace disk_cache
242 251
243 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 252 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
OLDNEW
« no previous file with comments | « net/disk_cache/disk_cache_perftest.cc ('k') | net/disk_cache/simple/simple_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698