OLD | NEW |
---|---|
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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_path.h" | |
Lei Zhang
2009/10/13 20:15:54
I haven't bothered to put in file_path.h in file w
| |
8 #include "base/file_util.h" | 9 #include "base/file_util.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
10 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
11 #include "net/disk_cache/backend_impl.h" | 12 #include "net/disk_cache/backend_impl.h" |
12 #include "net/disk_cache/cache_util.h" | 13 #include "net/disk_cache/cache_util.h" |
13 #include "net/disk_cache/file.h" | 14 #include "net/disk_cache/file.h" |
14 | 15 |
15 using base::Time; | 16 using base::Time; |
16 using base::TimeDelta; | 17 using base::TimeDelta; |
17 | 18 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 | 66 |
66 scoped_refptr<disk_cache::File> file(new disk_cache::File( | 67 scoped_refptr<disk_cache::File> file(new disk_cache::File( |
67 base::CreatePlatformFile(name, flags, NULL))); | 68 base::CreatePlatformFile(name, flags, NULL))); |
68 if (!file->IsValid()) | 69 if (!file->IsValid()) |
69 return false; | 70 return false; |
70 | 71 |
71 file->SetLength(4 * 1024 * 1024); | 72 file->SetLength(4 * 1024 * 1024); |
72 return true; | 73 return true; |
73 } | 74 } |
74 | 75 |
76 bool DeleteCache(const FilePath& path) { | |
77 disk_cache::DeleteCache(path, false); | |
78 return true; | |
79 } | |
80 | |
75 bool DeleteCache(const wchar_t* path) { | 81 bool DeleteCache(const wchar_t* path) { |
76 disk_cache::DeleteCache(path, false); | 82 return DeleteCache(FilePath::FromWStringHack(path)); |
77 return true; | |
78 } | 83 } |
79 | 84 |
80 bool CheckCacheIntegrity(const std::wstring& path, bool new_eviction) { | 85 bool CheckCacheIntegrity(const std::wstring& path, bool new_eviction) { |
81 scoped_ptr<disk_cache::BackendImpl> cache(new disk_cache::BackendImpl( | 86 scoped_ptr<disk_cache::BackendImpl> cache(new disk_cache::BackendImpl( |
82 FilePath::FromWStringHack(path))); | 87 FilePath::FromWStringHack(path))); |
83 if (!cache.get()) | 88 if (!cache.get()) |
84 return false; | 89 return false; |
85 if (new_eviction) | 90 if (new_eviction) |
86 cache->SetNewEviction(); | 91 cache->SetNewEviction(); |
87 cache->SetFlags(disk_cache::kNoRandom); | 92 cache->SetFlags(disk_cache::kNoRandom); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 } else { | 169 } else { |
165 // Not finished yet. See if we have to abort. | 170 // Not finished yet. See if we have to abort. |
166 if (last_ == g_cache_tests_received) | 171 if (last_ == g_cache_tests_received) |
167 num_iterations_++; | 172 num_iterations_++; |
168 else | 173 else |
169 last_ = g_cache_tests_received; | 174 last_ = g_cache_tests_received; |
170 if (40 == num_iterations_) | 175 if (40 == num_iterations_) |
171 MessageLoop::current()->Quit(); | 176 MessageLoop::current()->Quit(); |
172 } | 177 } |
173 } | 178 } |
OLD | NEW |