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

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

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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
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 disk_cache::BackendImpl* backend = 141 disk_cache::BackendImpl* backend = new disk_cache::BackendImpl(
142 new disk_cache::BackendImpl(path, thread->message_loop_proxy(), NULL); 142 path, thread->message_loop_proxy().get(), NULL);
143 backend->SetMaxSize(size); 143 backend->SetMaxSize(size);
144 backend->SetType(net::DISK_CACHE); 144 backend->SetType(net::DISK_CACHE);
145 backend->SetFlags(disk_cache::kNoRandom); 145 backend->SetFlags(disk_cache::kNoRandom);
146 int rv = backend->Init(cb->callback()); 146 int rv = backend->Init(cb->callback());
147 *cache = backend; 147 *cache = backend;
148 return (cb->GetResult(rv) == net::OK && !(*cache)->GetEntryCount()); 148 return (cb->GetResult(rv) == net::OK && !(*cache)->GetEntryCount());
149 } 149 }
150 150
151 // Generates the files for an empty and one item cache. 151 // Generates the files for an empty and one item cache.
152 int SimpleInsert(const base::FilePath& path, RankCrashes action, 152 int SimpleInsert(const base::FilePath& path, RankCrashes action,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 return NOT_REACHED; 258 return NOT_REACHED;
259 } 259 }
260 260
261 // Generates the files for insertion and removals on heavy loaded caches. 261 // Generates the files for insertion and removals on heavy loaded caches.
262 int LoadOperations(const base::FilePath& path, RankCrashes action, 262 int LoadOperations(const base::FilePath& path, RankCrashes action,
263 base::Thread* cache_thread) { 263 base::Thread* cache_thread) {
264 DCHECK(action >= disk_cache::INSERT_LOAD_1); 264 DCHECK(action >= disk_cache::INSERT_LOAD_1);
265 265
266 // Work with a tiny index table (16 entries). 266 // Work with a tiny index table (16 entries).
267 disk_cache::BackendImpl* cache = new disk_cache::BackendImpl( 267 disk_cache::BackendImpl* cache = new disk_cache::BackendImpl(
268 path, 0xf, cache_thread->message_loop_proxy(), NULL); 268 path, 0xf, cache_thread->message_loop_proxy().get(), NULL);
269 if (!cache || !cache->SetMaxSize(0x100000)) 269 if (!cache || !cache->SetMaxSize(0x100000))
270 return GENERIC; 270 return GENERIC;
271 271
272 // No experiments and use a simple LRU. 272 // No experiments and use a simple LRU.
273 cache->SetFlags(disk_cache::kNoRandom); 273 cache->SetFlags(disk_cache::kNoRandom);
274 net::TestCompletionCallback cb; 274 net::TestCompletionCallback cb;
275 int rv = cache->Init(cb.callback()); 275 int rv = cache->Init(cb.callback());
276 if (cb.GetResult(rv) != net::OK || cache->GetEntryCount()) 276 if (cb.GetResult(rv) != net::OK || cache->GetEntryCount())
277 return GENERIC; 277 return GENERIC;
278 278
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 371
372 base::FilePath path; 372 base::FilePath path;
373 PathService::Get(base::DIR_SOURCE_ROOT, &path); 373 PathService::Get(base::DIR_SOURCE_ROOT, &path);
374 path = path.AppendASCII("net"); 374 path = path.AppendASCII("net");
375 path = path.AppendASCII("data"); 375 path = path.AppendASCII("data");
376 path = path.AppendASCII("cache_tests"); 376 path = path.AppendASCII("cache_tests");
377 path = path.AppendASCII("new_crashes"); 377 path = path.AppendASCII("new_crashes");
378 378
379 return SlaveCode(path, action); 379 return SlaveCode(path, action);
380 } 380 }
OLDNEW
« no previous file with comments | « net/spdy/spdy_network_transaction_spdy3_unittest.cc ('k') | net/tools/dump_cache/simple_cache_dumper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698