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

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

Issue 14295013: Simple Cache: DoomEntriesBetween() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: first round of comments Created 7 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 | Annotate | Revision Log
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 <map> 8 #include <list>
9 #include <set>
9 #include <string> 10 #include <string>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
14 #include "base/hash_tables.h" 15 #include "base/hash_tables.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
18 #include "base/time.h" 19 #include "base/time.h"
20 #include "net/base/completion_callback.h"
19 #include "net/base/net_export.h" 21 #include "net/base/net_export.h"
20 22
21 class Pickle; 23 class Pickle;
22 class PickleIterator; 24 class PickleIterator;
23 25
24 namespace base { 26 namespace base {
25 class TaskRunner; 27 class TaskRunner;
26 } 28 }
27 29
28 namespace disk_cache { 30 namespace disk_cache {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 bool UpdateEntrySize(const std::string& key, uint64 entry_size); 96 bool UpdateEntrySize(const std::string& key, uint64 entry_size);
95 97
96 // TODO(felipeg): This way we are storing the hash_key twice, as the 98 // TODO(felipeg): This way we are storing the hash_key twice, as the
97 // hash_map::key and as a member of EntryMetadata. We could save space if we 99 // hash_map::key and as a member of EntryMetadata. We could save space if we
98 // use a hash_set. 100 // use a hash_set.
99 typedef base::hash_map<uint64, EntryMetadata> EntrySet; 101 typedef base::hash_map<uint64, EntryMetadata> EntrySet;
100 102
101 static void InsertInEntrySet(const EntryMetadata& entry_metadata, 103 static void InsertInEntrySet(const EntryMetadata& entry_metadata,
102 EntrySet* entry_set); 104 EntrySet* entry_set);
103 105
106 // Executes the |callback| when the index is ready. Allows multiple callbacks.
107 int ExecuteWhenReady(const net::CompletionCallback& callback);
108
109 // Takes out entries from the index that have last accessed time matching the
110 // range between |initial_time| and |end_time| where open intervals are
111 // possible according to the definition given in |DoomEntriesBetween()| in the
112 // disk cache backend interface. Returns the set of hashes taken out.
113 std::set<uint64>* ExtractEntriesBetween(const base::Time initial_time,
114 const base::Time end_time);
115
116 // Returns number of indexed entries.
117 int32 GetEntryCount() const;
118
104 private: 119 private:
105 typedef base::Callback<void(scoped_ptr<EntrySet>)> IndexCompletionCallback; 120 typedef base::Callback<void(scoped_ptr<EntrySet>)> IndexCompletionCallback;
106 121
107 virtual ~SimpleIndex(); 122 virtual ~SimpleIndex();
108 123
109 static void LoadFromDisk( 124 static void LoadFromDisk(
110 const base::FilePath& index_filename, 125 const base::FilePath& index_filename,
111 const scoped_refptr<base::TaskRunner>& io_thread, 126 const scoped_refptr<base::TaskRunner>& io_thread,
112 const IndexCompletionCallback& completion_callback); 127 const IndexCompletionCallback& completion_callback);
113 128
(...skipping 16 matching lines...) Expand all
130 bool initialized_; 145 bool initialized_;
131 146
132 base::FilePath index_filename_; 147 base::FilePath index_filename_;
133 148
134 scoped_refptr<base::TaskRunner> cache_thread_; 149 scoped_refptr<base::TaskRunner> cache_thread_;
135 scoped_refptr<base::TaskRunner> io_thread_; 150 scoped_refptr<base::TaskRunner> io_thread_;
136 151
137 // All nonstatic SimpleEntryImpl methods should always be called on the IO 152 // All nonstatic SimpleEntryImpl methods should always be called on the IO
138 // thread, in all cases. |io_thread_checker_| documents and enforces this. 153 // thread, in all cases. |io_thread_checker_| documents and enforces this.
139 base::ThreadChecker io_thread_checker_; 154 base::ThreadChecker io_thread_checker_;
155
156 typedef std::list<net::CompletionCallback> CallbackList;
157 CallbackList to_run_when_initialized_;
140 }; 158 };
141 159
142 } // namespace disk_cache 160 } // namespace disk_cache
143 161
144 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 162 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698