diff options
-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_; |