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

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: 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 <list>
8 #include <map> 9 #include <map>
gavinp 2013/04/17 07:41:18 While we're here, I believe this isn't needed any
pasko-google - do not use 2013/04/17 19:47:52 Done.
10 #include <set>
9 #include <string> 11 #include <string>
10 12
11 #include "base/basictypes.h" 13 #include "base/basictypes.h"
12 #include "base/callback.h" 14 #include "base/callback.h"
13 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
14 #include "base/hash_tables.h" 16 #include "base/hash_tables.h"
15 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
18 #include "base/time.h" 20 #include "base/time.h"
21 #include "net/base/completion_callback.h"
19 #include "net/base/net_export.h" 22 #include "net/base/net_export.h"
20 23
21 class Pickle; 24 class Pickle;
22 class PickleIterator; 25 class PickleIterator;
23 26
24 namespace base { 27 namespace base {
25 class TaskRunner; 28 class TaskRunner;
26 } 29 }
27 30
28 namespace disk_cache { 31 namespace disk_cache {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool UpdateEntrySize(const std::string& key, uint64 entry_size); 98 bool UpdateEntrySize(const std::string& key, uint64 entry_size);
96 99
97 // TODO(felipeg): This way we are storing the hash_key twice, as the 100 // TODO(felipeg): This way we are storing the hash_key twice, as the
98 // hash_map::key and as a member of EntryMetadata. We could save space if we 101 // hash_map::key and as a member of EntryMetadata. We could save space if we
99 // use a hash_set. 102 // use a hash_set.
100 typedef base::hash_map<uint64, EntryMetadata> EntrySet; 103 typedef base::hash_map<uint64, EntryMetadata> EntrySet;
101 104
102 static void InsertInEntrySet(const EntryMetadata& entry_metadata, 105 static void InsertInEntrySet(const EntryMetadata& entry_metadata,
103 EntrySet* entry_set); 106 EntrySet* entry_set);
104 107
108 // Executes the |callback| when the index is ready. Allows multiple callbacks.
109 int ExecuteWhenReady(const net::CompletionCallback& callback);
110
111 // Takes out entries from the index that have last accessed time matching the
112 // range between |initial_time| and |end_time| where open intervals are
113 // possible according to the definition given in |DoomEntriesBetween()| in the
114 // disk cache backend interface. Returns the set of hashes taken out.
115 std::set<uint64>* PullEntriesBetween(const base::Time initial_time,
gavinp 2013/04/17 07:41:18 Rather than referencing the definition in |DoomEnt
pasko-google - do not use 2013/04/17 19:47:52 That? Will change? C'mon, backend interface change
116 const base::Time end_time);
117
118 // Returns amount of indexed entries.
gavinp 2013/04/17 07:41:18 // Returns number of indexed entries.
pasko-google - do not use 2013/04/17 19:47:52 Done.
119 int32 GetEntryCount() const;
120
105 private: 121 private:
106 typedef base::Callback<void(scoped_ptr<EntrySet>)> IndexCompletionCallback; 122 typedef base::Callback<void(scoped_ptr<EntrySet>)> IndexCompletionCallback;
107 123
108 static void LoadFromDisk( 124 static void LoadFromDisk(
109 const base::FilePath& index_filename, 125 const base::FilePath& index_filename,
110 const scoped_refptr<base::TaskRunner>& io_thread, 126 const scoped_refptr<base::TaskRunner>& io_thread,
111 const IndexCompletionCallback& completion_callback); 127 const IndexCompletionCallback& completion_callback);
112 128
113 // Enumerates all entries' files on disk and regenerates the index. 129 // Enumerates all entries' files on disk and regenerates the index.
114 static scoped_ptr<SimpleIndex::EntrySet> RestoreFromDisk( 130 static scoped_ptr<SimpleIndex::EntrySet> RestoreFromDisk(
(...skipping 14 matching lines...) Expand all
129 bool initialized_; 145 bool initialized_;
130 146
131 base::FilePath index_filename_; 147 base::FilePath index_filename_;
132 148
133 scoped_refptr<base::TaskRunner> cache_thread_; 149 scoped_refptr<base::TaskRunner> cache_thread_;
134 scoped_refptr<base::TaskRunner> io_thread_; 150 scoped_refptr<base::TaskRunner> io_thread_;
135 151
136 // All nonstatic SimpleEntryImpl methods should always be called on the IO 152 // All nonstatic SimpleEntryImpl methods should always be called on the IO
137 // thread, in all cases. |io_thread_checker_| documents and enforces this. 153 // thread, in all cases. |io_thread_checker_| documents and enforces this.
138 base::ThreadChecker io_thread_checker_; 154 base::ThreadChecker io_thread_checker_;
155
156 typedef std::list<net::CompletionCallback> CallbackList;
gavinp 2013/04/17 07:41:18 Take it or leave it suggestion: lose this typedef.
pasko-google - do not use 2013/04/17 19:47:52 Please remind me when we transition to C++11, I'd
157 CallbackList initialized_waitlist_;
gavinp 2013/04/17 07:41:18 Naming suggestion: to_run_when_initialized_ (with
pasko-google - do not use 2013/04/17 19:47:52 OK, taking this. I liked how waitlist sounded, it
139 }; 158 };
140 159
141 } // namespace disk_cache 160 } // namespace disk_cache
142 161
143 #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