diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 14:22:54 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 14:22:54 +0000 |
commit | 2474031c9712cceaa0925aef2226e2acf82b579a (patch) | |
tree | e06ad3cf350cb2d3e92c01a841b6cc317b3ad92e | |
parent | cf06d35adf3115c1bc43021840d141f47d7c0cec (diff) | |
download | chromium_src-2474031c9712cceaa0925aef2226e2acf82b579a.zip chromium_src-2474031c9712cceaa0925aef2226e2acf82b579a.tar.gz chromium_src-2474031c9712cceaa0925aef2226e2acf82b579a.tar.bz2 |
BrowsingDataRemover* should not be scoped.
BrowsingDataRemover deletes itself (see browsing_data_remover.cc:
MessageLoop::current()->DeleteSoon(FROM_HERE, this)).
BUG=22068
Review URL: http://codereview.chromium.org/218001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27607 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browsing_data_remover.h | 7 | ||||
-rw-r--r-- | chrome/browser/dom_ui/history_ui.cc | 13 | ||||
-rw-r--r-- | chrome/browser/dom_ui/history_ui.h | 3 |
3 files changed, 14 insertions, 9 deletions
diff --git a/chrome/browser/browsing_data_remover.h b/chrome/browser/browsing_data_remover.h index 0425c6f..1e5054c 100644 --- a/chrome/browser/browsing_data_remover.h +++ b/chrome/browser/browsing_data_remover.h @@ -52,7 +52,6 @@ class BrowsingDataRemover : public NotificationObserver { // profile in the specified time range. BrowsingDataRemover(Profile* profile, TimePeriod time_period, base::Time delete_end); - ~BrowsingDataRemover(); // Removes the specified items related to browsing. void Remove(int remove_mask); @@ -66,6 +65,12 @@ class BrowsingDataRemover : public NotificationObserver { static bool is_removing() { return removing_; } private: + // BrowsingDataRemover deletes itself (using DeleteTask) and is not supposed + // to be deleted by other objects so make destructor private and DeleteTask + // a friend. + friend class DeleteTask<BrowsingDataRemover>; + ~BrowsingDataRemover(); + // NotificationObserver method. Callback when TemplateURLModel has finished // loading. Deletes the entries from the model, and if we're not waiting on // anything else notifies observers and deletes this BrowsingDataRemover. diff --git a/chrome/browser/dom_ui/history_ui.cc b/chrome/browser/dom_ui/history_ui.cc index 45a994b..978ad07 100644 --- a/chrome/browser/dom_ui/history_ui.cc +++ b/chrome/browser/dom_ui/history_ui.cc @@ -104,7 +104,7 @@ BrowsingHistoryHandler::BrowsingHistoryHandler() BrowsingHistoryHandler::~BrowsingHistoryHandler() { cancelable_consumer_.CancelAllRequests(); - if (remover_.get()) + if (remover_) remover_->RemoveObserver(this); } @@ -204,9 +204,9 @@ void BrowsingHistoryHandler::HandleDeleteDay(const Value* value) { base::Time begin_time = time.LocalMidnight(); base::Time end_time = begin_time + base::TimeDelta::FromDays(1); - remover_.reset(new BrowsingDataRemover(dom_ui_->GetProfile(), - begin_time, - end_time)); + remover_ = new BrowsingDataRemover(dom_ui_->GetProfile(), + begin_time, + end_time); remover_->AddObserver(this); remover_->Remove(BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_COOKIES | @@ -215,8 +215,9 @@ void BrowsingHistoryHandler::HandleDeleteDay(const Value* value) { void BrowsingHistoryHandler::OnBrowsingDataRemoverDone() { dom_ui_->CallJavascriptFunction(L"deleteComplete"); - remover_->RemoveObserver(this); - remover_.release(); + // No need to remove ourselves as an observer as BrowsingDataRemover deletes + // itself after we return. + remover_ = NULL; } void BrowsingHistoryHandler::QueryComplete( diff --git a/chrome/browser/dom_ui/history_ui.h b/chrome/browser/dom_ui/history_ui.h index 48b055b..846fa61 100644 --- a/chrome/browser/dom_ui/history_ui.h +++ b/chrome/browser/dom_ui/history_ui.h @@ -7,7 +7,6 @@ #include <vector> -#include "base/scoped_ptr.h" #include "chrome/browser/browsing_data_remover.h" #include "chrome/browser/dom_ui/chrome_url_data_manager.h" #include "chrome/browser/dom_ui/dom_ui.h" @@ -80,7 +79,7 @@ class BrowsingHistoryHandler : public DOMMessageHandler, std::wstring search_text_; // Browsing history remover - scoped_ptr<BrowsingDataRemover> remover_; + BrowsingDataRemover* remover_; // Our consumer for the history service. CancelableRequestConsumerT<int, 0> cancelable_consumer_; |