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

Unified Diff: chrome/browser/profiles/profile_destroyer.cc

Issue 15854011: Moving ProfileDestroyer from ref counting to WeakPtr. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | « chrome/browser/profiles/profile_destroyer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_destroyer.cc
diff --git a/chrome/browser/profiles/profile_destroyer.cc b/chrome/browser/profiles/profile_destroyer.cc
index 7aa57d2203405a10fb31dae20272ba0389e19868..f26180b5718e3d66264095507a51f3e205ab9c0c 100644
--- a/chrome/browser/profiles/profile_destroyer.cc
+++ b/chrome/browser/profiles/profile_destroyer.cc
@@ -55,8 +55,7 @@ void ProfileDestroyer::DestroyProfileWhenAppropriate(Profile* const profile) {
} else {
// The instance will destroy itself once all render process hosts referring
// to it are properly terminated.
- scoped_refptr<ProfileDestroyer> profile_destroyer(
- new ProfileDestroyer(profile, hosts));
+ new ProfileDestroyer(profile, hosts);
}
}
@@ -87,7 +86,8 @@ ProfileDestroyer::ProfileDestroyer(
const std::vector<content::RenderProcessHost*>& hosts)
: timer_(false, false),
num_hosts_(0),
- profile_(profile) {
+ profile_(profile),
+ weak_ptr_factory_(this) {
if (pending_destroyers_ == NULL)
pending_destroyers_ = new std::vector<ProfileDestroyer*>;
pending_destroyers_->push_back(this);
@@ -103,7 +103,8 @@ ProfileDestroyer::ProfileDestroyer(
if (num_hosts_) {
timer_.Start(FROM_HERE,
base::TimeDelta::FromSeconds(kTimerDelaySeconds),
- base::Bind(&ProfileDestroyer::DestroyProfile, this));
+ base::Bind(&ProfileDestroyer::DestroyProfile,
+ weak_ptr_factory_.GetWeakPtr()));
}
}
@@ -142,7 +143,8 @@ void ProfileDestroyer::Observe(int type,
// Delay the destruction one step further in case other observers of this
// notification need to look at the profile attached to the host.
base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&ProfileDestroyer::DestroyProfile, this));
+ FROM_HERE, base::Bind(
+ &ProfileDestroyer::DestroyProfile, weak_ptr_factory_.GetWeakPtr()));
}
}
@@ -162,6 +164,8 @@ void ProfileDestroyer::DestroyProfile() {
// And stop the timer so we can be released early too.
timer_.Stop();
+
+ delete this;
}
// static
« no previous file with comments | « chrome/browser/profiles/profile_destroyer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698