Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 8 #include "net/base/test_completion_callback.h" | 9 #include "net/base/test_completion_callback.h" |
| 9 #include "net/disk_cache/backend_impl.h" | 10 #include "net/disk_cache/backend_impl.h" |
| 10 #include "net/disk_cache/disk_cache_test_util.h" | 11 #include "net/disk_cache/disk_cache_test_util.h" |
| 11 #include "net/disk_cache/mem_backend_impl.h" | 12 #include "net/disk_cache/mem_backend_impl.h" |
| 12 | 13 |
| 13 void DiskCacheTest::TearDown() { | 14 void DiskCacheTest::TearDown() { |
| 14 MessageLoop::current()->RunAllPending(); | 15 MessageLoop::current()->RunAllPending(); |
| 15 } | 16 } |
| 16 | 17 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 } | 184 } |
| 184 | 185 |
| 185 void DiskCacheTestWithCache::FlushQueueForTest() { | 186 void DiskCacheTestWithCache::FlushQueueForTest() { |
| 186 if (memory_only_ || !cache_impl_) | 187 if (memory_only_ || !cache_impl_) |
| 187 return; | 188 return; |
| 188 | 189 |
| 189 TestCompletionCallback cb; | 190 TestCompletionCallback cb; |
| 190 int rv = cache_impl_->FlushQueueForTest(&cb); | 191 int rv = cache_impl_->FlushQueueForTest(&cb); |
| 191 EXPECT_EQ(net::OK, cb.GetResult(rv)); | 192 EXPECT_EQ(net::OK, cb.GetResult(rv)); |
| 192 } | 193 } |
| 194 | |
| 195 int DiskCacheTestWithCache::ReadData(disk_cache::Entry* entry, int index, | |
| 196 int offset, net::IOBuffer* buf, int len) { | |
| 197 TestCompletionCallback cb; | |
| 198 int rv = entry->ReadData(index, offset, buf, len, &cb); | |
| 199 return cb.GetResult(rv); | |
| 200 } | |
| 201 | |
| 202 | |
| 203 int DiskCacheTestWithCache::WriteData(disk_cache::Entry* entry, int index, | |
| 204 int offset, net::IOBuffer* buf, int len, | |
| 205 bool truncate) { | |
| 206 TestCompletionCallback cb; | |
| 207 int rv = entry->WriteData(index, offset, buf, len, &cb, truncate); | |
| 208 return cb.GetResult(rv); | |
| 209 } | |
| 210 | |
| 211 int DiskCacheTestWithCache::ReadSparseData(disk_cache::Entry* entry, | |
| 212 int64 offset, net::IOBuffer* buf, | |
| 213 int len) { | |
| 214 TestCompletionCallback cb; | |
| 215 int rv = entry->ReadSparseData(offset, buf, len, &cb); | |
| 216 return cb.GetResult(rv); | |
| 217 } | |
| 218 | |
| 219 int DiskCacheTestWithCache::WriteSparseData(disk_cache::Entry* entry, | |
| 220 int64 offset, | |
| 221 net::IOBuffer* buf, int len) { | |
| 222 TestCompletionCallback cb; | |
| 223 int rv = entry->WriteSparseData(offset, buf, len, &cb); | |
| 224 return cb.GetResult(rv); | |
| 225 } | |
|
gavinp
2010/08/19 18:17:22
nit: add a newline
| |
| OLD | NEW |