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

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

Issue 1894733002: Change scoped_ptr to std::unique_ptr in //net/disk_cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « net/disk_cache/disk_cache_test_base.h ('k') | net/disk_cache/disk_cache_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 7 #include <utility>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 bool DiskCacheTest::CleanupCacheDir() { 49 bool DiskCacheTest::CleanupCacheDir() {
50 return DeleteCache(cache_path_); 50 return DeleteCache(cache_path_);
51 } 51 }
52 52
53 void DiskCacheTest::TearDown() { 53 void DiskCacheTest::TearDown() {
54 base::RunLoop().RunUntilIdle(); 54 base::RunLoop().RunUntilIdle();
55 } 55 }
56 56
57 DiskCacheTestWithCache::TestIterator::TestIterator( 57 DiskCacheTestWithCache::TestIterator::TestIterator(
58 scoped_ptr<disk_cache::Backend::Iterator> iterator) 58 std::unique_ptr<disk_cache::Backend::Iterator> iterator)
59 : iterator_(std::move(iterator)) {} 59 : iterator_(std::move(iterator)) {}
60 60
61 DiskCacheTestWithCache::TestIterator::~TestIterator() {} 61 DiskCacheTestWithCache::TestIterator::~TestIterator() {}
62 62
63 int DiskCacheTestWithCache::TestIterator::OpenNextEntry( 63 int DiskCacheTestWithCache::TestIterator::OpenNextEntry(
64 disk_cache::Entry** next_entry) { 64 disk_cache::Entry** next_entry) {
65 net::TestCompletionCallback cb; 65 net::TestCompletionCallback cb;
66 int rv = iterator_->OpenNextEntry(next_entry, cb.callback()); 66 int rv = iterator_->OpenNextEntry(next_entry, cb.callback());
67 return cb.GetResult(rv); 67 return cb.GetResult(rv);
68 } 68 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 int rv = cache_->DoomEntriesSince(initial_time, cb.callback()); 167 int rv = cache_->DoomEntriesSince(initial_time, cb.callback());
168 return cb.GetResult(rv); 168 return cb.GetResult(rv);
169 } 169 }
170 170
171 int DiskCacheTestWithCache::CalculateSizeOfAllEntries() { 171 int DiskCacheTestWithCache::CalculateSizeOfAllEntries() {
172 net::TestCompletionCallback cb; 172 net::TestCompletionCallback cb;
173 int rv = cache_->CalculateSizeOfAllEntries(cb.callback()); 173 int rv = cache_->CalculateSizeOfAllEntries(cb.callback());
174 return cb.GetResult(rv); 174 return cb.GetResult(rv);
175 } 175 }
176 176
177 scoped_ptr<DiskCacheTestWithCache::TestIterator> 177 std::unique_ptr<DiskCacheTestWithCache::TestIterator>
178 DiskCacheTestWithCache::CreateIterator() { 178 DiskCacheTestWithCache::CreateIterator() {
179 return scoped_ptr<TestIterator>(new TestIterator(cache_->CreateIterator())); 179 return std::unique_ptr<TestIterator>(
180 new TestIterator(cache_->CreateIterator()));
180 } 181 }
181 182
182 void DiskCacheTestWithCache::FlushQueueForTest() { 183 void DiskCacheTestWithCache::FlushQueueForTest() {
183 if (memory_only_ || !cache_impl_) 184 if (memory_only_ || !cache_impl_)
184 return; 185 return;
185 186
186 net::TestCompletionCallback cb; 187 net::TestCompletionCallback cb;
187 int rv = cache_impl_->FlushQueueForTest(cb.callback()); 188 int rv = cache_impl_->FlushQueueForTest(cb.callback());
188 EXPECT_EQ(net::OK, cb.GetResult(rv)); 189 EXPECT_EQ(net::OK, cb.GetResult(rv));
189 } 190 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 void DiskCacheTestWithCache::CreateBackend(uint32_t flags, 306 void DiskCacheTestWithCache::CreateBackend(uint32_t flags,
306 base::Thread* thread) { 307 base::Thread* thread) {
307 scoped_refptr<base::SingleThreadTaskRunner> runner; 308 scoped_refptr<base::SingleThreadTaskRunner> runner;
308 if (use_current_thread_) 309 if (use_current_thread_)
309 runner = base::ThreadTaskRunnerHandle::Get(); 310 runner = base::ThreadTaskRunnerHandle::Get();
310 else 311 else
311 runner = thread->task_runner(); 312 runner = thread->task_runner();
312 313
313 if (simple_cache_mode_) { 314 if (simple_cache_mode_) {
314 net::TestCompletionCallback cb; 315 net::TestCompletionCallback cb;
315 scoped_ptr<disk_cache::SimpleBackendImpl> simple_backend( 316 std::unique_ptr<disk_cache::SimpleBackendImpl> simple_backend(
316 new disk_cache::SimpleBackendImpl( 317 new disk_cache::SimpleBackendImpl(cache_path_, size_, type_, runner,
317 cache_path_, size_, type_, runner, NULL)); 318 NULL));
318 int rv = simple_backend->Init(cb.callback()); 319 int rv = simple_backend->Init(cb.callback());
319 ASSERT_EQ(net::OK, cb.GetResult(rv)); 320 ASSERT_EQ(net::OK, cb.GetResult(rv));
320 simple_cache_impl_ = simple_backend.get(); 321 simple_cache_impl_ = simple_backend.get();
321 cache_ = std::move(simple_backend); 322 cache_ = std::move(simple_backend);
322 if (simple_cache_wait_for_index_) { 323 if (simple_cache_wait_for_index_) {
323 net::TestCompletionCallback wait_for_index_cb; 324 net::TestCompletionCallback wait_for_index_cb;
324 rv = simple_cache_impl_->index()->ExecuteWhenReady( 325 rv = simple_cache_impl_->index()->ExecuteWhenReady(
325 wait_for_index_cb.callback()); 326 wait_for_index_cb.callback());
326 ASSERT_EQ(net::OK, wait_for_index_cb.GetResult(rv)); 327 ASSERT_EQ(net::OK, wait_for_index_cb.GetResult(rv));
327 } 328 }
328 return; 329 return;
329 } 330 }
330 331
331 if (mask_) 332 if (mask_)
332 cache_impl_ = new disk_cache::BackendImpl(cache_path_, mask_, runner, NULL); 333 cache_impl_ = new disk_cache::BackendImpl(cache_path_, mask_, runner, NULL);
333 else 334 else
334 cache_impl_ = new disk_cache::BackendImpl(cache_path_, runner, NULL); 335 cache_impl_ = new disk_cache::BackendImpl(cache_path_, runner, NULL);
335 cache_.reset(cache_impl_); 336 cache_.reset(cache_impl_);
336 ASSERT_TRUE(cache_); 337 ASSERT_TRUE(cache_);
337 if (size_) 338 if (size_)
338 EXPECT_TRUE(cache_impl_->SetMaxSize(size_)); 339 EXPECT_TRUE(cache_impl_->SetMaxSize(size_));
339 if (new_eviction_) 340 if (new_eviction_)
340 cache_impl_->SetNewEviction(); 341 cache_impl_->SetNewEviction();
341 cache_impl_->SetType(type_); 342 cache_impl_->SetType(type_);
342 cache_impl_->SetFlags(flags); 343 cache_impl_->SetFlags(flags);
343 net::TestCompletionCallback cb; 344 net::TestCompletionCallback cb;
344 int rv = cache_impl_->Init(cb.callback()); 345 int rv = cache_impl_->Init(cb.callback());
345 ASSERT_EQ(net::OK, cb.GetResult(rv)); 346 ASSERT_EQ(net::OK, cb.GetResult(rv));
346 } 347 }
OLDNEW
« no previous file with comments | « net/disk_cache/disk_cache_test_base.h ('k') | net/disk_cache/disk_cache_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698