OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This command-line program generates the set of files needed for the crash- | 5 // This command-line program generates the set of files needed for the crash- |
6 // cache unit tests (DiskCacheTest,CacheBackend_Recover*). This program only | 6 // cache unit tests (DiskCacheTest,CacheBackend_Recover*). This program only |
7 // works properly on debug mode, because the crash functionality is not compiled | 7 // works properly on debug mode, because the crash functionality is not compiled |
8 // on release builds of the cache. | 8 // on release builds of the cache. |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 file_util::AppendToPath(full_path, folders[action]); | 112 file_util::AppendToPath(full_path, folders[action]); |
113 | 113 |
114 if (file_util::PathExists(*full_path)) | 114 if (file_util::PathExists(*full_path)) |
115 return false; | 115 return false; |
116 | 116 |
117 return file_util::CreateDirectory(*full_path); | 117 return file_util::CreateDirectory(*full_path); |
118 } | 118 } |
119 | 119 |
120 // Generates the files for an empty and one item cache. | 120 // Generates the files for an empty and one item cache. |
121 int SimpleInsert(const std::wstring& path, RankCrashes action) { | 121 int SimpleInsert(const std::wstring& path, RankCrashes action) { |
122 disk_cache::Backend* cache = disk_cache::CreateCacheBackend(path, false, 0); | 122 disk_cache::Backend* cache = disk_cache::CreateCacheBackend(path, false, 0, |
| 123 net::DISK_CACHE); |
123 if (!cache || cache->GetEntryCount()) | 124 if (!cache || cache->GetEntryCount()) |
124 return GENERIC; | 125 return GENERIC; |
125 | 126 |
126 const char* test_name = "some other key"; | 127 const char* test_name = "some other key"; |
127 | 128 |
128 if (action <= disk_cache::INSERT_EMPTY_3) { | 129 if (action <= disk_cache::INSERT_EMPTY_3) { |
129 test_name = kCrashEntryName; | 130 test_name = kCrashEntryName; |
130 g_rankings_crash = action; | 131 g_rankings_crash = action; |
131 } | 132 } |
132 | 133 |
(...skipping 11 matching lines...) Expand all Loading... |
144 return GENERIC; | 145 return GENERIC; |
145 | 146 |
146 return NOT_REACHED; | 147 return NOT_REACHED; |
147 } | 148 } |
148 | 149 |
149 // Generates the files for a one item cache, and removing the head. | 150 // Generates the files for a one item cache, and removing the head. |
150 int SimpleRemove(const std::wstring& path, RankCrashes action) { | 151 int SimpleRemove(const std::wstring& path, RankCrashes action) { |
151 DCHECK(action >= disk_cache::REMOVE_ONE_1); | 152 DCHECK(action >= disk_cache::REMOVE_ONE_1); |
152 DCHECK(action <= disk_cache::REMOVE_TAIL_3); | 153 DCHECK(action <= disk_cache::REMOVE_TAIL_3); |
153 | 154 |
154 disk_cache::Backend* cache = disk_cache::CreateCacheBackend(path, false, 0); | 155 disk_cache::Backend* cache = disk_cache::CreateCacheBackend(path, false, 0, |
| 156 net::DISK_CACHE); |
155 if (!cache || cache->GetEntryCount()) | 157 if (!cache || cache->GetEntryCount()) |
156 return GENERIC; | 158 return GENERIC; |
157 | 159 |
158 disk_cache::Entry* entry; | 160 disk_cache::Entry* entry; |
159 if (!cache->CreateEntry(kCrashEntryName, &entry)) | 161 if (!cache->CreateEntry(kCrashEntryName, &entry)) |
160 return GENERIC; | 162 return GENERIC; |
161 | 163 |
162 entry->Close(); | 164 entry->Close(); |
163 | 165 |
164 if (action >= disk_cache::REMOVE_TAIL_1) { | 166 if (action >= disk_cache::REMOVE_TAIL_1) { |
(...skipping 10 matching lines...) Expand all Loading... |
175 entry->Doom(); | 177 entry->Doom(); |
176 entry->Close(); | 178 entry->Close(); |
177 | 179 |
178 return NOT_REACHED; | 180 return NOT_REACHED; |
179 } | 181 } |
180 | 182 |
181 int HeadRemove(const std::wstring& path, RankCrashes action) { | 183 int HeadRemove(const std::wstring& path, RankCrashes action) { |
182 DCHECK(action >= disk_cache::REMOVE_HEAD_1); | 184 DCHECK(action >= disk_cache::REMOVE_HEAD_1); |
183 DCHECK(action <= disk_cache::REMOVE_HEAD_4); | 185 DCHECK(action <= disk_cache::REMOVE_HEAD_4); |
184 | 186 |
185 disk_cache::Backend* cache = disk_cache::CreateCacheBackend(path, false, 0); | 187 disk_cache::Backend* cache = disk_cache::CreateCacheBackend(path, false, 0, |
| 188 net::DISK_CACHE); |
186 if (!cache || cache->GetEntryCount()) | 189 if (!cache || cache->GetEntryCount()) |
187 return GENERIC; | 190 return GENERIC; |
188 | 191 |
189 disk_cache::Entry* entry; | 192 disk_cache::Entry* entry; |
190 if (!cache->CreateEntry("some other key", &entry)) | 193 if (!cache->CreateEntry("some other key", &entry)) |
191 return GENERIC; | 194 return GENERIC; |
192 | 195 |
193 entry->Close(); | 196 entry->Close(); |
194 if (!cache->CreateEntry(kCrashEntryName, &entry)) | 197 if (!cache->CreateEntry(kCrashEntryName, &entry)) |
195 return GENERIC; | 198 return GENERIC; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 302 |
300 std::wstring path; | 303 std::wstring path; |
301 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 304 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
302 file_util::AppendToPath(&path, L"net"); | 305 file_util::AppendToPath(&path, L"net"); |
303 file_util::AppendToPath(&path, L"data"); | 306 file_util::AppendToPath(&path, L"data"); |
304 file_util::AppendToPath(&path, L"cache_tests"); | 307 file_util::AppendToPath(&path, L"cache_tests"); |
305 file_util::AppendToPath(&path, L"new_crashes"); | 308 file_util::AppendToPath(&path, L"new_crashes"); |
306 | 309 |
307 return SlaveCode(path, action); | 310 return SlaveCode(path, action); |
308 } | 311 } |
OLD | NEW |