OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 base::Thread cache_thread("CacheThread"); | 97 base::Thread cache_thread("CacheThread"); |
98 if (!cache_thread.StartWithOptions( | 98 if (!cache_thread.StartWithOptions( |
99 base::Thread::Options(MessageLoop::TYPE_IO, 0))) | 99 base::Thread::Options(MessageLoop::TYPE_IO, 0))) |
100 return; | 100 return; |
101 | 101 |
102 TestCompletionCallback cb; | 102 TestCompletionCallback cb; |
103 disk_cache::Backend* cache; | 103 disk_cache::Backend* cache; |
104 int rv = disk_cache::BackendImpl::CreateBackend( | 104 int rv = disk_cache::BackendImpl::CreateBackend( |
105 path, false, cache_size, net::DISK_CACHE, | 105 path, false, cache_size, net::DISK_CACHE, |
106 disk_cache::kNoLoadProtection | disk_cache::kNoRandom, | 106 disk_cache::kNoLoadProtection | disk_cache::kNoRandom, |
107 cache_thread.message_loop_proxy(), &cache, &cb); | 107 cache_thread.message_loop_proxy(), NULL, &cache, &cb); |
108 | 108 |
109 if (cb.GetResult(rv) != net::OK) { | 109 if (cb.GetResult(rv) != net::OK) { |
110 printf("Unable to initialize cache.\n"); | 110 printf("Unable to initialize cache.\n"); |
111 return; | 111 return; |
112 } | 112 } |
113 printf("Iteration %d, initial entries: %d\n", iteration, | 113 printf("Iteration %d, initial entries: %d\n", iteration, |
114 cache->GetEntryCount()); | 114 cache->GetEntryCount()); |
115 | 115 |
116 int seed = static_cast<int>(Time::Now().ToInternalValue()); | 116 int seed = static_cast<int>(Time::Now().ToInternalValue()); |
117 srand(seed); | 117 srand(seed); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 long int iteration = strtol(argv[1], &end, 0); | 235 long int iteration = strtol(argv[1], &end, 0); |
236 | 236 |
237 if (!StartCrashThread()) { | 237 if (!StartCrashThread()) { |
238 printf("failed to start thread\n"); | 238 printf("failed to start thread\n"); |
239 return kError; | 239 return kError; |
240 } | 240 } |
241 | 241 |
242 StressTheCache(iteration); | 242 StressTheCache(iteration); |
243 return 0; | 243 return 0; |
244 } | 244 } |
OLD | NEW |