OLD | NEW |
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/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 18 matching lines...) Expand all Loading... |
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 explicit BackendImpl(const FilePath& path) |
39 : path_(path), block_files_(path.ToWStringHack()), 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 : path_(path), block_files_(path.ToWStringHack()), mask_(mask), max_size_(
0), | 46 : path_(path), block_files_(path), mask_(mask), max_size_(0), |
47 cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(kMask), | 47 cache_type_(net::DISK_CACHE), uma_report_(0), user_flags_(kMask), |
48 init_(false), restarted_(false), unit_test_(false), read_only_(false), | 48 init_(false), restarted_(false), unit_test_(false), read_only_(false), |
49 new_eviction_(false), first_timer_(true), | 49 new_eviction_(false), first_timer_(true), |
50 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {} | 50 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {} |
51 ~BackendImpl(); | 51 ~BackendImpl(); |
52 | 52 |
53 // Returns a new backend with the desired flags. See the declaration of | 53 // Returns a new backend with the desired flags. See the declaration of |
54 // CreateCacheBackend(). | 54 // CreateCacheBackend(). |
55 static Backend* CreateBackend(const std::wstring& full_path, bool force, | 55 static Backend* CreateBackend(const std::wstring& full_path, bool force, |
56 int max_bytes, net::CacheType type, | 56 int max_bytes, net::CacheType type, |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 292 |
293 DISALLOW_EVIL_CONSTRUCTORS(BackendImpl); | 293 DISALLOW_EVIL_CONSTRUCTORS(BackendImpl); |
294 }; | 294 }; |
295 | 295 |
296 // Returns the prefered max cache size given the available disk space. | 296 // Returns the prefered max cache size given the available disk space. |
297 int PreferedCacheSize(int64 available); | 297 int PreferedCacheSize(int64 available); |
298 | 298 |
299 } // namespace disk_cache | 299 } // namespace disk_cache |
300 | 300 |
301 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ | 301 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ |
OLD | NEW |