| 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_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 if (len && !buffer[0]) | 53 if (len && !buffer[0]) |
| 54 buffer[0] = 'g'; | 54 buffer[0] = 'g'; |
| 55 } | 55 } |
| 56 | 56 |
| 57 std::wstring GetCachePath() { | 57 std::wstring GetCachePath() { |
| 58 return BuildCachePath(L"cache_test"); | 58 return BuildCachePath(L"cache_test"); |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool CreateCacheTestFile(const wchar_t* name) { | 61 bool CreateCacheTestFile(const wchar_t* name) { |
| 62 using namespace disk_cache; | |
| 63 int flags = base::PLATFORM_FILE_CREATE_ALWAYS | | 62 int flags = base::PLATFORM_FILE_CREATE_ALWAYS | |
| 64 base::PLATFORM_FILE_READ | | 63 base::PLATFORM_FILE_READ | |
| 65 base::PLATFORM_FILE_WRITE; | 64 base::PLATFORM_FILE_WRITE; |
| 66 | 65 |
| 67 scoped_refptr<File> file(new File( | 66 scoped_refptr<disk_cache::File> file(new disk_cache::File( |
| 68 base::CreatePlatformFile(name, flags, NULL))); | 67 base::CreatePlatformFile(name, flags, NULL))); |
| 69 if (!file->IsValid()) | 68 if (!file->IsValid()) |
| 70 return false; | 69 return false; |
| 71 | 70 |
| 72 file->SetLength(4 * 1024 * 1024); | 71 file->SetLength(4 * 1024 * 1024); |
| 73 return true; | 72 return true; |
| 74 } | 73 } |
| 75 | 74 |
| 76 bool DeleteCache(const wchar_t* path) { | 75 bool DeleteCache(const wchar_t* path) { |
| 77 disk_cache::DeleteCache(path, false); | 76 disk_cache::DeleteCache(path, false); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } else { | 162 } else { |
| 164 // Not finished yet. See if we have to abort. | 163 // Not finished yet. See if we have to abort. |
| 165 if (last_ == g_cache_tests_received) | 164 if (last_ == g_cache_tests_received) |
| 166 num_iterations_++; | 165 num_iterations_++; |
| 167 else | 166 else |
| 168 last_ = g_cache_tests_received; | 167 last_ = g_cache_tests_received; |
| 169 if (40 == num_iterations_) | 168 if (40 == num_iterations_) |
| 170 MessageLoop::current()->Quit(); | 169 MessageLoop::current()->Quit(); |
| 171 } | 170 } |
| 172 } | 171 } |
| OLD | NEW |