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

Side by Side Diff: net/tools/crash_cache/crash_cache.cc

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 command-line program generates the set of files needed for the crash- 5 // This command-line program generates the set of files needed for the crash-
6 // cache unit tests (DiskCacheTest,CacheBackend_Recover*). This program only 6 // cache unit tests (DiskCacheTest,CacheBackend_Recover*). This program only
7 // works properly on debug mode, because the crash functionality is not compiled 7 // works properly on debug mode, because the crash functionality is not compiled
8 // on release builds of the cache. 8 // on release builds of the cache.
9 9
10 #include <string> 10 #include <string>
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 reinterpret_cast<disk_cache::BackendImpl*>(cache)->FlushQueueForTest( 132 reinterpret_cast<disk_cache::BackendImpl*>(cache)->FlushQueueForTest(
133 cb.callback()); 133 cb.callback());
134 cb.GetResult(rv); // Ignore the result; 134 cb.GetResult(rv); // Ignore the result;
135 } 135 }
136 136
137 bool CreateCache(const base::FilePath& path, 137 bool CreateCache(const base::FilePath& path,
138 base::Thread* thread, 138 base::Thread* thread,
139 disk_cache::Backend** cache, 139 disk_cache::Backend** cache,
140 net::TestCompletionCallback* cb) { 140 net::TestCompletionCallback* cb) {
141 int size = 1024 * 1024; 141 int size = 1024 * 1024;
142 disk_cache::BackendImpl* backend = new disk_cache::BackendImpl( 142 disk_cache::BackendImpl* backend =
143 path, thread->message_loop_proxy().get(), NULL); 143 new disk_cache::BackendImpl(path, thread->task_runner(), NULL);
144 backend->SetMaxSize(size); 144 backend->SetMaxSize(size);
145 backend->SetType(net::DISK_CACHE); 145 backend->SetType(net::DISK_CACHE);
146 backend->SetFlags(disk_cache::kNoRandom); 146 backend->SetFlags(disk_cache::kNoRandom);
147 int rv = backend->Init(cb->callback()); 147 int rv = backend->Init(cb->callback());
148 *cache = backend; 148 *cache = backend;
149 return (cb->GetResult(rv) == net::OK && !(*cache)->GetEntryCount()); 149 return (cb->GetResult(rv) == net::OK && !(*cache)->GetEntryCount());
150 } 150 }
151 151
152 // Generates the files for an empty and one item cache. 152 // Generates the files for an empty and one item cache.
153 int SimpleInsert(const base::FilePath& path, RankCrashes action, 153 int SimpleInsert(const base::FilePath& path, RankCrashes action,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 return NOT_REACHED; 259 return NOT_REACHED;
260 } 260 }
261 261
262 // Generates the files for insertion and removals on heavy loaded caches. 262 // Generates the files for insertion and removals on heavy loaded caches.
263 int LoadOperations(const base::FilePath& path, RankCrashes action, 263 int LoadOperations(const base::FilePath& path, RankCrashes action,
264 base::Thread* cache_thread) { 264 base::Thread* cache_thread) {
265 DCHECK(action >= disk_cache::INSERT_LOAD_1); 265 DCHECK(action >= disk_cache::INSERT_LOAD_1);
266 266
267 // Work with a tiny index table (16 entries). 267 // Work with a tiny index table (16 entries).
268 disk_cache::BackendImpl* cache = new disk_cache::BackendImpl( 268 disk_cache::BackendImpl* cache =
269 path, 0xf, cache_thread->message_loop_proxy().get(), NULL); 269 new disk_cache::BackendImpl(path, 0xf, cache_thread->task_runner(), NULL);
270 if (!cache->SetMaxSize(0x100000)) 270 if (!cache->SetMaxSize(0x100000))
271 return GENERIC; 271 return GENERIC;
272 272
273 // No experiments and use a simple LRU. 273 // No experiments and use a simple LRU.
274 cache->SetFlags(disk_cache::kNoRandom); 274 cache->SetFlags(disk_cache::kNoRandom);
275 net::TestCompletionCallback cb; 275 net::TestCompletionCallback cb;
276 int rv = cache->Init(cb.callback()); 276 int rv = cache->Init(cb.callback());
277 if (cb.GetResult(rv) != net::OK || cache->GetEntryCount()) 277 if (cb.GetResult(rv) != net::OK || cache->GetEntryCount())
278 return GENERIC; 278 return GENERIC;
279 279
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 372
373 base::FilePath path; 373 base::FilePath path;
374 PathService::Get(base::DIR_SOURCE_ROOT, &path); 374 PathService::Get(base::DIR_SOURCE_ROOT, &path);
375 path = path.AppendASCII("net"); 375 path = path.AppendASCII("net");
376 path = path.AppendASCII("data"); 376 path = path.AppendASCII("data");
377 path = path.AppendASCII("cache_tests"); 377 path = path.AppendASCII("cache_tests");
378 path = path.AppendASCII("new_crashes"); 378 path = path.AppendASCII("new_crashes");
379 379
380 return SlaveCode(path, action); 380 return SlaveCode(path, action);
381 } 381 }
OLDNEW
« no previous file with comments | « net/tools/balsa/string_piece_utils.h ('k') | net/tools/disk_cache_memory_test/disk_cache_memory_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698