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

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

Issue 6292011: Disk cache: Prevent obscure file corruption and deal... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2010 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 #include "net/disk_cache/disk_cache_test_base.h" 5 #include "net/disk_cache/disk_cache_test_base.h"
6 6
7 #include "net/base/io_buffer.h" 7 #include "net/base/io_buffer.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/base/test_completion_callback.h" 9 #include "net/base/test_completion_callback.h"
10 #include "net/disk_cache/backend_impl.h" 10 #include "net/disk_cache/backend_impl.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 return cb.GetResult(rv); 229 return cb.GetResult(rv);
230 } 230 }
231 231
232 int DiskCacheTestWithCache::WriteSparseData(disk_cache::Entry* entry, 232 int DiskCacheTestWithCache::WriteSparseData(disk_cache::Entry* entry,
233 int64 offset, 233 int64 offset,
234 net::IOBuffer* buf, int len) { 234 net::IOBuffer* buf, int len) {
235 TestCompletionCallback cb; 235 TestCompletionCallback cb;
236 int rv = entry->WriteSparseData(offset, buf, len, &cb); 236 int rv = entry->WriteSparseData(offset, buf, len, &cb);
237 return cb.GetResult(rv); 237 return cb.GetResult(rv);
238 } 238 }
239
240 // Simple task to run part of a test from the cache thread.
241 class TrimTask : public Task {
242 public:
243 TrimTask(disk_cache::BackendImpl* backend, bool deleted, bool empty)
244 : backend_(backend),
245 deleted_(deleted),
246 empty_(empty) {}
247
248 virtual void Run() {
249 if (deleted_)
250 backend_->TrimDeletedListForTest(empty_);
251 else
252 backend_->TrimForTest(empty_);
253 }
254
255 protected:
256 disk_cache::BackendImpl* backend_;
257 bool deleted_;
258 bool empty_;
259 };
260
261 void DiskCacheTestWithCache::TrimForTest(bool empty) {
262 RunTaskForTest(new TrimTask(cache_impl_, false, empty));
263 }
264
265 void DiskCacheTestWithCache::TrimDeletedListForTest(bool empty) {
266 RunTaskForTest(new TrimTask(cache_impl_, true, empty));
267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698