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

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

Issue 533293002: Delete enumerations at Simple Cache backend deletion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint Created 6 years, 3 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/backend_unittest.cc ('k') | net/disk_cache/simple/simple_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) 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_BACKEND_IMPL_H_ 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/id_map.h"
16 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
19 #include "base/task_runner.h" 20 #include "base/task_runner.h"
20 #include "base/time/time.h" 21 #include "base/time/time.h"
21 #include "net/base/cache_type.h" 22 #include "net/base/cache_type.h"
22 #include "net/disk_cache/disk_cache.h" 23 #include "net/disk_cache/disk_cache.h"
23 #include "net/disk_cache/simple/simple_entry_impl.h" 24 #include "net/disk_cache/simple/simple_entry_impl.h"
24 #include "net/disk_cache/simple/simple_index_delegate.h" 25 #include "net/disk_cache/simple/simple_index_delegate.h"
25 26
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 virtual int OpenNextEntry(void** iter, Entry** next_entry, 101 virtual int OpenNextEntry(void** iter, Entry** next_entry,
101 const CompletionCallback& callback) OVERRIDE; 102 const CompletionCallback& callback) OVERRIDE;
102 virtual void EndEnumeration(void** iter) OVERRIDE; 103 virtual void EndEnumeration(void** iter) OVERRIDE;
103 virtual void GetStats( 104 virtual void GetStats(
104 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE; 105 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE;
105 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; 106 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE;
106 107
107 private: 108 private:
108 typedef base::hash_map<uint64, SimpleEntryImpl*> EntryMap; 109 typedef base::hash_map<uint64, SimpleEntryImpl*> EntryMap;
109 110
111 typedef IDMap<std::vector<uint64>, IDMapOwnPointer> ActiveEnumerationMap;
112
110 typedef base::Callback<void(base::Time mtime, uint64 max_size, int result)> 113 typedef base::Callback<void(base::Time mtime, uint64 max_size, int result)>
111 InitializeIndexCallback; 114 InitializeIndexCallback;
112 115
113 class ActiveEntryProxy; 116 class ActiveEntryProxy;
114 friend class ActiveEntryProxy; 117 friend class ActiveEntryProxy;
115 118
116 // Return value of InitCacheStructureOnDisk(). 119 // Return value of InitCacheStructureOnDisk().
117 struct DiskStatResult { 120 struct DiskStatResult {
118 base::Time cache_dir_mtime; 121 base::Time cache_dir_mtime;
119 uint64 max_size; 122 uint64 max_size;
120 bool detected_magic_number_mismatch; 123 bool detected_magic_number_mismatch;
121 int net_error; 124 int net_error;
122 }; 125 };
123 126
127 // Convert an iterator from OpenNextEntry() to the key type for
128 // ActiveEnumerationMap. Note it takes a void** argument; this is for safety;
129 // if it took a void*, that would be type compatible with a void** permitting
130 // easy calls missing the dereference.
131 static ActiveEnumerationMap::KeyType IteratorToEnumerationId(void** iter);
132
133 // Convert a key from ActiveEnumerationMap back to a void*, suitable for
134 // storing in the iterator argument to OpenNextEntry().
135 static void* EnumerationIdToIterator(
136 ActiveEnumerationMap::KeyType enumeration_id);
137
124 void InitializeIndex(const CompletionCallback& callback, 138 void InitializeIndex(const CompletionCallback& callback,
125 const DiskStatResult& result); 139 const DiskStatResult& result);
126 140
127 // Dooms all entries previously accessed between |initial_time| and 141 // Dooms all entries previously accessed between |initial_time| and
128 // |end_time|. Invoked when the index is ready. 142 // |end_time|. Invoked when the index is ready.
129 void IndexReadyForDoom(base::Time initial_time, 143 void IndexReadyForDoom(base::Time initial_time,
130 base::Time end_time, 144 base::Time end_time,
131 const CompletionCallback& callback, 145 const CompletionCallback& callback,
132 int result); 146 int result);
133 147
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 const net::CacheType cache_type_; 213 const net::CacheType cache_type_;
200 scoped_ptr<SimpleIndex> index_; 214 scoped_ptr<SimpleIndex> index_;
201 const scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; 215 const scoped_refptr<base::SingleThreadTaskRunner> cache_thread_;
202 scoped_refptr<base::TaskRunner> worker_pool_; 216 scoped_refptr<base::TaskRunner> worker_pool_;
203 217
204 int orig_max_size_; 218 int orig_max_size_;
205 const SimpleEntryImpl::OperationsMode entry_operations_mode_; 219 const SimpleEntryImpl::OperationsMode entry_operations_mode_;
206 220
207 EntryMap active_entries_; 221 EntryMap active_entries_;
208 222
223 // One entry for every enumeration in progress.
224 ActiveEnumerationMap active_enumerations_;
225
209 // The set of all entries which are currently being doomed. To avoid races, 226 // The set of all entries which are currently being doomed. To avoid races,
210 // these entries cannot have Doom/Create/Open operations run until the doom 227 // these entries cannot have Doom/Create/Open operations run until the doom
211 // is complete. The base::Closure map target is used to store deferred 228 // is complete. The base::Closure map target is used to store deferred
212 // operations to be run at the completion of the Doom. 229 // operations to be run at the completion of the Doom.
213 base::hash_map<uint64, std::vector<base::Closure> > entries_pending_doom_; 230 base::hash_map<uint64, std::vector<base::Closure> > entries_pending_doom_;
214 231
215 net::NetLog* const net_log_; 232 net::NetLog* const net_log_;
216 }; 233 };
217 234
218 } // namespace disk_cache 235 } // namespace disk_cache
219 236
220 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ 237 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
OLDNEW
« no previous file with comments | « net/disk_cache/backend_unittest.cc ('k') | net/disk_cache/simple/simple_backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698