Index: net/disk_cache/disk_cache_test_base.h |
=================================================================== |
--- net/disk_cache/disk_cache_test_base.h (revision 232523) |
+++ net/disk_cache/disk_cache_test_base.h (working copy) |
@@ -24,6 +24,7 @@ |
class Backend; |
class BackendImpl; |
+class BackendImplV3; |
class Entry; |
class MemBackendImpl; |
class SimpleBackendImpl; |
@@ -45,6 +46,9 @@ |
// Deletes the contents of |cache_path_|. |
bool CleanupCacheDir(); |
+ // Forces the use of a random cache directory. |
+ bool ForceRandomCacheDir(); |
+ |
virtual void TearDown() OVERRIDE; |
base::FilePath cache_path_; |
@@ -60,21 +64,30 @@ |
DiskCacheTestWithCache(); |
virtual ~DiskCacheTestWithCache(); |
- void CreateBackend(uint32 flags, base::Thread* thread); |
+ void CreateBackend(base::Thread* thread); |
void InitCache(); |
void SimulateCrash(); |
void SetTestMode(); |
+ // Same as SetTestMode except that sets the flag on construction. |
+ void PresetTestMode() { |
+ EXPECT_FALSE(cache_); |
+ unit_test_mode_ = true; |
+ } |
+ |
void SetMemoryOnlyMode() { |
+ EXPECT_FALSE(cache_); |
memory_only_ = true; |
} |
void SetSimpleCacheMode() { |
+ EXPECT_FALSE(cache_); |
simple_cache_mode_ = true; |
} |
void SetMask(uint32 mask) { |
+ EXPECT_FALSE(cache_); |
mask_ = mask; |
} |
@@ -82,18 +95,26 @@ |
// Deletes and re-creates the files on initialization errors. |
void SetForceCreation() { |
+ EXPECT_FALSE(cache_); |
force_creation_ = true; |
} |
void SetNewEviction() { |
+ EXPECT_FALSE(cache_); |
new_eviction_ = true; |
} |
+ void UseVersion3() { |
+ EXPECT_FALSE(cache_); |
+ v3_ = true; |
+ } |
+ |
void DisableSimpleCacheWaitForIndex() { |
simple_cache_wait_for_index_ = false; |
} |
void DisableFirstCleanup() { |
+ EXPECT_FALSE(cache_); |
first_cleanup_ = false; |
} |
@@ -102,10 +123,18 @@ |
} |
void UseCurrentThread() { |
+ EXPECT_FALSE(cache_); |
use_current_thread_ = true; |
} |
+ void AvoidTestFlag() { |
+ EXPECT_FALSE(cache_); |
+ EXPECT_FALSE(v3_); |
+ avoid_test_flag_ = true; |
+ } |
+ |
void SetCacheType(net::CacheType type) { |
+ EXPECT_FALSE(cache_); |
type_ = type; |
} |
@@ -119,7 +148,9 @@ |
int DoomEntriesSince(const base::Time initial_time); |
int OpenNextEntry(void** iter, disk_cache::Entry** next_entry); |
void FlushQueueForTest(); |
+ void CleanupForTest(); |
void RunTaskForTest(const base::Closure& closure); |
+ |
int ReadData(disk_cache::Entry* entry, int index, int offset, |
net::IOBuffer* buf, int len); |
int WriteData(disk_cache::Entry* entry, int index, int offset, |
@@ -128,7 +159,15 @@ |
int len); |
int WriteSparseData(disk_cache::Entry* entry, int64 offset, |
net::IOBuffer* buf, int len); |
+ int GetAvailableRange(disk_cache::Entry* entry, int64 offset, int len, |
+ int64* start); |
+ bool IsAllocAllowed(int current_size, int new_size); |
+ void BufferDeleted(int size); |
+ int GetTotalBuffersSize(); |
+ void SetNoBuffering(); |
+ void WaitForEntryToClose(const std::string& key); |
+ |
// Asks the cache to trim an entry. If |empty| is true, the whole cache is |
// deleted. |
void TrimForTest(bool empty); |
@@ -137,6 +176,12 @@ |
// true, the whole list is deleted. |
void TrimDeletedListForTest(bool empty); |
+ // Returns the current time as seen by the backend. |
+ base::Time GetCurrentTime(); |
+ |
+ // Simulates that some |seconds| have passed before proceeding with a test. |
+ void AddDelayForTest(int seconds); |
+ |
// Makes sure that some time passes before continuing the test. Time::Now() |
// before and after this method will not be the same. |
void AddDelay(); |
@@ -150,6 +195,7 @@ |
disk_cache::BackendImpl* cache_impl_; |
disk_cache::SimpleBackendImpl* simple_cache_impl_; |
disk_cache::MemBackendImpl* mem_cache_; |
+ disk_cache::BackendImplV3* cache_impl_v3_; |
uint32 mask_; |
int size_; |
@@ -159,9 +205,12 @@ |
bool simple_cache_wait_for_index_; |
bool force_creation_; |
bool new_eviction_; |
+ bool v3_; |
bool first_cleanup_; |
bool integrity_; |
bool use_current_thread_; |
+ bool avoid_test_flag_; |
+ bool unit_test_mode_; |
// This is intentionally left uninitialized, to be used by any test. |
bool success_; |