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