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

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

Issue 159327: Disk cache: Avoid restarting the cache while it may be in use.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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) 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/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 17 matching lines...) Expand all
28 28
29 // This class implements the Backend interface. An object of this 29 // This class implements the Backend interface. An object of this
30 // class handles the operations of the cache for a particular profile. 30 // class handles the operations of the cache for a particular profile.
31 class BackendImpl : public Backend { 31 class BackendImpl : public Backend {
32 friend class Eviction; 32 friend class Eviction;
33 public: 33 public:
34 explicit BackendImpl(const std::wstring& path) 34 explicit BackendImpl(const std::wstring& path)
35 : path_(path), block_files_(path), mask_(0), max_size_(0), 35 : path_(path), block_files_(path), mask_(0), max_size_(0),
36 cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(0), 36 cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(0),
37 init_(false), restarted_(false), unit_test_(false), read_only_(false), 37 init_(false), restarted_(false), unit_test_(false), read_only_(false),
38 new_eviction_(false), first_timer_(true) {} 38 new_eviction_(false), first_timer_(true),
39 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {}
39 // mask can be used to limit the usable size of the hash table, for testing. 40 // mask can be used to limit the usable size of the hash table, for testing.
40 BackendImpl(const std::wstring& path, uint32 mask) 41 BackendImpl(const std::wstring& path, uint32 mask)
41 : path_(path), block_files_(path), mask_(mask), max_size_(0), 42 : path_(path), block_files_(path), mask_(mask), max_size_(0),
42 cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(kMask), 43 cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(kMask),
43 init_(false), restarted_(false), unit_test_(false), read_only_(false), 44 init_(false), restarted_(false), unit_test_(false), read_only_(false),
44 new_eviction_(false), first_timer_(true) {} 45 new_eviction_(false), first_timer_(true),
46 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {}
45 ~BackendImpl(); 47 ~BackendImpl();
46 48
47 // Performs general initialization for this current instance of the cache. 49 // Performs general initialization for this current instance of the cache.
48 bool Init(); 50 bool Init();
49 51
50 // Backend interface. 52 // Backend interface.
51 virtual int32 GetEntryCount() const; 53 virtual int32 GetEntryCount() const;
52 virtual bool OpenEntry(const std::string& key, Entry** entry); 54 virtual bool OpenEntry(const std::string& key, Entry** entry);
53 virtual bool CreateEntry(const std::string& key, Entry** entry); 55 virtual bool CreateEntry(const std::string& key, Entry** entry);
54 virtual bool DoomEntry(const std::string& key); 56 virtual bool DoomEntry(const std::string& key);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 bool restarted_; 267 bool restarted_;
266 bool unit_test_; 268 bool unit_test_;
267 bool read_only_; // Prevents updates of the rankings data (used by tools). 269 bool read_only_; // Prevents updates of the rankings data (used by tools).
268 bool disabled_; 270 bool disabled_;
269 bool new_eviction_; // What eviction algorithm should be used. 271 bool new_eviction_; // What eviction algorithm should be used.
270 bool first_timer_; // True if the timer has not been called. 272 bool first_timer_; // True if the timer has not been called.
271 273
272 Stats stats_; // Usage statistcs. 274 Stats stats_; // Usage statistcs.
273 base::RepeatingTimer<BackendImpl> timer_; // Usage timer. 275 base::RepeatingTimer<BackendImpl> timer_; // Usage timer.
274 scoped_refptr<TraceObject> trace_object_; // Inits internal tracing. 276 scoped_refptr<TraceObject> trace_object_; // Inits internal tracing.
277 ScopedRunnableMethodFactory<BackendImpl> factory_;
275 278
276 DISALLOW_EVIL_CONSTRUCTORS(BackendImpl); 279 DISALLOW_EVIL_CONSTRUCTORS(BackendImpl);
277 }; 280 };
278 281
279 // Returns the prefered max cache size given the available disk space. 282 // Returns the prefered max cache size given the available disk space.
280 int PreferedCacheSize(int64 available); 283 int PreferedCacheSize(int64 available);
281 284
282 } // namespace disk_cache 285 } // namespace disk_cache
283 286
284 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ 287 #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