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

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

Issue 2829008: Disk cache: Switch the disk cache to use the cache_thread.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Rename some methods Created 10 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 | « net/disk_cache/backend_unittest.cc ('k') | net/disk_cache/disk_cache_test_base.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-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2010 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 #ifndef NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ 5 #ifndef NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_
6 #define NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ 6 #define NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/thread.h" 9 #include "base/thread.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 18 matching lines...) Expand all
29 virtual void TearDown(); 29 virtual void TearDown();
30 }; 30 };
31 31
32 // Provides basic support for cache related tests. 32 // Provides basic support for cache related tests.
33 class DiskCacheTestWithCache : public DiskCacheTest { 33 class DiskCacheTestWithCache : public DiskCacheTest {
34 protected: 34 protected:
35 DiskCacheTestWithCache() 35 DiskCacheTestWithCache()
36 : cache_(NULL), cache_impl_(NULL), mem_cache_(NULL), mask_(0), size_(0), 36 : cache_(NULL), cache_impl_(NULL), mem_cache_(NULL), mask_(0), size_(0),
37 memory_only_(false), implementation_(false), force_creation_(false), 37 memory_only_(false), implementation_(false), force_creation_(false),
38 new_eviction_(false), first_cleanup_(true), integrity_(true), 38 new_eviction_(false), first_cleanup_(true), integrity_(true),
39 cache_thread_("CacheThread") {} 39 use_current_thread_(false), cache_thread_("CacheThread") {}
40 40
41 void InitCache(); 41 void InitCache();
42 virtual void TearDown(); 42 virtual void TearDown();
43 void SimulateCrash(); 43 void SimulateCrash();
44 void SetTestMode(); 44 void SetTestMode();
45 45
46 void SetMemoryOnlyMode() { 46 void SetMemoryOnlyMode() {
47 memory_only_ = true; 47 memory_only_ = true;
48 } 48 }
49 49
(...skipping 18 matching lines...) Expand all
68 } 68 }
69 69
70 void DisableFirstCleanup() { 70 void DisableFirstCleanup() {
71 first_cleanup_ = false; 71 first_cleanup_ = false;
72 } 72 }
73 73
74 void DisableIntegrityCheck() { 74 void DisableIntegrityCheck() {
75 integrity_ = false; 75 integrity_ = false;
76 } 76 }
77 77
78 void UseCurrentThread() {
79 use_current_thread_ = true;
80 }
81
78 // Utility methods to access the cache and wait for each operation to finish. 82 // Utility methods to access the cache and wait for each operation to finish.
79 int OpenEntry(const std::string& key, disk_cache::Entry** entry); 83 int OpenEntry(const std::string& key, disk_cache::Entry** entry);
80 int CreateEntry(const std::string& key, disk_cache::Entry** entry); 84 int CreateEntry(const std::string& key, disk_cache::Entry** entry);
81 int DoomEntry(const std::string& key); 85 int DoomEntry(const std::string& key);
82 int DoomAllEntries(); 86 int DoomAllEntries();
83 int DoomEntriesBetween(const base::Time initial_time, 87 int DoomEntriesBetween(const base::Time initial_time,
84 const base::Time end_time); 88 const base::Time end_time);
85 int DoomEntriesSince(const base::Time initial_time); 89 int DoomEntriesSince(const base::Time initial_time);
86 int OpenNextEntry(void** iter, disk_cache::Entry** next_entry); 90 int OpenNextEntry(void** iter, disk_cache::Entry** next_entry);
91 void FlushQueueForTest();
87 92
88 // cache_ will always have a valid object, regardless of how the cache was 93 // cache_ will always have a valid object, regardless of how the cache was
89 // initialized. The implementation pointers can be NULL. 94 // initialized. The implementation pointers can be NULL.
90 disk_cache::Backend* cache_; 95 disk_cache::Backend* cache_;
91 disk_cache::BackendImpl* cache_impl_; 96 disk_cache::BackendImpl* cache_impl_;
92 disk_cache::MemBackendImpl* mem_cache_; 97 disk_cache::MemBackendImpl* mem_cache_;
93 98
94 uint32 mask_; 99 uint32 mask_;
95 int size_; 100 int size_;
96 bool memory_only_; 101 bool memory_only_;
97 bool implementation_; 102 bool implementation_;
98 bool force_creation_; 103 bool force_creation_;
99 bool new_eviction_; 104 bool new_eviction_;
100 bool first_cleanup_; 105 bool first_cleanup_;
101 bool integrity_; 106 bool integrity_;
107 bool use_current_thread_;
102 // This is intentionally left uninitialized, to be used by any test. 108 // This is intentionally left uninitialized, to be used by any test.
103 bool success_; 109 bool success_;
104 110
105 private: 111 private:
106 void InitMemoryCache(); 112 void InitMemoryCache();
107 void InitDiskCache(); 113 void InitDiskCache();
108 void InitDiskCacheImpl(const FilePath& path); 114 void InitDiskCacheImpl(const FilePath& path);
109 115
110 base::Thread cache_thread_; 116 base::Thread cache_thread_;
111 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache); 117 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache);
112 }; 118 };
113 119
114 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ 120 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_
OLDNEW
« no previous file with comments | « net/disk_cache/backend_unittest.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