| Index: net/disk_cache/cache_creator.cc
|
| diff --git a/net/disk_cache/cache_creator.cc b/net/disk_cache/cache_creator.cc
|
| index 8384f82fd1eccc6910b6ec79c986689de90e9a9b..07a26c9d8581235f19835d121bc4e6bc39be8cd8 100644
|
| --- a/net/disk_cache/cache_creator.cc
|
| +++ b/net/disk_cache/cache_creator.cc
|
| @@ -9,6 +9,7 @@
|
| #include "net/base/net_errors.h"
|
| #include "net/disk_cache/backend_impl.h"
|
| #include "net/disk_cache/cache_util.h"
|
| +#include "net/disk_cache/disk_cache.h"
|
| #include "net/disk_cache/mem_backend_impl.h"
|
| #include "net/disk_cache/simple/simple_backend_impl.h"
|
|
|
| @@ -26,7 +27,7 @@ class CacheCreator {
|
| CacheCreator(const base::FilePath& path, bool force, int max_bytes,
|
| net::CacheType type, net::BackendType backend_type, uint32 flags,
|
| base::MessageLoopProxy* thread, net::NetLog* net_log,
|
| - disk_cache::Backend** backend,
|
| + scoped_ptr<disk_cache::Backend>* backend,
|
| const net::CompletionCallback& callback);
|
|
|
| // Creates the backend.
|
| @@ -47,9 +48,9 @@ class CacheCreator {
|
| net::BackendType backend_type_;
|
| uint32 flags_;
|
| scoped_refptr<base::MessageLoopProxy> thread_;
|
| - disk_cache::Backend** backend_;
|
| + scoped_ptr<disk_cache::Backend>* backend_;
|
| net::CompletionCallback callback_;
|
| - disk_cache::Backend* created_cache_;
|
| + scoped_ptr<disk_cache::Backend> created_cache_;
|
| net::NetLog* net_log_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(CacheCreator);
|
| @@ -59,7 +60,7 @@ CacheCreator::CacheCreator(
|
| const base::FilePath& path, bool force, int max_bytes,
|
| net::CacheType type, net::BackendType backend_type, uint32 flags,
|
| base::MessageLoopProxy* thread, net::NetLog* net_log,
|
| - disk_cache::Backend** backend,
|
| + scoped_ptr<disk_cache::Backend>* backend,
|
| const net::CompletionCallback& callback)
|
| : path_(path),
|
| force_(force),
|
| @@ -71,7 +72,6 @@ CacheCreator::CacheCreator(
|
| thread_(thread),
|
| backend_(backend),
|
| callback_(callback),
|
| - created_cache_(NULL),
|
| net_log_(net_log) {
|
| }
|
|
|
| @@ -86,13 +86,13 @@ int CacheCreator::Run() {
|
| disk_cache::SimpleBackendImpl* simple_cache =
|
| new disk_cache::SimpleBackendImpl(path_, max_bytes_, type_,
|
| thread_.get(), net_log_);
|
| - created_cache_ = simple_cache;
|
| + created_cache_.reset(simple_cache);
|
| return simple_cache->Init(
|
| base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this)));
|
| }
|
| disk_cache::BackendImpl* new_cache =
|
| new disk_cache::BackendImpl(path_, thread_.get(), net_log_);
|
| - created_cache_ = new_cache;
|
| + created_cache_.reset(new_cache);
|
| new_cache->SetMaxSize(max_bytes_);
|
| new_cache->SetType(type_);
|
| new_cache->SetFlags(flags_);
|
| @@ -106,14 +106,13 @@ void CacheCreator::DoCallback(int result) {
|
| DCHECK_NE(net::ERR_IO_PENDING, result);
|
| if (result == net::OK) {
|
| #ifndef USE_TRACING_CACHE_BACKEND
|
| - *backend_ = created_cache_;
|
| + *backend_ = created_cache_.Pass();
|
| #else
|
| - *backend_ = new disk_cache::TracingCacheBackend(created_cache_);
|
| + *backend_.reset(
|
| + new disk_cache::TracingCacheBackend(created_cache_.Pass()));
|
| #endif
|
| } else {
|
| LOG(ERROR) << "Unable to create cache";
|
| - *backend_ = NULL;
|
| - delete created_cache_;
|
| }
|
| callback_.Run(result);
|
| delete this;
|
| @@ -128,8 +127,7 @@ void CacheCreator::OnIOComplete(int result) {
|
| // This is a failure and we are supposed to try again, so delete the object,
|
| // delete all the files, and try again.
|
| retry_ = true;
|
| - delete created_cache_;
|
| - created_cache_ = NULL;
|
| + created_cache_.reset();
|
| if (!disk_cache::DelayedCacheCleanup(path_))
|
| return DoCallback(result);
|
|
|
| @@ -148,7 +146,7 @@ int CreateCacheBackend(net::CacheType type,
|
| const base::FilePath& path,
|
| int max_bytes,
|
| bool force, base::MessageLoopProxy* thread,
|
| - net::NetLog* net_log, Backend** backend,
|
| + net::NetLog* net_log, scoped_ptr<Backend>* backend,
|
| const net::CompletionCallback& callback) {
|
| DCHECK(!callback.is_null());
|
| if (type == net::MEMORY_CACHE) {
|
|
|