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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 // ----------------------------------------------------------------------- | 72 // ----------------------------------------------------------------------- |
73 | 73 |
74 // This thread will loop forever, adding and removing entries from the cache. | 74 // This thread will loop forever, adding and removing entries from the cache. |
75 // iteration is the current crash cycle, so the entries on the cache are marked | 75 // iteration is the current crash cycle, so the entries on the cache are marked |
76 // to know which instance of the application wrote them. | 76 // to know which instance of the application wrote them. |
77 void StressTheCache(int iteration) { | 77 void StressTheCache(int iteration) { |
78 int cache_size = 0x800000; // 8MB | 78 int cache_size = 0x800000; // 8MB |
79 std::wstring path = GetCachePath(); | 79 std::wstring path = GetCachePath(); |
80 path.append(L"_stress"); | 80 path.append(L"_stress"); |
81 disk_cache::BackendImpl* cache = new disk_cache::BackendImpl(path); | 81 disk_cache::BackendImpl* cache = |
| 82 new disk_cache::BackendImpl(FilePath::FromWStringHack(path)); |
82 cache->SetFlags(disk_cache::kNoLoadProtection | disk_cache::kNoRandom); | 83 cache->SetFlags(disk_cache::kNoLoadProtection | disk_cache::kNoRandom); |
83 cache->SetMaxSize(cache_size); | 84 cache->SetMaxSize(cache_size); |
84 cache->SetType(net::DISK_CACHE); | 85 cache->SetType(net::DISK_CACHE); |
85 if (!cache->Init()) { | 86 if (!cache->Init()) { |
86 printf("Unable to initialize cache.\n"); | 87 printf("Unable to initialize cache.\n"); |
87 return; | 88 return; |
88 } | 89 } |
89 printf("Iteration %d, initial entries: %d\n", iteration, | 90 printf("Iteration %d, initial entries: %d\n", iteration, |
90 cache->GetEntryCount()); | 91 cache->GetEntryCount()); |
91 | 92 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 long int iteration = strtol(argv[1], &end, 0); | 200 long int iteration = strtol(argv[1], &end, 0); |
200 | 201 |
201 if (!StartCrashThread()) { | 202 if (!StartCrashThread()) { |
202 printf("failed to start thread\n"); | 203 printf("failed to start thread\n"); |
203 return kError; | 204 return kError; |
204 } | 205 } |
205 | 206 |
206 StressTheCache(iteration); | 207 StressTheCache(iteration); |
207 return 0; | 208 return 0; |
208 } | 209 } |
OLD | NEW |