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

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

Issue 12794003: Initialize the simple cache backend at runtime. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: upload from git Created 7 years, 8 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
OLDNEW
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 #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/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 base::ScopedTempDir temp_dir_; 52 base::ScopedTempDir temp_dir_;
53 scoped_ptr<MessageLoop> message_loop_; 53 scoped_ptr<MessageLoop> message_loop_;
54 }; 54 };
55 55
56 // Provides basic support for cache related tests. 56 // Provides basic support for cache related tests.
57 class DiskCacheTestWithCache : public DiskCacheTest { 57 class DiskCacheTestWithCache : public DiskCacheTest {
58 protected: 58 protected:
59 DiskCacheTestWithCache(); 59 DiskCacheTestWithCache();
60 virtual ~DiskCacheTestWithCache(); 60 virtual ~DiskCacheTestWithCache();
61 61
62 disk_cache::Backend* CreateBackendAsModeSuggests(uint32 flags,
63 base::Thread* thread);
64
62 void InitCache(); 65 void InitCache();
66 void InitDefaultCacheViaCreator();
63 void SimulateCrash(); 67 void SimulateCrash();
64 void SetTestMode(); 68 void SetTestMode();
65 69
66 void SetMemoryOnlyMode() { 70 void SetMemoryOnlyMode() {
67 memory_only_ = true; 71 memory_only_ = true;
68 } 72 }
69 73
70 // Use the implementation directly instead of the factory provided object. 74 void SetSimpleCacheMode() {
71 void SetDirectMode() { 75 simple_cache_mode_ = true;
72 implementation_ = true;
73 } 76 }
74 77
75 void SetMask(uint32 mask) { 78 void SetMask(uint32 mask) {
76 mask_ = mask; 79 mask_ = mask;
77 } 80 }
78 81
79 void SetMaxSize(int size); 82 void SetMaxSize(int size);
80 83
81 // Deletes and re-creates the files on initialization errors. 84 // Deletes and re-creates the files on initialization errors.
82 void SetForceCreation() { 85 void SetForceCreation() {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // cache_ will always have a valid object, regardless of how the cache was 144 // cache_ will always have a valid object, regardless of how the cache was
142 // initialized. The implementation pointers can be NULL. 145 // initialized. The implementation pointers can be NULL.
143 disk_cache::Backend* cache_; 146 disk_cache::Backend* cache_;
144 disk_cache::BackendImpl* cache_impl_; 147 disk_cache::BackendImpl* cache_impl_;
145 disk_cache::MemBackendImpl* mem_cache_; 148 disk_cache::MemBackendImpl* mem_cache_;
146 149
147 uint32 mask_; 150 uint32 mask_;
148 int size_; 151 int size_;
149 net::CacheType type_; 152 net::CacheType type_;
150 bool memory_only_; 153 bool memory_only_;
151 bool implementation_; 154 bool simple_cache_mode_;
152 bool force_creation_; 155 bool force_creation_;
153 bool new_eviction_; 156 bool new_eviction_;
154 bool first_cleanup_; 157 bool first_cleanup_;
155 bool integrity_; 158 bool integrity_;
156 bool use_current_thread_; 159 bool use_current_thread_;
157 // This is intentionally left uninitialized, to be used by any test. 160 // This is intentionally left uninitialized, to be used by any test.
158 bool success_; 161 bool success_;
159 162
160 private: 163 private:
161 void InitMemoryCache(); 164 void InitMemoryCache();
162 void InitDiskCache(); 165 void InitDiskCache();
163 void InitDiskCacheImpl();
164 166
165 base::Thread cache_thread_; 167 base::Thread cache_thread_;
166 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache); 168 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache);
167 }; 169 };
168 170
169 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ 171 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698