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

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

Issue 478573003: Connect SimpleCache Backend active_entries_ more closely to Entry lifetime. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: one more comment Created 6 years, 4 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
« no previous file with comments | « net/disk_cache/entry_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>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 base::TaskRunner* worker_pool() { return worker_pool_.get(); } 59 base::TaskRunner* worker_pool() { return worker_pool_.get(); }
60 60
61 int Init(const CompletionCallback& completion_callback); 61 int Init(const CompletionCallback& completion_callback);
62 62
63 // Sets the maximum size for the total amount of data stored by this instance. 63 // Sets the maximum size for the total amount of data stored by this instance.
64 bool SetMaxSize(int max_bytes); 64 bool SetMaxSize(int max_bytes);
65 65
66 // Returns the maximum file size permitted in this backend. 66 // Returns the maximum file size permitted in this backend.
67 int GetMaxFileSize() const; 67 int GetMaxFileSize() const;
68 68
69 // Removes |entry| from the |active_entries_| set, forcing future Open/Create
70 // operations to construct a new object.
71 void OnDeactivated(const SimpleEntryImpl* entry);
72
73 // Flush our SequencedWorkerPool. 69 // Flush our SequencedWorkerPool.
74 static void FlushWorkerPoolForTesting(); 70 static void FlushWorkerPoolForTesting();
75 71
76 // The entry for |entry_hash| is being doomed; the backend will not attempt 72 // The entry for |entry_hash| is being doomed; the backend will not attempt
77 // run new operations for this |entry_hash| until the Doom is completed. 73 // run new operations for this |entry_hash| until the Doom is completed.
78 void OnDoomStart(uint64 entry_hash); 74 void OnDoomStart(uint64 entry_hash);
79 75
80 // The entry for |entry_hash| has been successfully doomed, we can now allow 76 // The entry for |entry_hash| has been successfully doomed, we can now allow
81 // operations on this entry, and we can run any operations enqueued while the 77 // operations on this entry, and we can run any operations enqueued while the
82 // doom completed. 78 // doom completed.
(...skipping 19 matching lines...) Expand all
102 virtual int DoomEntriesSince(base::Time initial_time, 98 virtual int DoomEntriesSince(base::Time initial_time,
103 const CompletionCallback& callback) OVERRIDE; 99 const CompletionCallback& callback) OVERRIDE;
104 virtual int OpenNextEntry(void** iter, Entry** next_entry, 100 virtual int OpenNextEntry(void** iter, Entry** next_entry,
105 const CompletionCallback& callback) OVERRIDE; 101 const CompletionCallback& callback) OVERRIDE;
106 virtual void EndEnumeration(void** iter) OVERRIDE; 102 virtual void EndEnumeration(void** iter) OVERRIDE;
107 virtual void GetStats( 103 virtual void GetStats(
108 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE; 104 std::vector<std::pair<std::string, std::string> >* stats) OVERRIDE;
109 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; 105 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE;
110 106
111 private: 107 private:
112 typedef base::hash_map<uint64, base::WeakPtr<SimpleEntryImpl> > EntryMap; 108 typedef base::hash_map<uint64, SimpleEntryImpl*> EntryMap;
113 109
114 typedef base::Callback<void(base::Time mtime, uint64 max_size, int result)> 110 typedef base::Callback<void(base::Time mtime, uint64 max_size, int result)>
115 InitializeIndexCallback; 111 InitializeIndexCallback;
116 112
113 class ActiveEntryProxy;
114 friend class ActiveEntryProxy;
115
117 // Return value of InitCacheStructureOnDisk(). 116 // Return value of InitCacheStructureOnDisk().
118 struct DiskStatResult { 117 struct DiskStatResult {
119 base::Time cache_dir_mtime; 118 base::Time cache_dir_mtime;
120 uint64 max_size; 119 uint64 max_size;
121 bool detected_magic_number_mismatch; 120 bool detected_magic_number_mismatch;
122 int net_error; 121 int net_error;
123 }; 122 };
124 123
125 void InitializeIndex(const CompletionCallback& callback, 124 void InitializeIndex(const CompletionCallback& callback,
126 const DiskStatResult& result); 125 const DiskStatResult& result);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // 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
213 // operations to be run at the completion of the Doom. 212 // operations to be run at the completion of the Doom.
214 base::hash_map<uint64, std::vector<base::Closure> > entries_pending_doom_; 213 base::hash_map<uint64, std::vector<base::Closure> > entries_pending_doom_;
215 214
216 net::NetLog* const net_log_; 215 net::NetLog* const net_log_;
217 }; 216 };
218 217
219 } // namespace disk_cache 218 } // namespace disk_cache
220 219
221 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_ 220 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_BACKEND_IMPL_H_
OLDNEW
« no previous file with comments | « net/disk_cache/entry_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