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

Unified Diff: net/disk_cache/disk_cache_test_base.h

Issue 15203004: Disk cache: Reference CL for the implementation of file format version 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: IndexTable review Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/disk_cache_perftest.cc ('k') | net/disk_cache/disk_cache_test_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/disk_cache_test_base.h
===================================================================
--- net/disk_cache/disk_cache_test_base.h (revision 199883)
+++ net/disk_cache/disk_cache_test_base.h (working copy)
@@ -10,6 +10,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread.h"
+#include "base/time.h"
#include "net/base/cache_type.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -24,6 +25,7 @@
class Backend;
class BackendImpl;
+class BackendImplV3;
class Entry;
class MemBackendImpl;
class SimpleBackendImpl;
@@ -45,6 +47,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 +65,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,14 +96,22 @@
// 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 DisableFirstCleanup() {
+ EXPECT_FALSE(cache_);
first_cleanup_ = false;
}
@@ -98,10 +120,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;
}
@@ -115,7 +145,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,
@@ -124,7 +156,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);
@@ -133,6 +173,12 @@
// true, the whole list is deleted.
void TrimDeletedListForTest(bool empty);
+ // Returns the current time as seen by the backend.
+ base::Time GetTime();
+
+ // 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();
@@ -146,6 +192,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_;
@@ -154,9 +201,12 @@
bool simple_cache_mode_;
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_;
« no previous file with comments | « net/disk_cache/disk_cache_perftest.cc ('k') | net/disk_cache/disk_cache_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698