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

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

Issue 12794003: Initialize the simple cache backend at runtime. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebased to latest, auto-merged net.gyp Created 7 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
« no previous file with comments | « net/net.gyp ('k') | no next file » | 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) 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 reinterpret_cast<disk_cache::BackendImpl*>(cache)->FlushQueueForTest( 131 reinterpret_cast<disk_cache::BackendImpl*>(cache)->FlushQueueForTest(
132 cb.callback()); 132 cb.callback());
133 cb.GetResult(rv); // Ignore the result; 133 cb.GetResult(rv); // Ignore the result;
134 } 134 }
135 135
136 bool CreateCache(const base::FilePath& path, 136 bool CreateCache(const base::FilePath& path,
137 base::Thread* thread, 137 base::Thread* thread,
138 disk_cache::Backend** cache, 138 disk_cache::Backend** cache,
139 net::TestCompletionCallback* cb) { 139 net::TestCompletionCallback* cb) {
140 int size = 1024 * 1024; 140 int size = 1024 * 1024;
141 int rv = disk_cache::BackendImpl::CreateBackend( 141 disk_cache::BackendImpl* backend =
142 path, false, size, net::DISK_CACHE, disk_cache::kNoRandom, 142 new disk_cache::BackendImpl(path, thread->message_loop_proxy(), NULL);
143 thread->message_loop_proxy(), NULL, cache, cb->callback()); 143 backend->SetMaxSize(size);
144 144 backend->SetType(net::DISK_CACHE);
145 backend->SetFlags(disk_cache::kNoRandom);
146 int rv = backend->Init(cb->callback());
147 *cache = backend;
145 return (cb->GetResult(rv) == net::OK && !(*cache)->GetEntryCount()); 148 return (cb->GetResult(rv) == net::OK && !(*cache)->GetEntryCount());
146 } 149 }
147 150
148 // Generates the files for an empty and one item cache. 151 // Generates the files for an empty and one item cache.
149 int SimpleInsert(const base::FilePath& path, RankCrashes action, 152 int SimpleInsert(const base::FilePath& path, RankCrashes action,
150 base::Thread* cache_thread) { 153 base::Thread* cache_thread) {
151 net::TestCompletionCallback cb; 154 net::TestCompletionCallback cb;
152 disk_cache::Backend* cache; 155 disk_cache::Backend* cache;
153 if (!CreateCache(path, cache_thread, &cache, &cb)) 156 if (!CreateCache(path, cache_thread, &cache, &cb))
154 return GENERIC; 157 return GENERIC;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 371
369 base::FilePath path; 372 base::FilePath path;
370 PathService::Get(base::DIR_SOURCE_ROOT, &path); 373 PathService::Get(base::DIR_SOURCE_ROOT, &path);
371 path = path.AppendASCII("net"); 374 path = path.AppendASCII("net");
372 path = path.AppendASCII("data"); 375 path = path.AppendASCII("data");
373 path = path.AppendASCII("cache_tests"); 376 path = path.AppendASCII("cache_tests");
374 path = path.AppendASCII("new_crashes"); 377 path = path.AppendASCII("new_crashes");
375 378
376 return SlaveCode(path, action); 379 return SlaveCode(path, action);
377 } 380 }
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698