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

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

Issue 261045: Start migrating the disk cache to using FilePath. (Closed)
Patch Set: rebase Created 11 years, 2 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
« no previous file with comments | « net/disk_cache/entry_impl.cc ('k') | net/tools/crash_cache/crash_cache.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 // ----------------------------------------------------------------------- 72 // -----------------------------------------------------------------------
73 73
74 // This thread will loop forever, adding and removing entries from the cache. 74 // This thread will loop forever, adding and removing entries from the cache.
75 // iteration is the current crash cycle, so the entries on the cache are marked 75 // iteration is the current crash cycle, so the entries on the cache are marked
76 // to know which instance of the application wrote them. 76 // to know which instance of the application wrote them.
77 void StressTheCache(int iteration) { 77 void StressTheCache(int iteration) {
78 int cache_size = 0x800000; // 8MB 78 int cache_size = 0x800000; // 8MB
79 std::wstring path = GetCachePath(); 79 std::wstring path = GetCachePath();
80 path.append(L"_stress"); 80 path.append(L"_stress");
81 disk_cache::BackendImpl* cache = new disk_cache::BackendImpl(path); 81 disk_cache::BackendImpl* cache =
82 new disk_cache::BackendImpl(FilePath::FromWStringHack(path));
82 cache->SetFlags(disk_cache::kNoLoadProtection | disk_cache::kNoRandom); 83 cache->SetFlags(disk_cache::kNoLoadProtection | disk_cache::kNoRandom);
83 cache->SetMaxSize(cache_size); 84 cache->SetMaxSize(cache_size);
84 cache->SetType(net::DISK_CACHE); 85 cache->SetType(net::DISK_CACHE);
85 if (!cache->Init()) { 86 if (!cache->Init()) {
86 printf("Unable to initialize cache.\n"); 87 printf("Unable to initialize cache.\n");
87 return; 88 return;
88 } 89 }
89 printf("Iteration %d, initial entries: %d\n", iteration, 90 printf("Iteration %d, initial entries: %d\n", iteration,
90 cache->GetEntryCount()); 91 cache->GetEntryCount());
91 92
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 long int iteration = strtol(argv[1], &end, 0); 200 long int iteration = strtol(argv[1], &end, 0);
200 201
201 if (!StartCrashThread()) { 202 if (!StartCrashThread()) {
202 printf("failed to start thread\n"); 203 printf("failed to start thread\n");
203 return kError; 204 return kError;
204 } 205 }
205 206
206 StressTheCache(iteration); 207 StressTheCache(iteration);
207 return 0; 208 return 0;
208 } 209 }
OLDNEW
« no previous file with comments | « net/disk_cache/entry_impl.cc ('k') | net/tools/crash_cache/crash_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698