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

Side by Side Diff: net/disk_cache/backend_impl.h

Issue 8956014: base::Bind: Cleanup almost-unused OldCompletionCallbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win fix. Created 9 years 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 | « chrome/browser/browsing_data_remover.cc ('k') | net/disk_cache/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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // See net/disk_cache/disk_cache.h for the public interface of the cache. 5 // See net/disk_cache/disk_cache.h for the public interface of the cache.
6 6
7 #ifndef NET_DISK_CACHE_BACKEND_IMPL_H_ 7 #ifndef NET_DISK_CACHE_BACKEND_IMPL_H_
8 #define NET_DISK_CACHE_BACKEND_IMPL_H_ 8 #define NET_DISK_CACHE_BACKEND_IMPL_H_
9 #pragma once 9 #pragma once
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 net::NetLog* net_log, Backend** backend, 58 net::NetLog* net_log, Backend** backend,
59 OldCompletionCallback* callback); 59 OldCompletionCallback* callback);
60 60
61 // Performs general initialization for this current instance of the cache. 61 // Performs general initialization for this current instance of the cache.
62 int Init(OldCompletionCallback* callback); 62 int Init(OldCompletionCallback* callback);
63 63
64 // Performs the actual initialization and final cleanup on destruction. 64 // Performs the actual initialization and final cleanup on destruction.
65 int SyncInit(); 65 int SyncInit();
66 void CleanupCache(); 66 void CleanupCache();
67 67
68 // Same bahavior as OpenNextEntry but walks the list from back to front. 68 // Same behavior as OpenNextEntry but walks the list from back to front.
69 int OpenPrevEntry(void** iter, Entry** prev_entry, 69 int OpenPrevEntry(void** iter, Entry** prev_entry,
70 OldCompletionCallback* callback); 70 OldCompletionCallback* callback);
71 71
72 // Synchronous implementation of the asynchronous interface. 72 // Synchronous implementation of the asynchronous interface.
73 int SyncOpenEntry(const std::string& key, Entry** entry); 73 int SyncOpenEntry(const std::string& key, Entry** entry);
74 int SyncCreateEntry(const std::string& key, Entry** entry); 74 int SyncCreateEntry(const std::string& key, Entry** entry);
75 int SyncDoomEntry(const std::string& key); 75 int SyncDoomEntry(const std::string& key);
76 int SyncDoomAllEntries(); 76 int SyncDoomAllEntries();
77 int SyncDoomEntriesBetween(const base::Time initial_time, 77 int SyncDoomEntriesBetween(const base::Time initial_time,
78 const base::Time end_time); 78 const base::Time end_time);
(...skipping 29 matching lines...) Expand all
108 bool CreateExternalFile(Addr* address); 108 bool CreateExternalFile(Addr* address);
109 109
110 // Creates a new storage block of size block_count. 110 // Creates a new storage block of size block_count.
111 bool CreateBlock(FileType block_type, int block_count, 111 bool CreateBlock(FileType block_type, int block_count,
112 Addr* block_address); 112 Addr* block_address);
113 113
114 // Deletes a given storage block. deep set to true can be used to zero-fill 114 // Deletes a given storage block. deep set to true can be used to zero-fill
115 // the related storage in addition of releasing the related block. 115 // the related storage in addition of releasing the related block.
116 void DeleteBlock(Addr block_address, bool deep); 116 void DeleteBlock(Addr block_address, bool deep);
117 117
118 // Retrieves a pointer to the lru-related data. 118 // Retrieves a pointer to the LRU-related data.
119 LruData* GetLruData(); 119 LruData* GetLruData();
120 120
121 // Updates the ranking information for an entry. 121 // Updates the ranking information for an entry.
122 void UpdateRank(EntryImpl* entry, bool modified); 122 void UpdateRank(EntryImpl* entry, bool modified);
123 123
124 // A node was recovered from a crash, it may not be on the index, so this 124 // A node was recovered from a crash, it may not be on the index, so this
125 // method checks it and takes the appropriate action. 125 // method checks it and takes the appropriate action.
126 void RecoveredEntry(CacheRankingsBlock* rankings); 126 void RecoveredEntry(CacheRankingsBlock* rankings);
127 127
128 // Permanently deletes an entry, but still keeps track of it. 128 // Permanently deletes an entry, but still keeps track of it.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 204
205 // Reports a critical error (and disables the cache). 205 // Reports a critical error (and disables the cache).
206 void CriticalError(int error); 206 void CriticalError(int error);
207 207
208 // Reports an uncommon, recoverable error. 208 // Reports an uncommon, recoverable error.
209 void ReportError(int error); 209 void ReportError(int error);
210 210
211 // Called when an interesting event should be logged (counted). 211 // Called when an interesting event should be logged (counted).
212 void OnEvent(Stats::Counters an_event); 212 void OnEvent(Stats::Counters an_event);
213 213
214 // Keeps track of paylod access (doesn't include metadata). 214 // Keeps track of payload access (doesn't include metadata).
215 void OnRead(int bytes); 215 void OnRead(int bytes);
216 void OnWrite(int bytes); 216 void OnWrite(int bytes);
217 217
218 // Timer callback to calculate usage statistics. 218 // Timer callback to calculate usage statistics.
219 void OnStatsTimer(); 219 void OnStatsTimer();
220 220
221 // Handles the pending asynchronous IO count. 221 // Handles the pending asynchronous IO count.
222 void IncrementIoCount(); 222 void IncrementIoCount();
223 void DecrementIoCount(); 223 void DecrementIoCount();
224 224
(...skipping 20 matching lines...) Expand all
245 int RunTaskForTest(Task* task, OldCompletionCallback* callback); 245 int RunTaskForTest(Task* task, OldCompletionCallback* callback);
246 246
247 // Trims an entry (all if |empty| is true) from the list of deleted 247 // Trims an entry (all if |empty| is true) from the list of deleted
248 // entries. This method should be called directly on the cache thread. 248 // entries. This method should be called directly on the cache thread.
249 void TrimForTest(bool empty); 249 void TrimForTest(bool empty);
250 250
251 // Trims an entry (all if |empty| is true) from the list of deleted 251 // Trims an entry (all if |empty| is true) from the list of deleted
252 // entries. This method should be called directly on the cache thread. 252 // entries. This method should be called directly on the cache thread.
253 void TrimDeletedListForTest(bool empty); 253 void TrimDeletedListForTest(bool empty);
254 254
255 // Peforms a simple self-check, and returns the number of dirty items 255 // Performs a simple self-check, and returns the number of dirty items
256 // or an error code (negative value). 256 // or an error code (negative value).
257 int SelfCheck(); 257 int SelfCheck();
258 258
259 // Backend interface. 259 // Backend implementation.
260 virtual int32 GetEntryCount() const OVERRIDE; 260 virtual int32 GetEntryCount() const OVERRIDE;
261 virtual int OpenEntry(const std::string& key, Entry** entry, 261 virtual int OpenEntry(const std::string& key, Entry** entry,
262 OldCompletionCallback* callback) OVERRIDE; 262 OldCompletionCallback* callback) OVERRIDE;
263 virtual int CreateEntry(const std::string& key, Entry** entry, 263 virtual int CreateEntry(const std::string& key, Entry** entry,
264 OldCompletionCallback* callback) OVERRIDE; 264 OldCompletionCallback* callback) OVERRIDE;
265 virtual int DoomEntry(const std::string& key, 265 virtual int DoomEntry(const std::string& key,
266 OldCompletionCallback* callback) OVERRIDE; 266 OldCompletionCallback* callback) OVERRIDE;
267 virtual int DoomAllEntries(OldCompletionCallback* callback) OVERRIDE;
268 virtual int DoomAllEntries(const net::CompletionCallback& callback) OVERRIDE; 267 virtual int DoomAllEntries(const net::CompletionCallback& callback) OVERRIDE;
269 virtual int DoomEntriesBetween(const base::Time initial_time,
270 const base::Time end_time,
271 OldCompletionCallback* callback) OVERRIDE;
272 virtual int DoomEntriesBetween( 268 virtual int DoomEntriesBetween(
273 const base::Time initial_time, 269 const base::Time initial_time,
274 const base::Time end_time, 270 const base::Time end_time,
275 const net::CompletionCallback& callback) OVERRIDE; 271 const net::CompletionCallback& callback) OVERRIDE;
276 virtual int DoomEntriesSince(const base::Time initial_time, 272 virtual int DoomEntriesSince(const base::Time initial_time,
277 OldCompletionCallback* callback) OVERRIDE; 273 OldCompletionCallback* callback) OVERRIDE;
278 virtual int OpenNextEntry(void** iter, Entry** next_entry, 274 virtual int OpenNextEntry(void** iter, Entry** next_entry,
279 OldCompletionCallback* callback) OVERRIDE;
280 virtual int OpenNextEntry(void** iter, Entry** next_entry,
281 const net::CompletionCallback& callback) OVERRIDE; 275 const net::CompletionCallback& callback) OVERRIDE;
282 virtual void EndEnumeration(void** iter) OVERRIDE; 276 virtual void EndEnumeration(void** iter) OVERRIDE;
283 virtual void GetStats(StatsItems* stats) OVERRIDE; 277 virtual void GetStats(StatsItems* stats) OVERRIDE;
284 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; 278 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE;
285 279
286 private: 280 private:
287 typedef base::hash_map<CacheAddr, EntryImpl*> EntriesMap; 281 typedef base::hash_map<CacheAddr, EntryImpl*> EntriesMap;
288 282
289 // Creates a new backing file for the cache index. 283 // Creates a new backing file for the cache index.
290 bool CreateBackingStore(disk_cache::File* file); 284 bool CreateBackingStore(disk_cache::File* file);
(...skipping 14 matching lines...) Expand all
305 // of a given entry, |entry_addr| should be grabbed from that entry, so that 299 // of a given entry, |entry_addr| should be grabbed from that entry, so that
306 // if it doesn't match the entry on the index, we know that it was replaced 300 // if it doesn't match the entry on the index, we know that it was replaced
307 // with a new entry; in this case |*match_error| will be set to true and the 301 // with a new entry; in this case |*match_error| will be set to true and the
308 // return value will be NULL. 302 // return value will be NULL.
309 EntryImpl* MatchEntry(const std::string& key, uint32 hash, bool find_parent, 303 EntryImpl* MatchEntry(const std::string& key, uint32 hash, bool find_parent,
310 Addr entry_addr, bool* match_error); 304 Addr entry_addr, bool* match_error);
311 305
312 // Opens the next or previous entry on a cache iteration. 306 // Opens the next or previous entry on a cache iteration.
313 EntryImpl* OpenFollowingEntry(bool forward, void** iter); 307 EntryImpl* OpenFollowingEntry(bool forward, void** iter);
314 308
315 // Opens the next or previous entry on a single list. If successfull, 309 // Opens the next or previous entry on a single list. If successful,
316 // |from_entry| will be updated to point to the new entry, otherwise it will 310 // |from_entry| will be updated to point to the new entry, otherwise it will
317 // be set to NULL; in other words, it is used as an explicit iterator. 311 // be set to NULL; in other words, it is used as an explicit iterator.
318 bool OpenFollowingEntryFromList(bool forward, Rankings::List list, 312 bool OpenFollowingEntryFromList(bool forward, Rankings::List list,
319 CacheRankingsBlock** from_entry, 313 CacheRankingsBlock** from_entry,
320 EntryImpl** next_entry); 314 EntryImpl** next_entry);
321 315
322 // Returns the entry that is pointed by |next|, from the given |list|. 316 // Returns the entry that is pointed by |next|, from the given |list|.
323 EntryImpl* GetEnumeratedEntry(CacheRankingsBlock* next, Rankings::List list); 317 EntryImpl* GetEnumeratedEntry(CacheRankingsBlock* next, Rankings::List list);
324 318
325 // Re-opens an entry that was previously deleted. 319 // Re-opens an entry that was previously deleted.
(...skipping 16 matching lines...) Expand all
342 336
343 // Send UMA stats. 337 // Send UMA stats.
344 void ReportStats(); 338 void ReportStats();
345 339
346 // Upgrades the index file to version 2.1. 340 // Upgrades the index file to version 2.1.
347 void UpgradeTo2_1(); 341 void UpgradeTo2_1();
348 342
349 // Performs basic checks on the index file. Returns false on failure. 343 // Performs basic checks on the index file. Returns false on failure.
350 bool CheckIndex(); 344 bool CheckIndex();
351 345
352 // Part of the selt test. Returns the number or dirty entries, or an error. 346 // Part of the self test. Returns the number or dirty entries, or an error.
353 int CheckAllEntries(); 347 int CheckAllEntries();
354 348
355 // Part of the self test. Returns false if the entry is corrupt. 349 // Part of the self test. Returns false if the entry is corrupt.
356 bool CheckEntry(EntryImpl* cache_entry); 350 bool CheckEntry(EntryImpl* cache_entry);
357 351
358 // Returns the maximum total memory for the memory buffers. 352 // Returns the maximum total memory for the memory buffers.
359 int MaxBuffersSize(); 353 int MaxBuffersSize();
360 354
361 InFlightBackendIO background_queue_; // The controller of pending operations. 355 InFlightBackendIO background_queue_; // The controller of pending operations.
362 scoped_refptr<MappedFile> index_; // The main cache index. 356 scoped_refptr<MappedFile> index_; // The main cache index.
363 FilePath path_; // Path to the folder used as backing storage. 357 FilePath path_; // Path to the folder used as backing storage.
364 Index* data_; // Pointer to the index data. 358 Index* data_; // Pointer to the index data.
365 BlockFiles block_files_; // Set of files used to store all data. 359 BlockFiles block_files_; // Set of files used to store all data.
366 Rankings rankings_; // Rankings to be able to trim the cache. 360 Rankings rankings_; // Rankings to be able to trim the cache.
367 uint32 mask_; // Binary mask to map a hash to the hash table. 361 uint32 mask_; // Binary mask to map a hash to the hash table.
368 int32 max_size_; // Maximum data size for this instance. 362 int32 max_size_; // Maximum data size for this instance.
369 Eviction eviction_; // Handler of the eviction algorithm. 363 Eviction eviction_; // Handler of the eviction algorithm.
370 EntriesMap open_entries_; // Map of open entries. 364 EntriesMap open_entries_; // Map of open entries.
371 int num_refs_; // Number of referenced cache entries. 365 int num_refs_; // Number of referenced cache entries.
372 int max_refs_; // Max number of referenced cache entries. 366 int max_refs_; // Max number of referenced cache entries.
373 int num_pending_io_; // Number of pending IO operations. 367 int num_pending_io_; // Number of pending IO operations.
374 int entry_count_; // Number of entries accessed lately. 368 int entry_count_; // Number of entries accessed lately.
375 int byte_count_; // Number of bytes read/written lately. 369 int byte_count_; // Number of bytes read/written lately.
376 int buffer_bytes_; // Total size of the temporary entries' buffers. 370 int buffer_bytes_; // Total size of the temporary entries' buffers.
377 int up_ticks_; // The number of timer ticks received (OnStatsTimer). 371 int up_ticks_; // The number of timer ticks received (OnStatsTimer).
378 net::CacheType cache_type_; 372 net::CacheType cache_type_;
379 int uma_report_; // Controls transmision of UMA data. 373 int uma_report_; // Controls transmission of UMA data.
380 uint32 user_flags_; // Flags set by the user. 374 uint32 user_flags_; // Flags set by the user.
381 bool init_; // controls the initialization of the system. 375 bool init_; // controls the initialization of the system.
382 bool restarted_; 376 bool restarted_;
383 bool unit_test_; 377 bool unit_test_;
384 bool read_only_; // Prevents updates of the rankings data (used by tools). 378 bool read_only_; // Prevents updates of the rankings data (used by tools).
385 bool disabled_; 379 bool disabled_;
386 bool new_eviction_; // What eviction algorithm should be used. 380 bool new_eviction_; // What eviction algorithm should be used.
387 bool first_timer_; // True if the timer has not been called. 381 bool first_timer_; // True if the timer has not been called.
388 bool user_load_; // True if we see a high load coming from the caller. 382 bool user_load_; // True if we see a high load coming from the caller.
389 383
390 net::NetLog* net_log_; 384 net::NetLog* net_log_;
391 385
392 Stats stats_; // Usage statistcs. 386 Stats stats_; // Usage statistics.
393 base::RepeatingTimer<BackendImpl> timer_; // Usage timer. 387 base::RepeatingTimer<BackendImpl> timer_; // Usage timer.
394 base::WaitableEvent done_; // Signals the end of background work. 388 base::WaitableEvent done_; // Signals the end of background work.
395 scoped_refptr<TraceObject> trace_object_; // Inits internal tracing. 389 scoped_refptr<TraceObject> trace_object_; // Initializes internal tracing.
396 base::WeakPtrFactory<BackendImpl> ptr_factory_; 390 base::WeakPtrFactory<BackendImpl> ptr_factory_;
397 391
398 DISALLOW_COPY_AND_ASSIGN(BackendImpl); 392 DISALLOW_COPY_AND_ASSIGN(BackendImpl);
399 }; 393 };
400 394
401 // Returns the prefered max cache size given the available disk space. 395 // Returns the preferred max cache size given the available disk space.
402 NET_EXPORT_PRIVATE int PreferedCacheSize(int64 available); 396 NET_EXPORT_PRIVATE int PreferedCacheSize(int64 available);
403 397
404 } // namespace disk_cache 398 } // namespace disk_cache
405 399
406 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ 400 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_remover.cc ('k') | net/disk_cache/backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698