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

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

Issue 15203004: Disk cache: Reference CL for the implementation of file format version 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: IndexTable review Created 7 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 | « net/disk_cache/addr_unittest.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/hash_tables.h" 11 #include "base/hash_tables.h"
12 #include "base/timer.h" 12 #include "base/timer.h"
13 #include "net/disk_cache/block_files.h" 13 #include "net/disk_cache/block_files.h"
14 #include "net/disk_cache/disk_cache.h" 14 #include "net/disk_cache/disk_cache.h"
15 #include "net/disk_cache/eviction.h" 15 #include "net/disk_cache/eviction.h"
16 #include "net/disk_cache/in_flight_backend_io.h" 16 #include "net/disk_cache/in_flight_backend_io.h"
17 #include "net/disk_cache/rankings.h" 17 #include "net/disk_cache/rankings.h"
18 #include "net/disk_cache/stats.h" 18 #include "net/disk_cache/stats.h"
19 #include "net/disk_cache/stress_support.h" 19 #include "net/disk_cache/stress_support.h"
20 #include "net/disk_cache/trace.h" 20 #include "net/disk_cache/trace.h"
21 21
22 namespace net { 22 namespace net {
23 class NetLog; 23 class NetLog;
24 } // namespace net 24 } // namespace net
25 25
26 namespace disk_cache { 26 namespace disk_cache {
27 27
28 struct Index;
29
28 enum BackendFlags { 30 enum BackendFlags {
29 kNone = 0, 31 kNone = 0,
30 kMask = 1, // A mask (for the index table) was specified. 32 kMask = 1, // A mask (for the index table) was specified.
31 kMaxSize = 1 << 1, // A maximum size was provided. 33 kMaxSize = 1 << 1, // A maximum size was provided.
32 kUnitTestMode = 1 << 2, // We are modifying the behavior for testing. 34 kUnitTestMode = 1 << 2, // We are modifying the behavior for testing.
33 kUpgradeMode = 1 << 3, // This is the upgrade tool (dump). 35 kUpgradeMode = 1 << 3, // This is the upgrade tool (dump).
34 kNewEviction = 1 << 4, // Use of new eviction was specified. 36 kNewEviction = 1 << 4, // Use of new eviction was specified.
35 kNoRandom = 1 << 5, // Don't add randomness to the behavior. 37 kNoRandom = 1 << 5, // Don't add randomness to the behavior.
36 kNoLoadProtection = 1 << 6, // Don't act conservatively under load. 38 kNoLoadProtection = 1 << 6, // Don't act conservatively under load.
37 kNoBuffering = 1 << 7 // Disable extended IO buffering. 39 kNoBuffering = 1 << 7 // Disable extended IO buffering.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE; 275 virtual void OnExternalCacheHit(const std::string& key) OVERRIDE;
274 276
275 private: 277 private:
276 typedef base::hash_map<CacheAddr, EntryImpl*> EntriesMap; 278 typedef base::hash_map<CacheAddr, EntryImpl*> EntriesMap;
277 279
278 // Creates a new backing file for the cache index. 280 // Creates a new backing file for the cache index.
279 bool CreateBackingStore(disk_cache::File* file); 281 bool CreateBackingStore(disk_cache::File* file);
280 bool InitBackingStore(bool* file_created); 282 bool InitBackingStore(bool* file_created);
281 void AdjustMaxCacheSize(int table_len); 283 void AdjustMaxCacheSize(int table_len);
282 284
285 bool InitStats();
286 void StoreStats();
287
283 // Deletes the cache and starts again. 288 // Deletes the cache and starts again.
284 void RestartCache(bool failure); 289 void RestartCache(bool failure);
285 void PrepareForRestart(); 290 void PrepareForRestart();
286 291
287 // Creates a new entry object. Returns zero on success, or a disk_cache error 292 // Creates a new entry object. Returns zero on success, or a disk_cache error
288 // on failure. 293 // on failure.
289 int NewEntry(Addr address, EntryImpl** entry); 294 int NewEntry(Addr address, EntryImpl** entry);
290 295
291 // Returns a given entry from the cache. The entry to match is determined by 296 // Returns a given entry from the cache. The entry to match is determined by
292 // key and hash, and the returned entry may be the matched one or it's parent 297 // key and hash, and the returned entry may be the matched one or it's parent
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 391
387 DISALLOW_COPY_AND_ASSIGN(BackendImpl); 392 DISALLOW_COPY_AND_ASSIGN(BackendImpl);
388 }; 393 };
389 394
390 // Returns the preferred max cache size given the available disk space. 395 // Returns the preferred max cache size given the available disk space.
391 NET_EXPORT_PRIVATE int PreferedCacheSize(int64 available); 396 NET_EXPORT_PRIVATE int PreferedCacheSize(int64 available);
392 397
393 } // namespace disk_cache 398 } // namespace disk_cache
394 399
395 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ 400 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_
OLDNEW
« no previous file with comments | « net/disk_cache/addr_unittest.cc ('k') | net/disk_cache/backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698