summaryrefslogtreecommitdiffstats
path: root/net/tools/dump_cache
diff options
context:
space:
mode:
authorqsr@chromium.org <qsr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-01 11:57:53 +0000
committerqsr@chromium.org <qsr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-01 11:57:53 +0000
commit8c3f5a3423c155d0a90048fb04c7da0df0f81540 (patch)
tree83e7c29a104bcb6a60ee589a0f8fbecdc20fd8e0 /net/tools/dump_cache
parent335f57f55c9b7862499152638c2b3085cd4ca19d (diff)
downloadchromium_src-8c3f5a3423c155d0a90048fb04c7da0df0f81540.zip
chromium_src-8c3f5a3423c155d0a90048fb04c7da0df0f81540.tar.gz
chromium_src-8c3f5a3423c155d0a90048fb04c7da0df0f81540.tar.bz2
Change the API of disk_cache::CreateCacheBackend to use scoped_ptr
Using scoped_ptr instead of pointer allows the API to show the transfert of ownership and ensure that the caller will holds it. R=rvargas@chromium.org TBR=bradchen@chromium.org,apatrick@chromium.org,darin@chromium.org Review URL: https://chromiumcodereview.appspot.com/20737002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215008 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools/dump_cache')
-rw-r--r--net/tools/dump_cache/simple_cache_dumper.cc9
-rw-r--r--net/tools/dump_cache/simple_cache_dumper.h2
-rw-r--r--net/tools/dump_cache/upgrade_win.cc8
3 files changed, 8 insertions, 11 deletions
diff --git a/net/tools/dump_cache/simple_cache_dumper.cc b/net/tools/dump_cache/simple_cache_dumper.cc
index dd7c18d..56162ca 100644
--- a/net/tools/dump_cache/simple_cache_dumper.cc
+++ b/net/tools/dump_cache/simple_cache_dumper.cc
@@ -24,7 +24,6 @@ SimpleCacheDumper::SimpleCacheDumper(base::FilePath input_path,
: state_(STATE_NONE),
input_path_(input_path),
output_path_(output_path),
- cache_(NULL),
writer_(new DiskDumper(output_path)),
cache_thread_(new base::Thread("CacheThead")),
iter_(NULL),
@@ -36,7 +35,6 @@ SimpleCacheDumper::SimpleCacheDumper(base::FilePath input_path,
}
SimpleCacheDumper::~SimpleCacheDumper() {
- delete(cache_);
}
int SimpleCacheDumper::Run() {
@@ -140,8 +138,8 @@ int SimpleCacheDumper::DoCreateCacheComplete(int rv) {
if (rv < 0)
return rv;
- reinterpret_cast<disk_cache::BackendImpl*>(cache_)->SetUpgradeMode();
- reinterpret_cast<disk_cache::BackendImpl*>(cache_)->SetFlags(
+ reinterpret_cast<disk_cache::BackendImpl*>(cache_.get())->SetUpgradeMode();
+ reinterpret_cast<disk_cache::BackendImpl*>(cache_.get())->SetFlags(
disk_cache::kNoRandom);
state_ = STATE_OPEN_ENTRY;
@@ -267,8 +265,7 @@ void SimpleCacheDumper::OnIOComplete(int rv) {
if (rv != ERR_IO_PENDING) {
rv_ = rv;
- delete cache_;
- cache_ = NULL;
+ cache_.reset();
base::MessageLoop::current()->Quit();
}
}
diff --git a/net/tools/dump_cache/simple_cache_dumper.h b/net/tools/dump_cache/simple_cache_dumper.h
index 33b6d76..c95e6a9 100644
--- a/net/tools/dump_cache/simple_cache_dumper.h
+++ b/net/tools/dump_cache/simple_cache_dumper.h
@@ -76,7 +76,7 @@ class SimpleCacheDumper {
State state_;
base::FilePath input_path_;
base::FilePath output_path_;
- disk_cache::Backend* cache_;
+ scoped_ptr<disk_cache::Backend> cache_;
scoped_ptr<DiskDumper> writer_;
base::Thread* cache_thread_;
void* iter_;
diff --git a/net/tools/dump_cache/upgrade_win.cc b/net/tools/dump_cache/upgrade_win.cc
index 6c7def9..5135592 100644
--- a/net/tools/dump_cache/upgrade_win.cc
+++ b/net/tools/dump_cache/upgrade_win.cc
@@ -319,7 +319,7 @@ bool MasterSM::DoInit() {
DEBUGMSG("Master DoInit\n");
DCHECK(state_ == MASTER_INITIAL);
- disk_cache::Backend* cache;
+ scoped_ptr<disk_cache::Backend> cache;
net::TestCompletionCallback cb;
int rv = disk_cache::CreateCacheBackend(net::DISK_CACHE,
net::CACHE_BACKEND_DEFAULT, path_, 0,
@@ -330,7 +330,7 @@ bool MasterSM::DoInit() {
printf("Unable to initialize new files\n");
return false;
}
- cache_.reset(cache);
+ cache_ = cache.Pass();
writer_ = new CacheDumper(cache_.get());
copied_entries_ = 0;
@@ -594,7 +594,7 @@ class SlaveSM : public BaseSM {
SlaveSM::SlaveSM(const base::FilePath& path, HANDLE channel)
: BaseSM(channel), iterator_(NULL) {
- disk_cache::Backend* cache;
+ scoped_ptr<disk_cache::Backend> cache;
net::TestCompletionCallback cb;
int rv = disk_cache::CreateCacheBackend(net::DISK_CACHE,
net::CACHE_BACKEND_BLOCKFILE, path, 0,
@@ -605,7 +605,7 @@ SlaveSM::SlaveSM(const base::FilePath& path, HANDLE channel)
printf("Unable to open cache files\n");
return;
}
- cache_.reset(reinterpret_cast<disk_cache::BackendImpl*>(cache));
+ cache_.reset(reinterpret_cast<disk_cache::BackendImpl*>(cache.release()));
cache_->SetUpgradeMode();
}