| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 base::FilePath path; | 106 base::FilePath path; |
| 107 PathService::Get(base::DIR_TEMP, &path); | 107 PathService::Get(base::DIR_TEMP, &path); |
| 108 path = path.AppendASCII("cache_test_stress"); | 108 path = path.AppendASCII("cache_test_stress"); |
| 109 | 109 |
| 110 base::Thread cache_thread("CacheThread"); | 110 base::Thread cache_thread("CacheThread"); |
| 111 if (!cache_thread.StartWithOptions( | 111 if (!cache_thread.StartWithOptions( |
| 112 base::Thread::Options(base::MessageLoop::TYPE_IO, 0))) | 112 base::Thread::Options(base::MessageLoop::TYPE_IO, 0))) |
| 113 return; | 113 return; |
| 114 | 114 |
| 115 disk_cache::BackendImpl* cache = | 115 disk_cache::BackendImpl* cache = |
| 116 new disk_cache::BackendImpl(path, mask, | 116 new disk_cache::BackendImpl(path, mask, cache_thread.task_runner(), NULL); |
| 117 cache_thread.message_loop_proxy().get(), | |
| 118 NULL); | |
| 119 cache->SetMaxSize(cache_size); | 117 cache->SetMaxSize(cache_size); |
| 120 cache->SetFlags(disk_cache::kNoLoadProtection); | 118 cache->SetFlags(disk_cache::kNoLoadProtection); |
| 121 | 119 |
| 122 net::TestCompletionCallback cb; | 120 net::TestCompletionCallback cb; |
| 123 int rv = cache->Init(cb.callback()); | 121 int rv = cache->Init(cb.callback()); |
| 124 | 122 |
| 125 if (cb.GetResult(rv) != net::OK) { | 123 if (cb.GetResult(rv) != net::OK) { |
| 126 printf("Unable to initialize cache.\n"); | 124 printf("Unable to initialize cache.\n"); |
| 127 return; | 125 return; |
| 128 } | 126 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 long int iteration = strtol(argv[1], &end, 0); | 282 long int iteration = strtol(argv[1], &end, 0); |
| 285 | 283 |
| 286 if (!StartCrashThread()) { | 284 if (!StartCrashThread()) { |
| 287 printf("failed to start thread\n"); | 285 printf("failed to start thread\n"); |
| 288 return kError; | 286 return kError; |
| 289 } | 287 } |
| 290 | 288 |
| 291 StressTheCache(iteration); | 289 StressTheCache(iteration); |
| 292 return 0; | 290 return 0; |
| 293 } | 291 } |
| OLD | NEW |