| OLD | NEW |
| 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 #include "net/disk_cache/disk_cache_test_util.h" | 5 #include "net/disk_cache/disk_cache_test_util.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 file->SetLength(4 * 1024 * 1024); | 71 file->SetLength(4 * 1024 * 1024); |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool DeleteCache(const FilePath& path) { | 75 bool DeleteCache(const FilePath& path) { |
| 76 disk_cache::DeleteCache(path, false); | 76 disk_cache::DeleteCache(path, false); |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool CopyTestCache(const std::string& name) { |
| 81 FilePath path; |
| 82 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
| 83 path = path.AppendASCII("net"); |
| 84 path = path.AppendASCII("data"); |
| 85 path = path.AppendASCII("cache_tests"); |
| 86 path = path.AppendASCII(name); |
| 87 |
| 88 FilePath dest = GetCacheFilePath(); |
| 89 if (!DeleteCache(dest)) |
| 90 return false; |
| 91 return file_util::CopyDirectory(path, dest, false); |
| 92 } |
| 93 |
| 80 bool CheckCacheIntegrity(const FilePath& path, bool new_eviction) { | 94 bool CheckCacheIntegrity(const FilePath& path, bool new_eviction) { |
| 81 scoped_ptr<disk_cache::BackendImpl> cache(new disk_cache::BackendImpl( | 95 scoped_ptr<disk_cache::BackendImpl> cache(new disk_cache::BackendImpl( |
| 82 path, base::MessageLoopProxy::CreateForCurrentThread())); | 96 path, base::MessageLoopProxy::CreateForCurrentThread())); |
| 83 if (!cache.get()) | 97 if (!cache.get()) |
| 84 return false; | 98 return false; |
| 85 if (new_eviction) | 99 if (new_eviction) |
| 86 cache->SetNewEviction(); | 100 cache->SetNewEviction(); |
| 87 cache->SetFlags(disk_cache::kNoRandom); | 101 cache->SetFlags(disk_cache::kNoRandom); |
| 88 if (!cache->Init()) | 102 if (!cache->Init()) |
| 89 return false; | 103 return false; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } else { | 170 } else { |
| 157 // Not finished yet. See if we have to abort. | 171 // Not finished yet. See if we have to abort. |
| 158 if (last_ == g_cache_tests_received) | 172 if (last_ == g_cache_tests_received) |
| 159 num_iterations_++; | 173 num_iterations_++; |
| 160 else | 174 else |
| 161 last_ = g_cache_tests_received; | 175 last_ = g_cache_tests_received; |
| 162 if (40 == num_iterations_) | 176 if (40 == num_iterations_) |
| 163 MessageLoop::current()->Quit(); | 177 MessageLoop::current()->Quit(); |
| 164 } | 178 } |
| 165 } | 179 } |
| OLD | NEW |