| 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 <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 Loading... |
| 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; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 const net::CacheType cache_type_; | 202 const net::CacheType cache_type_; |
| 200 scoped_ptr<SimpleIndex> index_; | 203 scoped_ptr<SimpleIndex> index_; |
| 201 const scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; | 204 const scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; |
| 202 scoped_refptr<base::TaskRunner> worker_pool_; | 205 scoped_refptr<base::TaskRunner> worker_pool_; |
| 203 | 206 |
| 204 int orig_max_size_; | 207 int orig_max_size_; |
| 205 const SimpleEntryImpl::OperationsMode entry_operations_mode_; | 208 const SimpleEntryImpl::OperationsMode entry_operations_mode_; |
| 206 | 209 |
| 207 EntryMap active_entries_; | 210 EntryMap active_entries_; |
| 208 | 211 |
| 212 // One entry for every enumeration in progress. |
| 213 ActiveEnumerationMap active_enumerations_; |
| 214 |
| 209 // The set of all entries which are currently being doomed. To avoid races, | 215 // 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 | 216 // 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 | 217 // is complete. The base::Closure map target is used to store deferred |
| 212 // operations to be run at the completion of the Doom. | 218 // operations to be run at the completion of the Doom. |
| 213 base::hash_map<uint64, std::vector<base::Closure> > entries_pending_doom_; | 219 base::hash_map<uint64, std::vector<base::Closure> > entries_pending_doom_; |
| 214 | 220 |
| 215 net::NetLog* const net_log_; | 221 net::NetLog* const net_log_; |
| 216 }; | 222 }; |
| 217 | 223 |
| 218 } // namespace disk_cache | 224 } // namespace disk_cache |
| 219 | 225 |
| 220 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ | 226 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ |
| OLD | NEW |