OLD | NEW |
---|---|
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/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/message_loop_proxy.h" | |
12 #include "base/timer.h" | 14 #include "base/timer.h" |
15 #include "net/disk_cache/bitmap.h" | |
13 #include "net/disk_cache/block_files.h" | 16 #include "net/disk_cache/block_files.h" |
14 #include "net/disk_cache/disk_cache.h" | 17 #include "net/disk_cache/disk_cache.h" |
15 #include "net/disk_cache/eviction.h" | 18 #include "net/disk_cache/eviction.h" |
16 #include "net/disk_cache/in_flight_backend_io.h" | 19 #include "net/disk_cache/in_flight_backend_io.h" |
17 #include "net/disk_cache/rankings.h" | 20 #include "net/disk_cache/rankings.h" |
18 #include "net/disk_cache/stats.h" | 21 #include "net/disk_cache/stats.h" |
19 #include "net/disk_cache/stress_support.h" | 22 #include "net/disk_cache/stress_support.h" |
20 #include "net/disk_cache/trace.h" | 23 #include "net/disk_cache/trace.h" |
21 | 24 |
22 namespace net { | 25 namespace net { |
(...skipping 30 matching lines...) Expand all Loading... | |
53 // CreateCacheBackend(). | 56 // CreateCacheBackend(). |
54 static int CreateBackend(const base::FilePath& full_path, bool force, | 57 static int CreateBackend(const base::FilePath& full_path, bool force, |
55 int max_bytes, net::CacheType type, | 58 int max_bytes, net::CacheType type, |
56 uint32 flags, base::MessageLoopProxy* thread, | 59 uint32 flags, base::MessageLoopProxy* thread, |
57 net::NetLog* net_log, Backend** backend, | 60 net::NetLog* net_log, Backend** backend, |
58 const CompletionCallback& callback); | 61 const CompletionCallback& callback); |
59 | 62 |
60 // Performs general initialization for this current instance of the cache. | 63 // Performs general initialization for this current instance of the cache. |
61 int Init(const CompletionCallback& callback); | 64 int Init(const CompletionCallback& callback); |
62 | 65 |
63 // Performs the actual initialization and final cleanup on destruction. | 66 // Performs the actual initialization and final cleanup on destruction. If |
67 // |async_thread| is non null, then |bitmap_| may be initialized on that | |
rvargas (doing something else)
2013/02/12 01:58:33
I'm guessing the comment is stale now.
| |
68 // thread, otherwise |bitmap_| is left unchanged. | |
64 int SyncInit(); | 69 int SyncInit(); |
65 void CleanupCache(); | 70 void CleanupCache(); |
66 | 71 |
67 // Same behavior as OpenNextEntry but walks the list from back to front. | 72 // Same behavior as OpenNextEntry but walks the list from back to front. |
68 int OpenPrevEntry(void** iter, Entry** prev_entry, | 73 int OpenPrevEntry(void** iter, Entry** prev_entry, |
69 const CompletionCallback& callback); | 74 const CompletionCallback& callback); |
70 | 75 |
71 // Synchronous implementation of the asynchronous interface. | 76 // Synchronous implementation of the asynchronous interface. |
72 int SyncOpenEntry(const std::string& key, Entry** entry); | 77 int SyncOpenEntry(const std::string& key, Entry** entry); |
73 int SyncCreateEntry(const std::string& key, Entry** entry); | 78 int SyncCreateEntry(const std::string& key, Entry** entry); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 | 231 |
227 // Sets internal parameters to enable upgrade mode (for internal tools). | 232 // Sets internal parameters to enable upgrade mode (for internal tools). |
228 void SetUpgradeMode(); | 233 void SetUpgradeMode(); |
229 | 234 |
230 // Sets the eviction algorithm to version 2. | 235 // Sets the eviction algorithm to version 2. |
231 void SetNewEviction(); | 236 void SetNewEviction(); |
232 | 237 |
233 // Sets an explicit set of BackendFlags. | 238 // Sets an explicit set of BackendFlags. |
234 void SetFlags(uint32 flags); | 239 void SetFlags(uint32 flags); |
235 | 240 |
241 // Clears the index bitmap for tests. | |
242 void ClearIndexBitmapForTest(); | |
243 | |
236 // Clears the counter of references to test handling of corruptions. | 244 // Clears the counter of references to test handling of corruptions. |
237 void ClearRefCountForTest(); | 245 void ClearRefCountForTest(); |
238 | 246 |
239 // Sends a dummy operation through the operation queue, for unit tests. | 247 // Sends a dummy operation through the operation queue, for unit tests. |
240 int FlushQueueForTest(const CompletionCallback& callback); | 248 int FlushQueueForTest(const CompletionCallback& callback); |
241 | 249 |
242 // Runs the provided task on the cache thread. The task will be automatically | 250 // Runs the provided task on the cache thread. The task will be automatically |
243 // deleted after it runs. | 251 // deleted after it runs. |
244 int RunTaskForTest(const base::Closure& task, | 252 int RunTaskForTest(const base::Closure& task, |
245 const CompletionCallback& callback); | 253 const CompletionCallback& callback); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 uint32 user_flags_; // Flags set by the user. | 385 uint32 user_flags_; // Flags set by the user. |
378 bool init_; // controls the initialization of the system. | 386 bool init_; // controls the initialization of the system. |
379 bool restarted_; | 387 bool restarted_; |
380 bool unit_test_; | 388 bool unit_test_; |
381 bool read_only_; // Prevents updates of the rankings data (used by tools). | 389 bool read_only_; // Prevents updates of the rankings data (used by tools). |
382 bool disabled_; | 390 bool disabled_; |
383 bool new_eviction_; // What eviction algorithm should be used. | 391 bool new_eviction_; // What eviction algorithm should be used. |
384 bool first_timer_; // True if the timer has not been called. | 392 bool first_timer_; // True if the timer has not been called. |
385 bool user_load_; // True if we see a high load coming from the caller. | 393 bool user_load_; // True if we see a high load coming from the caller. |
386 | 394 |
395 Bitmap index_bitmap_; | |
396 | |
387 net::NetLog* net_log_; | 397 net::NetLog* net_log_; |
388 | 398 |
389 Stats stats_; // Usage statistics. | 399 Stats stats_; // Usage statistics. |
390 scoped_ptr<base::RepeatingTimer<BackendImpl> > timer_; // Usage timer. | 400 scoped_ptr<base::RepeatingTimer<BackendImpl> > timer_; // Usage timer. |
391 base::WaitableEvent done_; // Signals the end of background work. | 401 base::WaitableEvent done_; // Signals the end of background work. |
392 scoped_refptr<TraceObject> trace_object_; // Initializes internal tracing. | 402 scoped_refptr<TraceObject> trace_object_; // Initializes internal tracing. |
393 base::WeakPtrFactory<BackendImpl> ptr_factory_; | 403 base::WeakPtrFactory<BackendImpl> ptr_factory_; |
394 | 404 |
395 DISALLOW_COPY_AND_ASSIGN(BackendImpl); | 405 DISALLOW_COPY_AND_ASSIGN(BackendImpl); |
396 }; | 406 }; |
397 | 407 |
398 // Returns the preferred max cache size given the available disk space. | 408 // Returns the preferred max cache size given the available disk space. |
399 NET_EXPORT_PRIVATE int PreferedCacheSize(int64 available); | 409 NET_EXPORT_PRIVATE int PreferedCacheSize(int64 available); |
400 | 410 |
401 } // namespace disk_cache | 411 } // namespace disk_cache |
402 | 412 |
403 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ | 413 #endif // NET_DISK_CACHE_BACKEND_IMPL_H_ |
OLD | NEW |