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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 simple_cache_mode_(false), 61 simple_cache_mode_(false),
62 simple_cache_wait_for_index_(true), 62 simple_cache_wait_for_index_(true),
63 force_creation_(false), 63 force_creation_(false),
64 new_eviction_(false), 64 new_eviction_(false),
65 first_cleanup_(true), 65 first_cleanup_(true),
66 integrity_(true), 66 integrity_(true),
67 use_current_thread_(false), 67 use_current_thread_(false),
68 cache_thread_("CacheThread") { 68 cache_thread_("CacheThread") {
69 } 69 }
70 70
71 DiskCacheTestWithCache::~DiskCacheTestWithCache() {} 71 DiskCacheTestWithCache::~DiskCacheTestWithCache() {
72 }
72 73
73 void DiskCacheTestWithCache::InitCache() { 74 void DiskCacheTestWithCache::InitCache() {
74 if (memory_only_) 75 if (memory_only_)
75 InitMemoryCache(); 76 InitMemoryCache();
76 else 77 else
77 InitDiskCache(); 78 InitDiskCache();
78 79
79 ASSERT_TRUE(NULL != cache_); 80 ASSERT_TRUE(NULL != cache_);
80 if (first_cleanup_) 81 if (first_cleanup_)
81 ASSERT_EQ(0, cache_->GetEntryCount()); 82 ASSERT_EQ(0, cache_->GetEntryCount());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 if (memory_only_ || !cache_impl_) { 172 if (memory_only_ || !cache_impl_) {
172 closure.Run(); 173 closure.Run();
173 return; 174 return;
174 } 175 }
175 176
176 net::TestCompletionCallback cb; 177 net::TestCompletionCallback cb;
177 int rv = cache_impl_->RunTaskForTest(closure, cb.callback()); 178 int rv = cache_impl_->RunTaskForTest(closure, cb.callback());
178 EXPECT_EQ(net::OK, cb.GetResult(rv)); 179 EXPECT_EQ(net::OK, cb.GetResult(rv));
179 } 180 }
180 181
181 int DiskCacheTestWithCache::ReadData(disk_cache::Entry* entry, int index, 182 int DiskCacheTestWithCache::ReadData(disk_cache::Entry* entry,
182 int offset, net::IOBuffer* buf, int len) { 183 int index,
184 int offset,
185 net::IOBuffer* buf,
186 int len) {
183 net::TestCompletionCallback cb; 187 net::TestCompletionCallback cb;
184 int rv = entry->ReadData(index, offset, buf, len, cb.callback()); 188 int rv = entry->ReadData(index, offset, buf, len, cb.callback());
185 return cb.GetResult(rv); 189 return cb.GetResult(rv);
186 } 190 }
187 191
188 int DiskCacheTestWithCache::WriteData(disk_cache::Entry* entry, int index, 192 int DiskCacheTestWithCache::WriteData(disk_cache::Entry* entry,
189 int offset, net::IOBuffer* buf, int len, 193 int index,
194 int offset,
195 net::IOBuffer* buf,
196 int len,
190 bool truncate) { 197 bool truncate) {
191 net::TestCompletionCallback cb; 198 net::TestCompletionCallback cb;
192 int rv = entry->WriteData(index, offset, buf, len, cb.callback(), truncate); 199 int rv = entry->WriteData(index, offset, buf, len, cb.callback(), truncate);
193 return cb.GetResult(rv); 200 return cb.GetResult(rv);
194 } 201 }
195 202
196 int DiskCacheTestWithCache::ReadSparseData(disk_cache::Entry* entry, 203 int DiskCacheTestWithCache::ReadSparseData(disk_cache::Entry* entry,
197 int64 offset, net::IOBuffer* buf, 204 int64 offset,
205 net::IOBuffer* buf,
198 int len) { 206 int len) {
199 net::TestCompletionCallback cb; 207 net::TestCompletionCallback cb;
200 int rv = entry->ReadSparseData(offset, buf, len, cb.callback()); 208 int rv = entry->ReadSparseData(offset, buf, len, cb.callback());
201 return cb.GetResult(rv); 209 return cb.GetResult(rv);
202 } 210 }
203 211
204 int DiskCacheTestWithCache::WriteSparseData(disk_cache::Entry* entry, 212 int DiskCacheTestWithCache::WriteSparseData(disk_cache::Entry* entry,
205 int64 offset, 213 int64 offset,
206 net::IOBuffer* buf, int len) { 214 net::IOBuffer* buf,
215 int len) {
207 net::TestCompletionCallback cb; 216 net::TestCompletionCallback cb;
208 int rv = entry->WriteSparseData(offset, buf, len, cb.callback()); 217 int rv = entry->WriteSparseData(offset, buf, len, cb.callback());
209 return cb.GetResult(rv); 218 return cb.GetResult(rv);
210 } 219 }
211 220
212 void DiskCacheTestWithCache::TrimForTest(bool empty) { 221 void DiskCacheTestWithCache::TrimForTest(bool empty) {
213 RunTaskForTest(base::Bind(&disk_cache::BackendImpl::TrimForTest, 222 RunTaskForTest(base::Bind(&disk_cache::BackendImpl::TrimForTest,
214 base::Unretained(cache_impl_), 223 base::Unretained(cache_impl_),
215 empty)); 224 empty));
216 } 225 }
217 226
218 void DiskCacheTestWithCache::TrimDeletedListForTest(bool empty) { 227 void DiskCacheTestWithCache::TrimDeletedListForTest(bool empty) {
219 RunTaskForTest(base::Bind(&disk_cache::BackendImpl::TrimDeletedListForTest, 228 RunTaskForTest(base::Bind(&disk_cache::BackendImpl::TrimDeletedListForTest,
220 base::Unretained(cache_impl_), 229 base::Unretained(cache_impl_),
221 empty)); 230 empty));
222 } 231 }
223 232
224 void DiskCacheTestWithCache::AddDelay() { 233 void DiskCacheTestWithCache::AddDelay() {
225 if (simple_cache_mode_) { 234 if (simple_cache_mode_) {
226 // The simple cache uses second resolution for many timeouts, so it's safest 235 // The simple cache uses second resolution for many timeouts, so it's safest
227 // to advance by at least whole seconds before falling back into the normal 236 // to advance by at least whole seconds before falling back into the normal
228 // disk cache epsilon advance. 237 // disk cache epsilon advance.
229 const base::Time initial_time = base::Time::Now(); 238 const base::Time initial_time = base::Time::Now();
230 do { 239 do {
231 base::PlatformThread::YieldCurrentThread(); 240 base::PlatformThread::YieldCurrentThread();
232 } while (base::Time::Now() - 241 } while (base::Time::Now() - initial_time <
233 initial_time < base::TimeDelta::FromSeconds(1)); 242 base::TimeDelta::FromSeconds(1));
234 } 243 }
235 244
236 base::Time initial = base::Time::Now(); 245 base::Time initial = base::Time::Now();
237 while (base::Time::Now() <= initial) { 246 while (base::Time::Now() <= initial) {
238 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); 247 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
239 }; 248 };
240 } 249 }
241 250
242 void DiskCacheTestWithCache::TearDown() { 251 void DiskCacheTestWithCache::TearDown() {
243 base::RunLoop().RunUntilIdle(); 252 base::RunLoop().RunUntilIdle();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if (size_) 322 if (size_)
314 EXPECT_TRUE(cache_impl_->SetMaxSize(size_)); 323 EXPECT_TRUE(cache_impl_->SetMaxSize(size_));
315 if (new_eviction_) 324 if (new_eviction_)
316 cache_impl_->SetNewEviction(); 325 cache_impl_->SetNewEviction();
317 cache_impl_->SetType(type_); 326 cache_impl_->SetType(type_);
318 cache_impl_->SetFlags(flags); 327 cache_impl_->SetFlags(flags);
319 net::TestCompletionCallback cb; 328 net::TestCompletionCallback cb;
320 int rv = cache_impl_->Init(cb.callback()); 329 int rv = cache_impl_->Init(cb.callback());
321 ASSERT_EQ(net::OK, cb.GetResult(rv)); 330 ASSERT_EQ(net::OK, cb.GetResult(rv));
322 } 331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698