Commit cb042b64 authored by Anna Malova's avatar Anna Malova Committed by Commit Bot

Convert DiskCacheTest to use OnceCallback.

Bug: 1007815
Change-Id: I09fad24dfee175d0456e12333b063ac57b2c0193
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083543Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Commit-Queue: Anna Malova <amalova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746374}
parent 5208094b
......@@ -248,14 +248,14 @@ void DiskCacheTestWithCache::FlushQueueForTest() {
EXPECT_THAT(cb.GetResult(rv), IsOk());
}
void DiskCacheTestWithCache::RunTaskForTest(const base::Closure& closure) {
void DiskCacheTestWithCache::RunTaskForTest(base::OnceClosure closure) {
if (memory_only_ || !cache_impl_) {
closure.Run();
std::move(closure).Run();
return;
}
net::TestCompletionCallback cb;
int rv = cache_impl_->RunTaskForTest(closure, cb.callback());
int rv = cache_impl_->RunTaskForTest(std::move(closure), cb.callback());
EXPECT_THAT(cb.GetResult(rv), IsOk());
}
......@@ -311,16 +311,17 @@ void DiskCacheTestWithCache::TrimForTest(bool empty) {
if (memory_only_ || !cache_impl_)
return;
RunTaskForTest(base::Bind(&disk_cache::BackendImpl::TrimForTest,
base::Unretained(cache_impl_), empty));
RunTaskForTest(base::BindOnce(&disk_cache::BackendImpl::TrimForTest,
base::Unretained(cache_impl_), empty));
}
void DiskCacheTestWithCache::TrimDeletedListForTest(bool empty) {
if (memory_only_ || !cache_impl_)
return;
RunTaskForTest(base::Bind(&disk_cache::BackendImpl::TrimDeletedListForTest,
base::Unretained(cache_impl_), empty));
RunTaskForTest(
base::BindOnce(&disk_cache::BackendImpl::TrimDeletedListForTest,
base::Unretained(cache_impl_), empty));
}
void DiskCacheTestWithCache::AddDelay() {
......
......@@ -155,7 +155,7 @@ class DiskCacheTestWithCache : public DiskCacheTest {
int DoomEntriesSince(const base::Time initial_time);
std::unique_ptr<TestIterator> CreateIterator();
void FlushQueueForTest();
void RunTaskForTest(const base::Closure& closure);
void RunTaskForTest(base::OnceClosure closure);
int ReadData(disk_cache::Entry* entry, int index, int offset,
net::IOBuffer* buf, int len);
int WriteData(disk_cache::Entry* entry, int index, int offset,
......
......@@ -164,10 +164,8 @@ void DiskCacheEntryTest::InternalSyncIO() {
ASSERT_TRUE(nullptr != entry);
// The bulk of the test runs from within the callback, on the cache thread.
RunTaskForTest(base::Bind(&DiskCacheEntryTest::InternalSyncIOBackground,
base::Unretained(this),
entry));
RunTaskForTest(base::BindOnce(&DiskCacheEntryTest::InternalSyncIOBackground,
base::Unretained(this), entry));
entry->Doom();
entry->Close();
......@@ -400,9 +398,8 @@ void DiskCacheEntryTest::ExternalSyncIO() {
ASSERT_THAT(CreateEntry("the first key", &entry), IsOk());
// The bulk of the test runs from within the callback, on the cache thread.
RunTaskForTest(base::Bind(&DiskCacheEntryTest::ExternalSyncIOBackground,
base::Unretained(this),
entry));
RunTaskForTest(base::BindOnce(&DiskCacheEntryTest::ExternalSyncIOBackground,
base::Unretained(this), entry));
entry->Doom();
entry->Close();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment