| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 rv = cache->CreateEntry(keys[key], &entries[slot], &cb); | 127 rv = cache->CreateEntry(keys[key], &entries[slot], &cb); |
| 128 CHECK_EQ(net::OK, cb.GetResult(rv)); | 128 CHECK_EQ(net::OK, cb.GetResult(rv)); |
| 129 } | 129 } |
| 130 | 130 |
| 131 base::snprintf(buffer->data(), kSize, "%d %d", iteration, i); | 131 base::snprintf(buffer->data(), kSize, "%d %d", iteration, i); |
| 132 rv = entries[slot]->WriteData(0, 0, buffer, kSize, &cb, false); | 132 rv = entries[slot]->WriteData(0, 0, buffer, kSize, &cb, false); |
| 133 CHECK_EQ(kSize, cb.GetResult(rv)); | 133 CHECK_EQ(kSize, cb.GetResult(rv)); |
| 134 | 134 |
| 135 if (rand() % 100 > 80) { | 135 if (rand() % 100 > 80) { |
| 136 key = rand() % kNumKeys; | 136 key = rand() % kNumKeys; |
| 137 cache->DoomEntry(keys[key]); | 137 rv = cache->DoomEntry(keys[key], &cb); |
| 138 cb.GetResult(rv); |
| 138 } | 139 } |
| 139 | 140 |
| 140 if (!(i % 100)) | 141 if (!(i % 100)) |
| 141 printf("Entries: %d \r", i); | 142 printf("Entries: %d \r", i); |
| 142 MessageLoop::current()->RunAllPending(); | 143 MessageLoop::current()->RunAllPending(); |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 | 146 |
| 146 // We want to prevent the timer thread from killing the process while we are | 147 // We want to prevent the timer thread from killing the process while we are |
| 147 // waiting for the debugger to attach. | 148 // waiting for the debugger to attach. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 long int iteration = strtol(argv[1], &end, 0); | 214 long int iteration = strtol(argv[1], &end, 0); |
| 214 | 215 |
| 215 if (!StartCrashThread()) { | 216 if (!StartCrashThread()) { |
| 216 printf("failed to start thread\n"); | 217 printf("failed to start thread\n"); |
| 217 return kError; | 218 return kError; |
| 218 } | 219 } |
| 219 | 220 |
| 220 StressTheCache(iteration); | 221 StressTheCache(iteration); |
| 221 return 0; | 222 return 0; |
| 222 } | 223 } |
| OLD | NEW |