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

Side by Side Diff: net/disk_cache/disk_cache_test_util.cc

Issue 2891022: Disk cache: Read the index and data_0 files in a single... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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
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 #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
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
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 }
OLDNEW
« net/disk_cache/disk_cache_test_util.h ('K') | « net/disk_cache/disk_cache_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698