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 is a simple application that stress-tests the crash recovery of the disk | 5 // This is a simple application that stress-tests the crash recovery of the disk |
6 // cache. The main application starts a copy of itself on a loop, checking the | 6 // cache. The main application starts a copy of itself on a loop, checking the |
7 // exit code of the child process. When the child dies in an unexpected way, | 7 // exit code of the child process. When the child dies in an unexpected way, |
8 // the main application quits. | 8 // the main application quits. |
9 | 9 |
10 // The child application has two threads: one to exercise the cache in an | 10 // The child application has two threads: one to exercise the cache in an |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // ----------------------------------------------------------------------- | 70 // ----------------------------------------------------------------------- |
71 | 71 |
72 // This thread will loop forever, adding and removing entries from the cache. | 72 // This thread will loop forever, adding and removing entries from the cache. |
73 // iteration is the current crash cycle, so the entries on the cache are marked | 73 // iteration is the current crash cycle, so the entries on the cache are marked |
74 // to know which instance of the application wrote them. | 74 // to know which instance of the application wrote them. |
75 void StressTheCache(int iteration) { | 75 void StressTheCache(int iteration) { |
76 int cache_size = 0x800000; // 8MB | 76 int cache_size = 0x800000; // 8MB |
77 std::wstring path = GetCachePath(); | 77 std::wstring path = GetCachePath(); |
78 path.append(L"_stress"); | 78 path.append(L"_stress"); |
79 disk_cache::Backend* cache = disk_cache::CreateCacheBackend(path, false, | 79 disk_cache::Backend* cache = disk_cache::CreateCacheBackend(path, false, |
80 cache_size); | 80 cache_size, |
| 81 net::DISK_CACHE); |
81 if (NULL == cache) { | 82 if (NULL == cache) { |
82 printf("Unable to initialize cache.\n"); | 83 printf("Unable to initialize cache.\n"); |
83 return; | 84 return; |
84 } | 85 } |
85 printf("Iteration %d, initial entries: %d\n", iteration, | 86 printf("Iteration %d, initial entries: %d\n", iteration, |
86 cache->GetEntryCount()); | 87 cache->GetEntryCount()); |
87 | 88 |
88 int seed = static_cast<int>(Time::Now().ToInternalValue()); | 89 int seed = static_cast<int>(Time::Now().ToInternalValue()); |
89 srand(seed); | 90 srand(seed); |
90 | 91 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 long int iteration = strtol(argv[1], &end, 0); | 195 long int iteration = strtol(argv[1], &end, 0); |
195 | 196 |
196 if (!StartCrashThread()) { | 197 if (!StartCrashThread()) { |
197 printf("failed to start thread\n"); | 198 printf("failed to start thread\n"); |
198 return kError; | 199 return kError; |
199 } | 200 } |
200 | 201 |
201 StressTheCache(iteration); | 202 StressTheCache(iteration); |
202 return 0; | 203 return 0; |
203 } | 204 } |
OLD | NEW |