OLD | NEW |
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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 #include <utility> | 12 #include <utility> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/callback_forward.h" | 15 #include "base/callback_forward.h" |
15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
16 #include "base/containers/hash_tables.h" | 17 #include "base/containers/hash_tables.h" |
17 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
18 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
19 #include "base/memory/scoped_ptr.h" | |
20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
21 #include "base/strings/string_split.h" | 21 #include "base/strings/string_split.h" |
22 #include "base/task_runner.h" | 22 #include "base/task_runner.h" |
23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
24 #include "net/base/cache_type.h" | 24 #include "net/base/cache_type.h" |
25 #include "net/disk_cache/disk_cache.h" | 25 #include "net/disk_cache/disk_cache.h" |
26 #include "net/disk_cache/simple/simple_entry_impl.h" | 26 #include "net/disk_cache/simple/simple_entry_impl.h" |
27 #include "net/disk_cache/simple/simple_index_delegate.h" | 27 #include "net/disk_cache/simple/simple_index_delegate.h" |
28 | 28 |
29 namespace base { | 29 namespace base { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 const CompletionCallback& callback) override; | 101 const CompletionCallback& callback) override; |
102 int DoomEntry(const std::string& key, | 102 int DoomEntry(const std::string& key, |
103 const CompletionCallback& callback) override; | 103 const CompletionCallback& callback) override; |
104 int DoomAllEntries(const CompletionCallback& callback) override; | 104 int DoomAllEntries(const CompletionCallback& callback) override; |
105 int DoomEntriesBetween(base::Time initial_time, | 105 int DoomEntriesBetween(base::Time initial_time, |
106 base::Time end_time, | 106 base::Time end_time, |
107 const CompletionCallback& callback) override; | 107 const CompletionCallback& callback) override; |
108 int DoomEntriesSince(base::Time initial_time, | 108 int DoomEntriesSince(base::Time initial_time, |
109 const CompletionCallback& callback) override; | 109 const CompletionCallback& callback) override; |
110 int CalculateSizeOfAllEntries(const CompletionCallback& callback) override; | 110 int CalculateSizeOfAllEntries(const CompletionCallback& callback) override; |
111 scoped_ptr<Iterator> CreateIterator() override; | 111 std::unique_ptr<Iterator> CreateIterator() override; |
112 void GetStats(base::StringPairs* stats) override; | 112 void GetStats(base::StringPairs* stats) override; |
113 void OnExternalCacheHit(const std::string& key) override; | 113 void OnExternalCacheHit(const std::string& key) override; |
114 | 114 |
115 private: | 115 private: |
116 class SimpleIterator; | 116 class SimpleIterator; |
117 friend class SimpleIterator; | 117 friend class SimpleIterator; |
118 | 118 |
119 typedef base::hash_map<uint64_t, SimpleEntryImpl*> EntryMap; | 119 typedef base::hash_map<uint64_t, SimpleEntryImpl*> EntryMap; |
120 | 120 |
121 typedef base::Callback<void(base::Time mtime, uint64_t max_size, int result)> | 121 typedef base::Callback<void(base::Time mtime, uint64_t max_size, int result)> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // Called when we tried to open an entry from key. When the entry has been | 184 // Called when we tried to open an entry from key. When the entry has been |
185 // opened, a check for key mismatch is performed. | 185 // opened, a check for key mismatch is performed. |
186 void OnEntryOpenedFromKey(const std::string key, | 186 void OnEntryOpenedFromKey(const std::string key, |
187 Entry** entry, | 187 Entry** entry, |
188 const scoped_refptr<SimpleEntryImpl>& simple_entry, | 188 const scoped_refptr<SimpleEntryImpl>& simple_entry, |
189 const CompletionCallback& callback, | 189 const CompletionCallback& callback, |
190 int error_code); | 190 int error_code); |
191 | 191 |
192 // A callback thunk used by DoomEntries to clear the |entries_pending_doom_| | 192 // A callback thunk used by DoomEntries to clear the |entries_pending_doom_| |
193 // after a mass doom. | 193 // after a mass doom. |
194 void DoomEntriesComplete(scoped_ptr<std::vector<uint64_t>> entry_hashes, | 194 void DoomEntriesComplete(std::unique_ptr<std::vector<uint64_t>> entry_hashes, |
195 const CompletionCallback& callback, | 195 const CompletionCallback& callback, |
196 int result); | 196 int result); |
197 | 197 |
198 const base::FilePath path_; | 198 const base::FilePath path_; |
199 const net::CacheType cache_type_; | 199 const net::CacheType cache_type_; |
200 scoped_ptr<SimpleIndex> index_; | 200 std::unique_ptr<SimpleIndex> index_; |
201 const scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; | 201 const scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; |
202 scoped_refptr<base::TaskRunner> worker_pool_; | 202 scoped_refptr<base::TaskRunner> worker_pool_; |
203 | 203 |
204 int orig_max_size_; | 204 int orig_max_size_; |
205 const SimpleEntryImpl::OperationsMode entry_operations_mode_; | 205 const SimpleEntryImpl::OperationsMode entry_operations_mode_; |
206 | 206 |
207 EntryMap active_entries_; | 207 EntryMap active_entries_; |
208 | 208 |
209 // The set of all entries which are currently being doomed. To avoid races, | 209 // 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 | 210 // 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 | 211 // is complete. The base::Closure map target is used to store deferred |
212 // operations to be run at the completion of the Doom. | 212 // operations to be run at the completion of the Doom. |
213 base::hash_map<uint64_t, std::vector<base::Closure>> entries_pending_doom_; | 213 base::hash_map<uint64_t, std::vector<base::Closure>> entries_pending_doom_; |
214 | 214 |
215 net::NetLog* const net_log_; | 215 net::NetLog* const net_log_; |
216 }; | 216 }; |
217 | 217 |
218 } // namespace disk_cache | 218 } // namespace disk_cache |
219 | 219 |
220 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ | 220 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ |
OLD | NEW |