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

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

Issue 6292011: Disk cache: Prevent obscure file corruption and deal... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 | « no previous file | net/disk_cache/backend_impl.cc » ('j') | net/disk_cache/backend_impl.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2010 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // Sends a dummy operation through the operation queue, for unit tests. 233 // Sends a dummy operation through the operation queue, for unit tests.
234 int FlushQueueForTest(CompletionCallback* callback); 234 int FlushQueueForTest(CompletionCallback* callback);
235 235
236 // Runs the provided task on the cache thread. The task will be automatically 236 // Runs the provided task on the cache thread. The task will be automatically
237 // deleted after it runs. 237 // deleted after it runs.
238 int RunTaskForTest(Task* task, CompletionCallback* callback); 238 int RunTaskForTest(Task* task, CompletionCallback* callback);
239 239
240 // Starts or stops throttling requests. 240 // Starts or stops throttling requests.
241 void ThrottleRequestsForTest(bool throttle); 241 void ThrottleRequestsForTest(bool throttle);
242 242
243 // Trims an entry (all if |empty| is true) from the list of deleted
244 // entries. This method should be called directly on the cache thread.
245 void TrimForTest(bool empty);
246
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.
249 void TrimDeletedListForTest(bool empty);
250
243 // Peforms a simple self-check, and returns the number of dirty items 251 // Peforms a simple self-check, and returns the number of dirty items
244 // or an error code (negative value). 252 // or an error code (negative value).
245 int SelfCheck(); 253 int SelfCheck();
246 254
247 // Backend interface. 255 // Backend interface.
248 virtual int32 GetEntryCount() const; 256 virtual int32 GetEntryCount() const;
249 virtual int OpenEntry(const std::string& key, Entry** entry, 257 virtual int OpenEntry(const std::string& key, Entry** entry,
250 CompletionCallback* callback); 258 CompletionCallback* callback);
251 virtual int CreateEntry(const std::string& key, Entry** entry, 259 virtual int CreateEntry(const std::string& key, Entry** entry,
252 CompletionCallback* callback); 260 CompletionCallback* callback);
(...skipping 20 matching lines...) Expand all
273 // Deletes the cache and starts again. 281 // Deletes the cache and starts again.
274 void RestartCache(bool failure); 282 void RestartCache(bool failure);
275 void PrepareForRestart(); 283 void PrepareForRestart();
276 284
277 // Creates a new entry object and checks to see if it is dirty. Returns zero 285 // Creates a new entry object and checks to see if it is dirty. Returns zero
278 // on success, or a disk_cache error on failure. 286 // on success, or a disk_cache error on failure.
279 int NewEntry(Addr address, EntryImpl** entry, bool* dirty); 287 int NewEntry(Addr address, EntryImpl** entry, bool* dirty);
280 288
281 // Returns a given entry from the cache. The entry to match is determined by 289 // Returns a given entry from the cache. The entry to match is determined by
282 // key and hash, and the returned entry may be the matched one or it's parent 290 // key and hash, and the returned entry may be the matched one or it's parent
283 // on the list of entries with the same hash (or bucket). 291 // on the list of entries with the same hash (or bucket). To look for a parent
284 EntryImpl* MatchEntry(const std::string& key, uint32 hash, bool find_parent); 292 // of a given entry, |entry_addr| should be grabbed from that entry, so that
293 // if it doesn't match the entry on the index, we know that it was replaced
294 // with a new entry; in this case |*match_error| will be set to true and the
295 // return value will be NULL.
296 EntryImpl* MatchEntry(const std::string& key, uint32 hash, bool find_parent,
297 Addr entry_addr, bool* match_error);
285 298
286 // Opens the next or previous entry on a cache iteration. 299 // Opens the next or previous entry on a cache iteration.
287 EntryImpl* OpenFollowingEntry(bool forward, void** iter); 300 EntryImpl* OpenFollowingEntry(bool forward, void** iter);
288 301
289 // Opens the next or previous entry on a single list. If successfull, 302 // Opens the next or previous entry on a single list. If successfull,
290 // |from_entry| will be updated to point to the new entry, otherwise it will 303 // |from_entry| will be updated to point to the new entry, otherwise it will
291 // be set to NULL; in other words, it is used as an explicit iterator. 304 // be set to NULL; in other words, it is used as an explicit iterator.
292 bool OpenFollowingEntryFromList(bool forward, Rankings::List list, 305 bool OpenFollowingEntryFromList(bool forward, Rankings::List list,
293 CacheRankingsBlock** from_entry, 306 CacheRankingsBlock** from_entry,
294 EntryImpl** next_entry); 307 EntryImpl** next_entry);
295 308
296 // Returns the entry that is pointed by |next|. If we are trimming the cache, 309 // Returns the entry that is pointed by |next|.
297 // |to_evict| should be true so that we don't perform extra disk writes. 310 EntryImpl* GetEnumeratedEntry(CacheRankingsBlock* next);
298 EntryImpl* GetEnumeratedEntry(CacheRankingsBlock* next, bool to_evict);
299 311
300 // Re-opens an entry that was previously deleted. 312 // Re-opens an entry that was previously deleted.
301 EntryImpl* ResurrectEntry(EntryImpl* deleted_entry); 313 EntryImpl* ResurrectEntry(EntryImpl* deleted_entry);
302 314
303 void DestroyInvalidEntry(EntryImpl* entry); 315 void DestroyInvalidEntry(EntryImpl* entry);
304 void DestroyInvalidEntryFromEnumeration(EntryImpl* entry); 316 void DestroyInvalidEntryFromEnumeration(EntryImpl* entry);
305 317
306 // Handles the used storage count. 318 // Handles the used storage count.
307 void AddStorageSize(int32 bytes); 319 void AddStorageSize(int32 bytes);
308 void SubstractStorageSize(int32 bytes); 320 void SubstractStorageSize(int32 bytes);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 386
375 DISALLOW_COPY_AND_ASSIGN(BackendImpl); 387 DISALLOW_COPY_AND_ASSIGN(BackendImpl);
376 }; 388 };
377 389
378 // Returns the prefered max cache size given the available disk space. 390 // Returns the prefered max cache size given the available disk space.
379 int PreferedCacheSize(int64 available); 391 int PreferedCacheSize(int64 available);
380 392
381 } // namespace disk_cache 393 } // namespace disk_cache
382 394
383 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ 395 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/backend_impl.cc » ('j') | net/disk_cache/backend_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698