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

Unified Diff: net/disk_cache/cache_creator.cc

Issue 13813015: Separate Simple Backend creation from initialization. (Closed) Base URL: http://git.chromium.org/chromium/src.git@trace-2
Patch Set: updated the simple backend initialization according to the new interface in tests Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/disk_cache/disk_cache_test_base.cc » ('j') | net/disk_cache/simple/simple_backend_impl.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/cache_creator.cc
diff --git a/net/disk_cache/cache_creator.cc b/net/disk_cache/cache_creator.cc
index d8344a9a65b4dac976161aeb470d3bdd58329be2..9a3a924a7f5a29bde5796597337141310145c061 100644
--- a/net/disk_cache/cache_creator.cc
+++ b/net/disk_cache/cache_creator.cc
@@ -45,7 +45,6 @@ class CacheCreator {
net::CompletionCallback callback_;
disk_cache::Backend* created_cache_;
net::NetLog* net_log_;
- bool use_simple_cache_backend_;
DISALLOW_COPY_AND_ASSIGN(CacheCreator);
};
@@ -66,8 +65,7 @@ CacheCreator::CacheCreator(
backend_(backend),
callback_(callback),
created_cache_(NULL),
- net_log_(net_log),
- use_simple_cache_backend_(false) {
+ net_log_(net_log) {
}
CacheCreator::~CacheCreator() {
@@ -82,12 +80,12 @@ int CacheCreator::Run() {
// testing it against net::DISK_CACHE. Turn it on for more cache types as
// appropriate.
if (type_ == net::DISK_CACHE) {
- VLOG(1) << "Using the Simple Cache Backend.";
- use_simple_cache_backend_ = true;
- return disk_cache::SimpleBackendImpl::CreateBackend(
- path_, max_bytes_, type_, disk_cache::kNone, thread_, net_log_,
- backend_, base::Bind(&CacheCreator::OnIOComplete,
- base::Unretained(this)));
+ disk_cache::SimpleBackendImpl* simple_cache =
+ new disk_cache::SimpleBackendImpl(path_, max_bytes_, type_, thread_,
+ net_log_);
+ created_cache_ = simple_cache;
+ return simple_cache->Init(
+ base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this)));
}
}
disk_cache::BackendImpl* new_cache =
@@ -104,14 +102,9 @@ int CacheCreator::Run() {
void CacheCreator::DoCallback(int result) {
DCHECK_NE(net::ERR_IO_PENDING, result);
- if (result == net::OK) {
- // TODO(pasko): Separate creation of the Simple Backend from its
- // initialization, eliminate unnecessary use_simple_cache_backend_.
- if (use_simple_cache_backend_)
- created_cache_ = *backend_;
- else
- *backend_ = created_cache_;
- } else {
+ if (result == net::OK)
+ *backend_ = created_cache_;
+ else {
LOG(ERROR) << "Unable to create cache";
*backend_ = NULL;
delete created_cache_;
@@ -160,5 +153,4 @@ int CreateCacheBackend(net::CacheType type, const base::FilePath& path,
return creator->Run();
}
-
} // namespace disk_cache
« no previous file with comments | « no previous file | net/disk_cache/disk_cache_test_base.cc » ('j') | net/disk_cache/simple/simple_backend_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698