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

Unified Diff: net/disk_cache/disk_cache_test_base.cc

Issue 2945002: Disk cache: Switch the disk cache to use the cache_thread.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/disk_cache_test_base.h ('k') | net/disk_cache/entry_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/disk_cache_test_base.cc
===================================================================
--- net/disk_cache/disk_cache_test_base.cc (revision 51874)
+++ net/disk_cache/disk_cache_test_base.cc (working copy)
@@ -4,6 +4,7 @@
#include "net/disk_cache/disk_cache_test_base.h"
+#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "net/disk_cache/backend_impl.h"
#include "net/disk_cache/disk_cache_test_util.h"
@@ -66,21 +67,25 @@
if (implementation_)
return InitDiskCacheImpl(path);
+ scoped_refptr<base::MessageLoopProxy> thread =
+ use_current_thread_ ? base::MessageLoopProxy::CreateForCurrentThread() :
+ cache_thread_.message_loop_proxy();
+
TestCompletionCallback cb;
int rv = disk_cache::BackendImpl::CreateBackend(
path, force_creation_, size_, net::DISK_CACHE,
- disk_cache::kNoRandom, cache_thread_.message_loop_proxy(),
- &cache_, &cb);
+ disk_cache::kNoRandom, thread, &cache_, &cb);
ASSERT_EQ(net::OK, cb.GetResult(rv));
}
void DiskCacheTestWithCache::InitDiskCacheImpl(const FilePath& path) {
+ scoped_refptr<base::MessageLoopProxy> thread =
+ use_current_thread_ ? base::MessageLoopProxy::CreateForCurrentThread() :
+ cache_thread_.message_loop_proxy();
if (mask_)
- cache_impl_ = new disk_cache::BackendImpl(
- path, mask_, cache_thread_.message_loop_proxy());
+ cache_impl_ = new disk_cache::BackendImpl(path, mask_, thread);
else
- cache_impl_ = new disk_cache::BackendImpl(
- path, cache_thread_.message_loop_proxy());
+ cache_impl_ = new disk_cache::BackendImpl(path, thread);
cache_ = cache_impl_;
ASSERT_TRUE(NULL != cache_);
@@ -92,7 +97,9 @@
cache_impl_->SetNewEviction();
cache_impl_->SetFlags(disk_cache::kNoRandom);
- ASSERT_TRUE(cache_impl_->Init());
+ TestCompletionCallback cb;
+ int rv = cache_impl_->Init(&cb);
+ ASSERT_EQ(net::OK, cb.GetResult(rv));
}
void DiskCacheTestWithCache::TearDown() {
@@ -112,6 +119,9 @@
// We are expected to leak memory when simulating crashes.
void DiskCacheTestWithCache::SimulateCrash() {
ASSERT_TRUE(implementation_ && !memory_only_);
+ TestCompletionCallback cb;
+ int rv = cache_impl_->FlushQueueForTest(&cb);
+ ASSERT_EQ(net::OK, cb.GetResult(rv));
cache_impl_->ClearRefCountForTest();
delete cache_impl_;
@@ -171,3 +181,12 @@
int rv = cache_->OpenNextEntry(iter, next_entry, &cb);
return cb.GetResult(rv);
}
+
+void DiskCacheTestWithCache::FlushQueueForTest() {
+ if (memory_only_ || !cache_impl_)
+ return;
+
+ TestCompletionCallback cb;
+ int rv = cache_impl_->FlushQueueForTest(&cb);
+ EXPECT_EQ(net::OK, cb.GetResult(rv));
+}
« no previous file with comments | « net/disk_cache/disk_cache_test_base.h ('k') | net/disk_cache/entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698