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

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

Issue 49027: Disk cache: First pass to make it possible to have... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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/base/cache_type.h ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/timer.h" 10 #include "base/timer.h"
11 #include "net/disk_cache/block_files.h" 11 #include "net/disk_cache/block_files.h"
12 #include "net/disk_cache/disk_cache.h" 12 #include "net/disk_cache/disk_cache.h"
13 #include "net/disk_cache/eviction.h" 13 #include "net/disk_cache/eviction.h"
14 #include "net/disk_cache/rankings.h" 14 #include "net/disk_cache/rankings.h"
15 #include "net/disk_cache/stats.h" 15 #include "net/disk_cache/stats.h"
16 #include "net/disk_cache/trace.h" 16 #include "net/disk_cache/trace.h"
17 17
18 namespace disk_cache { 18 namespace disk_cache {
19 19
20 // This class implements the Backend interface. An object of this 20 // This class implements the Backend interface. An object of this
21 // class handles the operations of the cache for a particular profile. 21 // class handles the operations of the cache for a particular profile.
22 class BackendImpl : public Backend { 22 class BackendImpl : public Backend {
23 friend class Eviction; 23 friend class Eviction;
24 public: 24 public:
25 explicit BackendImpl(const std::wstring& path) 25 explicit BackendImpl(const std::wstring& path)
26 : path_(path), block_files_(path), mask_(0), max_size_(0), init_(false), 26 : path_(path), block_files_(path), mask_(0), max_size_(0),
27 cache_type_(net::DISK_CACHE), uma_report_(0), init_(false),
27 restarted_(false), unit_test_(false), read_only_(false), 28 restarted_(false), unit_test_(false), read_only_(false),
28 new_eviction_(false) {} 29 new_eviction_(false), first_timer_(true) {}
29 // mask can be used to limit the usable size of the hash table, for testing. 30 // mask can be used to limit the usable size of the hash table, for testing.
30 BackendImpl(const std::wstring& path, uint32 mask) 31 BackendImpl(const std::wstring& path, uint32 mask)
31 : path_(path), block_files_(path), mask_(mask), max_size_(0), 32 : path_(path), block_files_(path), mask_(mask), max_size_(0),
32 init_(false), restarted_(false), unit_test_(false), read_only_(false), 33 cache_type_(net::DISK_CACHE), uma_report_(0), init_(false),
33 new_eviction_(false) {} 34 restarted_(false), unit_test_(false), read_only_(false),
35 new_eviction_(false), first_timer_(true) {}
34 ~BackendImpl(); 36 ~BackendImpl();
35 37
36 // Performs general initialization for this current instance of the cache. 38 // Performs general initialization for this current instance of the cache.
37 bool Init(); 39 bool Init();
38 40
39 // Backend interface. 41 // Backend interface.
40 virtual int32 GetEntryCount() const; 42 virtual int32 GetEntryCount() const;
41 virtual bool OpenEntry(const std::string& key, Entry** entry); 43 virtual bool OpenEntry(const std::string& key, Entry** entry);
42 virtual bool CreateEntry(const std::string& key, Entry** entry); 44 virtual bool CreateEntry(const std::string& key, Entry** entry);
43 virtual bool DoomEntry(const std::string& key); 45 virtual bool DoomEntry(const std::string& key);
44 virtual bool DoomAllEntries(); 46 virtual bool DoomAllEntries();
45 virtual bool DoomEntriesBetween(const base::Time initial_time, 47 virtual bool DoomEntriesBetween(const base::Time initial_time,
46 const base::Time end_time); 48 const base::Time end_time);
47 virtual bool DoomEntriesSince(const base::Time initial_time); 49 virtual bool DoomEntriesSince(const base::Time initial_time);
48 virtual bool OpenNextEntry(void** iter, Entry** next_entry); 50 virtual bool OpenNextEntry(void** iter, Entry** next_entry);
49 virtual void EndEnumeration(void** iter); 51 virtual void EndEnumeration(void** iter);
50 virtual void GetStats(StatsItems* stats); 52 virtual void GetStats(StatsItems* stats);
51 53
52 // Sets the maximum size for the total amount of data stored by this instance. 54 // Sets the maximum size for the total amount of data stored by this instance.
53 bool SetMaxSize(int max_bytes); 55 bool SetMaxSize(int max_bytes);
54 56
57 // Sets the cache type for this backend.
58 void SetType(net::CacheType type);
59
55 // Returns the full name for an external storage file. 60 // Returns the full name for an external storage file.
56 std::wstring GetFileName(Addr address) const; 61 std::wstring GetFileName(Addr address) const;
57 62
58 // Returns the actual file used to store a given (non-external) address. 63 // Returns the actual file used to store a given (non-external) address.
59 MappedFile* File(Addr address); 64 MappedFile* File(Addr address);
60 65
61 // Creates an external storage file. 66 // Creates an external storage file.
62 bool CreateExternalFile(Addr* address); 67 bool CreateExternalFile(Addr* address);
63 68
64 // Creates a new storage block of size block_count. 69 // Creates a new storage block of size block_count.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 std::wstring path_; // Path to the folder used as backing storage. 214 std::wstring path_; // Path to the folder used as backing storage.
210 Index* data_; // Pointer to the index data. 215 Index* data_; // Pointer to the index data.
211 BlockFiles block_files_; // Set of files used to store all data. 216 BlockFiles block_files_; // Set of files used to store all data.
212 Rankings rankings_; // Rankings to be able to trim the cache. 217 Rankings rankings_; // Rankings to be able to trim the cache.
213 uint32 mask_; // Binary mask to map a hash to the hash table. 218 uint32 mask_; // Binary mask to map a hash to the hash table.
214 int32 max_size_; // Maximum data size for this instance. 219 int32 max_size_; // Maximum data size for this instance.
215 Eviction eviction_; // Handler of the eviction algorithm. 220 Eviction eviction_; // Handler of the eviction algorithm.
216 int num_refs_; // Number of referenced cache entries. 221 int num_refs_; // Number of referenced cache entries.
217 int max_refs_; // Max number of referenced cache entries. 222 int max_refs_; // Max number of referenced cache entries.
218 int num_pending_io_; // Number of pending IO operations. 223 int num_pending_io_; // Number of pending IO operations.
224 net::CacheType cache_type_;
225 int uma_report_; // Controls transmision of UMA data.
219 bool init_; // controls the initialization of the system. 226 bool init_; // controls the initialization of the system.
220 bool restarted_; 227 bool restarted_;
221 bool unit_test_; 228 bool unit_test_;
222 bool read_only_; // Prevents updates of the rankings data (used by tools). 229 bool read_only_; // Prevents updates of the rankings data (used by tools).
223 bool disabled_; 230 bool disabled_;
224 bool new_eviction_; // What eviction algorithm should be used. 231 bool new_eviction_; // What eviction algorithm should be used.
232 bool first_timer_; // True if the timer has not been called.
225 233
226 Stats stats_; // Usage statistcs. 234 Stats stats_; // Usage statistcs.
227 base::RepeatingTimer<BackendImpl> timer_; // Usage timer. 235 base::RepeatingTimer<BackendImpl> timer_; // Usage timer.
228 TraceObject trace_object_; // Inits and destroys internal tracing. 236 scoped_refptr<TraceObject> trace_object_; // Inits internal tracing.
229 237
230 DISALLOW_EVIL_CONSTRUCTORS(BackendImpl); 238 DISALLOW_EVIL_CONSTRUCTORS(BackendImpl);
231 }; 239 };
232 240
233 } // namespace disk_cache 241 } // namespace disk_cache
234 242
235 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ 243 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_
OLDNEW
« no previous file with comments | « net/base/cache_type.h ('k') | net/disk_cache/backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698