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/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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 if (!cache_thread_.IsRunning()) { | 243 if (!cache_thread_.IsRunning()) { |
244 EXPECT_TRUE(cache_thread_.StartWithOptions( | 244 EXPECT_TRUE(cache_thread_.StartWithOptions( |
245 base::Thread::Options(MessageLoop::TYPE_IO, 0))); | 245 base::Thread::Options(MessageLoop::TYPE_IO, 0))); |
246 } | 246 } |
247 ASSERT_TRUE(cache_thread_.message_loop() != NULL); | 247 ASSERT_TRUE(cache_thread_.message_loop() != NULL); |
248 | 248 |
249 if (implementation_) | 249 if (implementation_) |
250 return InitDiskCacheImpl(path); | 250 return InitDiskCacheImpl(path); |
251 | 251 |
252 scoped_refptr<base::MessageLoopProxy> thread = | 252 scoped_refptr<base::MessageLoopProxy> thread = |
253 use_current_thread_ ? base::MessageLoopProxy::CreateForCurrentThread() : | 253 use_current_thread_ ? base::MessageLoopProxy::current() : |
254 cache_thread_.message_loop_proxy(); | 254 cache_thread_.message_loop_proxy(); |
255 | 255 |
256 TestCompletionCallback cb; | 256 TestCompletionCallback cb; |
257 int rv = disk_cache::BackendImpl::CreateBackend( | 257 int rv = disk_cache::BackendImpl::CreateBackend( |
258 path, force_creation_, size_, type_, | 258 path, force_creation_, size_, type_, |
259 disk_cache::kNoRandom, thread, NULL, &cache_, &cb); | 259 disk_cache::kNoRandom, thread, NULL, &cache_, &cb); |
260 ASSERT_EQ(net::OK, cb.GetResult(rv)); | 260 ASSERT_EQ(net::OK, cb.GetResult(rv)); |
261 } | 261 } |
262 | 262 |
263 void DiskCacheTestWithCache::InitDiskCacheImpl(const FilePath& path) { | 263 void DiskCacheTestWithCache::InitDiskCacheImpl(const FilePath& path) { |
264 scoped_refptr<base::MessageLoopProxy> thread = | 264 scoped_refptr<base::MessageLoopProxy> thread = |
265 use_current_thread_ ? base::MessageLoopProxy::CreateForCurrentThread() : | 265 use_current_thread_ ? base::MessageLoopProxy::current() : |
266 cache_thread_.message_loop_proxy(); | 266 cache_thread_.message_loop_proxy(); |
267 if (mask_) | 267 if (mask_) |
268 cache_impl_ = new disk_cache::BackendImpl(path, mask_, thread, NULL); | 268 cache_impl_ = new disk_cache::BackendImpl(path, mask_, thread, NULL); |
269 else | 269 else |
270 cache_impl_ = new disk_cache::BackendImpl(path, thread, NULL); | 270 cache_impl_ = new disk_cache::BackendImpl(path, thread, NULL); |
271 | 271 |
272 cache_ = cache_impl_; | 272 cache_ = cache_impl_; |
273 ASSERT_TRUE(NULL != cache_); | 273 ASSERT_TRUE(NULL != cache_); |
274 | 274 |
275 if (size_) | 275 if (size_) |
276 EXPECT_TRUE(cache_impl_->SetMaxSize(size_)); | 276 EXPECT_TRUE(cache_impl_->SetMaxSize(size_)); |
277 | 277 |
278 if (new_eviction_) | 278 if (new_eviction_) |
279 cache_impl_->SetNewEviction(); | 279 cache_impl_->SetNewEviction(); |
280 | 280 |
281 cache_impl_->SetType(type_); | 281 cache_impl_->SetType(type_); |
282 cache_impl_->SetFlags(disk_cache::kNoRandom); | 282 cache_impl_->SetFlags(disk_cache::kNoRandom); |
283 TestCompletionCallback cb; | 283 TestCompletionCallback cb; |
284 int rv = cache_impl_->Init(&cb); | 284 int rv = cache_impl_->Init(&cb); |
285 ASSERT_EQ(net::OK, cb.GetResult(rv)); | 285 ASSERT_EQ(net::OK, cb.GetResult(rv)); |
286 } | 286 } |
OLD | NEW |