OLD | NEW |
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 <utility> |
| 8 |
7 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
8 #include "base/path_service.h" | 10 #include "base/path_service.h" |
9 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
10 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
11 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
12 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
13 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
14 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
15 #include "net/base/test_completion_callback.h" | 17 #include "net/base/test_completion_callback.h" |
16 #include "net/disk_cache/blockfile/backend_impl.h" | 18 #include "net/disk_cache/blockfile/backend_impl.h" |
(...skipping 30 matching lines...) Expand all Loading... |
47 bool DiskCacheTest::CleanupCacheDir() { | 49 bool DiskCacheTest::CleanupCacheDir() { |
48 return DeleteCache(cache_path_); | 50 return DeleteCache(cache_path_); |
49 } | 51 } |
50 | 52 |
51 void DiskCacheTest::TearDown() { | 53 void DiskCacheTest::TearDown() { |
52 base::RunLoop().RunUntilIdle(); | 54 base::RunLoop().RunUntilIdle(); |
53 } | 55 } |
54 | 56 |
55 DiskCacheTestWithCache::TestIterator::TestIterator( | 57 DiskCacheTestWithCache::TestIterator::TestIterator( |
56 scoped_ptr<disk_cache::Backend::Iterator> iterator) | 58 scoped_ptr<disk_cache::Backend::Iterator> iterator) |
57 : iterator_(iterator.Pass()) { | 59 : iterator_(std::move(iterator)) {} |
58 } | |
59 | 60 |
60 DiskCacheTestWithCache::TestIterator::~TestIterator() {} | 61 DiskCacheTestWithCache::TestIterator::~TestIterator() {} |
61 | 62 |
62 int DiskCacheTestWithCache::TestIterator::OpenNextEntry( | 63 int DiskCacheTestWithCache::TestIterator::OpenNextEntry( |
63 disk_cache::Entry** next_entry) { | 64 disk_cache::Entry** next_entry) { |
64 net::TestCompletionCallback cb; | 65 net::TestCompletionCallback cb; |
65 int rv = iterator_->OpenNextEntry(next_entry, cb.callback()); | 66 int rv = iterator_->OpenNextEntry(next_entry, cb.callback()); |
66 return cb.GetResult(rv); | 67 return cb.GetResult(rv); |
67 } | 68 } |
68 | 69 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 runner = thread->task_runner(); | 311 runner = thread->task_runner(); |
311 | 312 |
312 if (simple_cache_mode_) { | 313 if (simple_cache_mode_) { |
313 net::TestCompletionCallback cb; | 314 net::TestCompletionCallback cb; |
314 scoped_ptr<disk_cache::SimpleBackendImpl> simple_backend( | 315 scoped_ptr<disk_cache::SimpleBackendImpl> simple_backend( |
315 new disk_cache::SimpleBackendImpl( | 316 new disk_cache::SimpleBackendImpl( |
316 cache_path_, size_, type_, runner, NULL)); | 317 cache_path_, size_, type_, runner, NULL)); |
317 int rv = simple_backend->Init(cb.callback()); | 318 int rv = simple_backend->Init(cb.callback()); |
318 ASSERT_EQ(net::OK, cb.GetResult(rv)); | 319 ASSERT_EQ(net::OK, cb.GetResult(rv)); |
319 simple_cache_impl_ = simple_backend.get(); | 320 simple_cache_impl_ = simple_backend.get(); |
320 cache_ = simple_backend.Pass(); | 321 cache_ = std::move(simple_backend); |
321 if (simple_cache_wait_for_index_) { | 322 if (simple_cache_wait_for_index_) { |
322 net::TestCompletionCallback wait_for_index_cb; | 323 net::TestCompletionCallback wait_for_index_cb; |
323 rv = simple_cache_impl_->index()->ExecuteWhenReady( | 324 rv = simple_cache_impl_->index()->ExecuteWhenReady( |
324 wait_for_index_cb.callback()); | 325 wait_for_index_cb.callback()); |
325 ASSERT_EQ(net::OK, wait_for_index_cb.GetResult(rv)); | 326 ASSERT_EQ(net::OK, wait_for_index_cb.GetResult(rv)); |
326 } | 327 } |
327 return; | 328 return; |
328 } | 329 } |
329 | 330 |
330 if (mask_) | 331 if (mask_) |
331 cache_impl_ = new disk_cache::BackendImpl(cache_path_, mask_, runner, NULL); | 332 cache_impl_ = new disk_cache::BackendImpl(cache_path_, mask_, runner, NULL); |
332 else | 333 else |
333 cache_impl_ = new disk_cache::BackendImpl(cache_path_, runner, NULL); | 334 cache_impl_ = new disk_cache::BackendImpl(cache_path_, runner, NULL); |
334 cache_.reset(cache_impl_); | 335 cache_.reset(cache_impl_); |
335 ASSERT_TRUE(cache_); | 336 ASSERT_TRUE(cache_); |
336 if (size_) | 337 if (size_) |
337 EXPECT_TRUE(cache_impl_->SetMaxSize(size_)); | 338 EXPECT_TRUE(cache_impl_->SetMaxSize(size_)); |
338 if (new_eviction_) | 339 if (new_eviction_) |
339 cache_impl_->SetNewEviction(); | 340 cache_impl_->SetNewEviction(); |
340 cache_impl_->SetType(type_); | 341 cache_impl_->SetType(type_); |
341 cache_impl_->SetFlags(flags); | 342 cache_impl_->SetFlags(flags); |
342 net::TestCompletionCallback cb; | 343 net::TestCompletionCallback cb; |
343 int rv = cache_impl_->Init(cb.callback()); | 344 int rv = cache_impl_->Init(cb.callback()); |
344 ASSERT_EQ(net::OK, cb.GetResult(rv)); | 345 ASSERT_EQ(net::OK, cb.GetResult(rv)); |
345 } | 346 } |
OLD | NEW |