| 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 <memory> |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 const CompletionCallback& callback) override; | 103 const CompletionCallback& callback) override; |
| 104 int DoomEntry(const std::string& key, | 104 int DoomEntry(const std::string& key, |
| 105 const CompletionCallback& callback) override; | 105 const CompletionCallback& callback) override; |
| 106 int DoomAllEntries(const CompletionCallback& callback) override; | 106 int DoomAllEntries(const CompletionCallback& callback) override; |
| 107 int DoomEntriesBetween(base::Time initial_time, | 107 int DoomEntriesBetween(base::Time initial_time, |
| 108 base::Time end_time, | 108 base::Time end_time, |
| 109 const CompletionCallback& callback) override; | 109 const CompletionCallback& callback) override; |
| 110 int DoomEntriesSince(base::Time initial_time, | 110 int DoomEntriesSince(base::Time initial_time, |
| 111 const CompletionCallback& callback) override; | 111 const CompletionCallback& callback) override; |
| 112 int CalculateSizeOfAllEntries(const CompletionCallback& callback) override; | 112 int CalculateSizeOfAllEntries(const CompletionCallback& callback) override; |
| 113 int CalculateSizeOfEntriesBetween( |
| 114 base::Time initial_time, |
| 115 base::Time end_time, |
| 116 const CompletionCallback& callback) override; |
| 113 std::unique_ptr<Iterator> CreateIterator() override; | 117 std::unique_ptr<Iterator> CreateIterator() override; |
| 114 void GetStats(base::StringPairs* stats) override; | 118 void GetStats(base::StringPairs* stats) override; |
| 115 void OnExternalCacheHit(const std::string& key) override; | 119 void OnExternalCacheHit(const std::string& key) override; |
| 116 | 120 |
| 117 private: | 121 private: |
| 118 class SimpleIterator; | 122 class SimpleIterator; |
| 119 friend class SimpleIterator; | 123 friend class SimpleIterator; |
| 120 | 124 |
| 121 using EntryMap = std::unordered_map<uint64_t, SimpleEntryImpl*>; | 125 using EntryMap = std::unordered_map<uint64_t, SimpleEntryImpl*>; |
| 122 | 126 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 141 // |end_time|. Invoked when the index is ready. | 145 // |end_time|. Invoked when the index is ready. |
| 142 void IndexReadyForDoom(base::Time initial_time, | 146 void IndexReadyForDoom(base::Time initial_time, |
| 143 base::Time end_time, | 147 base::Time end_time, |
| 144 const CompletionCallback& callback, | 148 const CompletionCallback& callback, |
| 145 int result); | 149 int result); |
| 146 | 150 |
| 147 // Calculates the size of the entire cache. Invoked when the index is ready. | 151 // Calculates the size of the entire cache. Invoked when the index is ready. |
| 148 void IndexReadyForSizeCalculation(const CompletionCallback& callback, | 152 void IndexReadyForSizeCalculation(const CompletionCallback& callback, |
| 149 int result); | 153 int result); |
| 150 | 154 |
| 155 // Calculates the size all cache entries between |initial_time| and |
| 156 // |end_time|. Invoked when the index is ready. |
| 157 void IndexReadyForSizeBetweenCalculation(base::Time initial_time, |
| 158 base::Time end_time, |
| 159 const CompletionCallback& callback, |
| 160 int result); |
| 161 |
| 151 // Try to create the directory if it doesn't exist. This must run on the IO | 162 // Try to create the directory if it doesn't exist. This must run on the IO |
| 152 // thread. | 163 // thread. |
| 153 static DiskStatResult InitCacheStructureOnDisk( | 164 static DiskStatResult InitCacheStructureOnDisk( |
| 154 const base::FilePath& path, | 165 const base::FilePath& path, |
| 155 uint64_t suggested_max_size, | 166 uint64_t suggested_max_size, |
| 156 const SimpleExperiment& experiment); | 167 const SimpleExperiment& experiment); |
| 157 | 168 |
| 158 // Searches |active_entries_| for the entry corresponding to |key|. If found, | 169 // Searches |active_entries_| for the entry corresponding to |key|. If found, |
| 159 // returns the found entry. Otherwise, creates a new entry and returns that. | 170 // returns the found entry. Otherwise, creates a new entry and returns that. |
| 160 scoped_refptr<SimpleEntryImpl> CreateOrFindActiveEntry( | 171 scoped_refptr<SimpleEntryImpl> CreateOrFindActiveEntry( |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // operations to be run at the completion of the Doom. | 227 // operations to be run at the completion of the Doom. |
| 217 std::unordered_map<uint64_t, std::vector<base::Closure>> | 228 std::unordered_map<uint64_t, std::vector<base::Closure>> |
| 218 entries_pending_doom_; | 229 entries_pending_doom_; |
| 219 | 230 |
| 220 net::NetLog* const net_log_; | 231 net::NetLog* const net_log_; |
| 221 }; | 232 }; |
| 222 | 233 |
| 223 } // namespace disk_cache | 234 } // namespace disk_cache |
| 224 | 235 |
| 225 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ | 236 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ |
| OLD | NEW |