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

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

Issue 2739007: Disk cache: Update the disk cache tools and tests to use... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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') | 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) 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 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/hash_tables.h" 11 #include "base/hash_tables.h"
(...skipping 16 matching lines...) Expand all
28 kNewEviction = 1 << 4, // Use of new eviction was specified. 28 kNewEviction = 1 << 4, // Use of new eviction was specified.
29 kNoRandom = 1 << 5, // Don't add randomness to the behavior. 29 kNoRandom = 1 << 5, // Don't add randomness to the behavior.
30 kNoLoadProtection = 1 << 6 // Don't act conservatively under load. 30 kNoLoadProtection = 1 << 6 // Don't act conservatively under load.
31 }; 31 };
32 32
33 // This class implements the Backend interface. An object of this 33 // This class implements the Backend interface. An object of this
34 // class handles the operations of the cache for a particular profile. 34 // class handles the operations of the cache for a particular profile.
35 class BackendImpl : public Backend { 35 class BackendImpl : public Backend {
36 friend class Eviction; 36 friend class Eviction;
37 public: 37 public:
38 explicit BackendImpl(const FilePath& path) 38 BackendImpl(const FilePath& path, base::MessageLoopProxy* cache_thread)
39 : path_(path), block_files_(path), mask_(0), max_size_(0), 39 : path_(path), block_files_(path), mask_(0), max_size_(0),
40 cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(0), 40 cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(0),
41 init_(false), restarted_(false), unit_test_(false), read_only_(false), 41 init_(false), restarted_(false), unit_test_(false), read_only_(false),
42 new_eviction_(false), first_timer_(true), 42 new_eviction_(false), first_timer_(true),
43 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {} 43 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {}
44 // mask can be used to limit the usable size of the hash table, for testing. 44 // mask can be used to limit the usable size of the hash table, for testing.
45 BackendImpl(const FilePath& path, uint32 mask) 45 BackendImpl(const FilePath& path, uint32 mask,
46 base::MessageLoopProxy* cache_thread)
46 : path_(path), block_files_(path), mask_(mask), max_size_(0), 47 : path_(path), block_files_(path), mask_(mask), max_size_(0),
47 cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(kMask), 48 cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(kMask),
48 init_(false), restarted_(false), unit_test_(false), read_only_(false), 49 init_(false), restarted_(false), unit_test_(false), read_only_(false),
49 new_eviction_(false), first_timer_(true), 50 new_eviction_(false), first_timer_(true),
50 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {} 51 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {}
51 ~BackendImpl(); 52 ~BackendImpl();
52 53
53 // Returns a new backend with the desired flags. See the declaration of 54 // Returns a new backend with the desired flags. See the declaration of
54 // CreateCacheBackend(). 55 // CreateCacheBackend().
55 static Backend* CreateBackend(const FilePath& full_path, bool force, 56 static int CreateBackend(const FilePath& full_path, bool force,
56 int max_bytes, net::CacheType type, 57 int max_bytes, net::CacheType type,
57 BackendFlags flags); 58 uint32 flags, base::MessageLoopProxy* thread,
59 Backend** backend, CompletionCallback* callback);
58 60
59 // Performs general initialization for this current instance of the cache. 61 // Performs general initialization for this current instance of the cache.
60 bool Init(); 62 bool Init();
61 63
62 // Backend interface. 64 // Backend interface.
63 virtual int32 GetEntryCount() const; 65 virtual int32 GetEntryCount() const;
64 virtual bool OpenEntry(const std::string& key, Entry** entry); 66 virtual bool OpenEntry(const std::string& key, Entry** entry);
65 virtual int OpenEntry(const std::string& key, Entry** entry, 67 virtual int OpenEntry(const std::string& key, Entry** entry,
66 CompletionCallback* callback); 68 CompletionCallback* callback);
67 virtual bool CreateEntry(const std::string& key, Entry** entry); 69 virtual bool CreateEntry(const std::string& key, Entry** entry);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 307
306 DISALLOW_COPY_AND_ASSIGN(BackendImpl); 308 DISALLOW_COPY_AND_ASSIGN(BackendImpl);
307 }; 309 };
308 310
309 // Returns the prefered max cache size given the available disk space. 311 // Returns the prefered max cache size given the available disk space.
310 int PreferedCacheSize(int64 available); 312 int PreferedCacheSize(int64 available);
311 313
312 } // namespace disk_cache 314 } // namespace disk_cache
313 315
314 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ 316 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698