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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 net::TestCompletionCallback cb; | 161 net::TestCompletionCallback cb; |
162 rv = cache->OpenEntry(keys[key], &entries[slot], cb.callback()); | 162 rv = cache->OpenEntry(keys[key], &entries[slot], cb.callback()); |
163 if (cb.GetResult(rv) != net::OK) { | 163 if (cb.GetResult(rv) != net::OK) { |
164 rv = cache->CreateEntry(keys[key], &entries[slot], cb.callback()); | 164 rv = cache->CreateEntry(keys[key], &entries[slot], cb.callback()); |
165 CHECK_EQ(net::OK, cb.GetResult(rv)); | 165 CHECK_EQ(net::OK, cb.GetResult(rv)); |
166 } | 166 } |
167 | 167 |
168 base::snprintf(buffer->data(), kSize, | 168 base::snprintf(buffer->data(), kSize, |
169 "i: %d iter: %d, size: %d, truncate: %d ", i, iteration, | 169 "i: %d iter: %d, size: %d, truncate: %d ", i, iteration, |
170 size, truncate ? 1 : 0); | 170 size, truncate ? 1 : 0); |
171 rv = entries[slot]->WriteData(0, 0, buffer, size, cb.callback(), truncate); | 171 rv = entries[slot] |
| 172 ->WriteData(0, 0, buffer.get(), size, cb.callback(), truncate); |
172 CHECK_EQ(size, cb.GetResult(rv)); | 173 CHECK_EQ(size, cb.GetResult(rv)); |
173 | 174 |
174 if (rand() % 100 > 80) { | 175 if (rand() % 100 > 80) { |
175 key = rand() % kNumKeys; | 176 key = rand() % kNumKeys; |
176 net::TestCompletionCallback cb2; | 177 net::TestCompletionCallback cb2; |
177 rv = cache->DoomEntry(keys[key], cb2.callback()); | 178 rv = cache->DoomEntry(keys[key], cb2.callback()); |
178 cb2.GetResult(rv); | 179 cb2.GetResult(rv); |
179 } | 180 } |
180 | 181 |
181 if (!(i % 100)) | 182 if (!(i % 100)) |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 long int iteration = strtol(argv[1], &end, 0); | 282 long int iteration = strtol(argv[1], &end, 0); |
282 | 283 |
283 if (!StartCrashThread()) { | 284 if (!StartCrashThread()) { |
284 printf("failed to start thread\n"); | 285 printf("failed to start thread\n"); |
285 return kError; | 286 return kError; |
286 } | 287 } |
287 | 288 |
288 StressTheCache(iteration); | 289 StressTheCache(iteration); |
289 return 0; | 290 return 0; |
290 } | 291 } |
OLD | NEW |