| OLD | NEW |
| 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 #include "net/disk_cache/disk_cache_test_base.h" | 5 #include "net/disk_cache/disk_cache_test_base.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return cb.GetResult(rv); | 118 return cb.GetResult(rv); |
| 119 } | 119 } |
| 120 | 120 |
| 121 int DiskCacheTestWithCache::DoomEntry(const std::string& key) { | 121 int DiskCacheTestWithCache::DoomEntry(const std::string& key) { |
| 122 TestOldCompletionCallback cb; | 122 TestOldCompletionCallback cb; |
| 123 int rv = cache_->DoomEntry(key, &cb); | 123 int rv = cache_->DoomEntry(key, &cb); |
| 124 return cb.GetResult(rv); | 124 return cb.GetResult(rv); |
| 125 } | 125 } |
| 126 | 126 |
| 127 int DiskCacheTestWithCache::DoomAllEntries() { | 127 int DiskCacheTestWithCache::DoomAllEntries() { |
| 128 TestOldCompletionCallback cb; | 128 net::TestCompletionCallback cb; |
| 129 int rv = cache_->DoomAllEntries(&cb); | 129 int rv = cache_->DoomAllEntries(cb.callback()); |
| 130 return cb.GetResult(rv); | 130 return cb.GetResult(rv); |
| 131 } | 131 } |
| 132 | 132 |
| 133 int DiskCacheTestWithCache::DoomEntriesBetween(const base::Time initial_time, | 133 int DiskCacheTestWithCache::DoomEntriesBetween(const base::Time initial_time, |
| 134 const base::Time end_time) { | 134 const base::Time end_time) { |
| 135 TestOldCompletionCallback cb; | 135 net::TestCompletionCallback cb; |
| 136 int rv = cache_->DoomEntriesBetween(initial_time, end_time, &cb); | 136 int rv = cache_->DoomEntriesBetween(initial_time, end_time, cb.callback()); |
| 137 return cb.GetResult(rv); | 137 return cb.GetResult(rv); |
| 138 } | 138 } |
| 139 | 139 |
| 140 int DiskCacheTestWithCache::DoomEntriesSince(const base::Time initial_time) { | 140 int DiskCacheTestWithCache::DoomEntriesSince(const base::Time initial_time) { |
| 141 TestOldCompletionCallback cb; | 141 TestOldCompletionCallback cb; |
| 142 int rv = cache_->DoomEntriesSince(initial_time, &cb); | 142 int rv = cache_->DoomEntriesSince(initial_time, &cb); |
| 143 return cb.GetResult(rv); | 143 return cb.GetResult(rv); |
| 144 } | 144 } |
| 145 | 145 |
| 146 int DiskCacheTestWithCache::OpenNextEntry(void** iter, | 146 int DiskCacheTestWithCache::OpenNextEntry(void** iter, |
| 147 disk_cache::Entry** next_entry) { | 147 disk_cache::Entry** next_entry) { |
| 148 TestOldCompletionCallback cb; | 148 net::TestCompletionCallback cb; |
| 149 int rv = cache_->OpenNextEntry(iter, next_entry, &cb); | 149 int rv = cache_->OpenNextEntry(iter, next_entry, cb.callback()); |
| 150 return cb.GetResult(rv); | 150 return cb.GetResult(rv); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void DiskCacheTestWithCache::FlushQueueForTest() { | 153 void DiskCacheTestWithCache::FlushQueueForTest() { |
| 154 if (memory_only_ || !cache_impl_) | 154 if (memory_only_ || !cache_impl_) |
| 155 return; | 155 return; |
| 156 | 156 |
| 157 TestOldCompletionCallback cb; | 157 TestOldCompletionCallback cb; |
| 158 int rv = cache_impl_->FlushQueueForTest(&cb); | 158 int rv = cache_impl_->FlushQueueForTest(&cb); |
| 159 EXPECT_EQ(net::OK, cb.GetResult(rv)); | 159 EXPECT_EQ(net::OK, cb.GetResult(rv)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 171 EXPECT_EQ(net::OK, cb.GetResult(rv)); | 171 EXPECT_EQ(net::OK, cb.GetResult(rv)); |
| 172 } | 172 } |
| 173 | 173 |
| 174 int DiskCacheTestWithCache::ReadData(disk_cache::Entry* entry, int index, | 174 int DiskCacheTestWithCache::ReadData(disk_cache::Entry* entry, int index, |
| 175 int offset, net::IOBuffer* buf, int len) { | 175 int offset, net::IOBuffer* buf, int len) { |
| 176 TestOldCompletionCallback cb; | 176 TestOldCompletionCallback cb; |
| 177 int rv = entry->ReadData(index, offset, buf, len, &cb); | 177 int rv = entry->ReadData(index, offset, buf, len, &cb); |
| 178 return cb.GetResult(rv); | 178 return cb.GetResult(rv); |
| 179 } | 179 } |
| 180 | 180 |
| 181 | |
| 182 int DiskCacheTestWithCache::WriteData(disk_cache::Entry* entry, int index, | 181 int DiskCacheTestWithCache::WriteData(disk_cache::Entry* entry, int index, |
| 183 int offset, net::IOBuffer* buf, int len, | 182 int offset, net::IOBuffer* buf, int len, |
| 184 bool truncate) { | 183 bool truncate) { |
| 185 TestOldCompletionCallback cb; | 184 TestOldCompletionCallback cb; |
| 186 int rv = entry->WriteData(index, offset, buf, len, &cb, truncate); | 185 int rv = entry->WriteData(index, offset, buf, len, &cb, truncate); |
| 187 return cb.GetResult(rv); | 186 return cb.GetResult(rv); |
| 188 } | 187 } |
| 189 | 188 |
| 190 int DiskCacheTestWithCache::ReadSparseData(disk_cache::Entry* entry, | 189 int DiskCacheTestWithCache::ReadSparseData(disk_cache::Entry* entry, |
| 191 int64 offset, net::IOBuffer* buf, | 190 int64 offset, net::IOBuffer* buf, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 301 |
| 303 if (new_eviction_) | 302 if (new_eviction_) |
| 304 cache_impl_->SetNewEviction(); | 303 cache_impl_->SetNewEviction(); |
| 305 | 304 |
| 306 cache_impl_->SetType(type_); | 305 cache_impl_->SetType(type_); |
| 307 cache_impl_->SetFlags(disk_cache::kNoRandom); | 306 cache_impl_->SetFlags(disk_cache::kNoRandom); |
| 308 TestOldCompletionCallback cb; | 307 TestOldCompletionCallback cb; |
| 309 int rv = cache_impl_->Init(&cb); | 308 int rv = cache_impl_->Init(&cb); |
| 310 ASSERT_EQ(net::OK, cb.GetResult(rv)); | 309 ASSERT_EQ(net::OK, cb.GetResult(rv)); |
| 311 } | 310 } |
| OLD | NEW |