Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: net/disk_cache/stress_cache.cc

Issue 10942004: Cleanup: avoid foo ? true : false, part 2. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/entry_impl.cc ('k') | net/http/http_response_info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 keys[i] = GenerateStressKey(); 145 keys[i] = GenerateStressKey();
146 } 146 }
147 147
148 const int kSize = 20000; 148 const int kSize = 20000;
149 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kSize)); 149 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kSize));
150 memset(buffer->data(), 'k', kSize); 150 memset(buffer->data(), 'k', kSize);
151 151
152 for (int i = 0;; i++) { 152 for (int i = 0;; i++) {
153 int slot = rand() % kNumEntries; 153 int slot = rand() % kNumEntries;
154 int key = rand() % kNumKeys; 154 int key = rand() % kNumKeys;
155 bool truncate = rand() % 2 ? false : true; 155 bool truncate = (rand() % 2 == 0);
156 int size = kSize - (rand() % 20) * kSize / 20; 156 int size = kSize - (rand() % 20) * kSize / 20;
157 157
158 if (entries[slot]) 158 if (entries[slot])
159 entries[slot]->Close(); 159 entries[slot]->Close();
160 160
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));
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 long int iteration = strtol(argv[1], &end, 0); 281 long int iteration = strtol(argv[1], &end, 0);
282 282
283 if (!StartCrashThread()) { 283 if (!StartCrashThread()) {
284 printf("failed to start thread\n"); 284 printf("failed to start thread\n");
285 return kError; 285 return kError;
286 } 286 }
287 287
288 StressTheCache(iteration); 288 StressTheCache(iteration);
289 return 0; 289 return 0;
290 } 290 }
OLDNEW
« no previous file with comments | « net/disk_cache/entry_impl.cc ('k') | net/http/http_response_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698