summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-22 01:47:16 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-22 01:47:16 +0000
commitb3edb31e6ec0a3a3a312718933e907f341606548 (patch)
treeb9e73b4dd19be2535b13c1ab2b270d84dafbd910 /chrome/browser
parent825ff8d48aee34b10ef6198743755b88c01a0e6b (diff)
downloadchromium_src-b3edb31e6ec0a3a3a312718933e907f341606548.zip
chromium_src-b3edb31e6ec0a3a3a312718933e907f341606548.tar.gz
chromium_src-b3edb31e6ec0a3a3a312718933e907f341606548.tar.bz2
More NotificationRegistrar conversions.
BUG=2381 Review URL: http://codereview.chromium.org/115674 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16699 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browsing_data_remover.cc16
-rw-r--r--chrome/browser/browsing_data_remover.h9
-rw-r--r--chrome/browser/google_url_tracker.cc8
-rw-r--r--chrome/browser/google_url_tracker.h3
4 files changed, 11 insertions, 25 deletions
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index 0929238..5b3bc70 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -40,7 +40,6 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
: profile_(profile),
delete_begin_(delete_begin),
delete_end_(delete_end),
- waiting_for_keywords_(false),
waiting_for_clear_history_(false),
waiting_for_clear_cache_(false) {
DCHECK(profile);
@@ -80,10 +79,8 @@ void BrowsingDataRemover::Remove(int remove_mask) {
// As part of history deletion we also delete the auto-generated keywords.
TemplateURLModel* keywords_model = profile_->GetTemplateURLModel();
if (keywords_model && !keywords_model->loaded()) {
- waiting_for_keywords_ = true;
- NotificationService::current()->AddObserver(
- this, NotificationType::TEMPLATE_URL_MODEL_LOADED,
- Source<TemplateURLModel>(keywords_model));
+ registrar_.Add(this, NotificationType::TEMPLATE_URL_MODEL_LOADED,
+ Source<TemplateURLModel>(keywords_model));
keywords_model->Load();
} else if (keywords_model) {
keywords_model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_);
@@ -198,15 +195,8 @@ void BrowsingDataRemover::Observe(NotificationType type,
DCHECK(type == NotificationType::TEMPLATE_URL_MODEL_LOADED);
TemplateURLModel* model = Source<TemplateURLModel>(source).ptr();
if (model->profile() == profile_->GetOriginalProfile()) {
- NotificationService::current()->RemoveObserver(
- this,
- NotificationType::TEMPLATE_URL_MODEL_LOADED,
- Source<TemplateURLModel>(model));
-
+ registrar_.RemoveAll();
model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_);
-
- waiting_for_keywords_ = false;
-
NotifyAndDeleteIfDone();
}
}
diff --git a/chrome/browser/browsing_data_remover.h b/chrome/browser/browsing_data_remover.h
index 62172a0..0425c6f 100644
--- a/chrome/browser/browsing_data_remover.h
+++ b/chrome/browser/browsing_data_remover.h
@@ -8,7 +8,7 @@
#include "base/observer_list.h"
#include "base/time.h"
#include "chrome/browser/cancelable_request.h"
-#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
class MessageLoop;
class Profile;
@@ -90,10 +90,12 @@ class BrowsingDataRemover : public NotificationObserver {
// Returns true if we're all done.
bool all_done() {
- return !waiting_for_keywords_ && !waiting_for_clear_cache_ &&
+ return registrar_.IsEmpty() && !waiting_for_clear_cache_ &&
!waiting_for_clear_history_;
}
+ NotificationRegistrar registrar_;
+
// Profile we're to remove from.
Profile* profile_;
@@ -106,9 +108,6 @@ class BrowsingDataRemover : public NotificationObserver {
// True if Remove has been invoked.
static bool removing_;
- // True if we're waiting for the TemplateURLModel to finish loading.
- bool waiting_for_keywords_;
-
// True if we're waiting for the history to be deleted.
bool waiting_for_clear_history_;
diff --git a/chrome/browser/google_url_tracker.cc b/chrome/browser/google_url_tracker.cc
index 2e26147..8b60ae4 100644
--- a/chrome/browser/google_url_tracker.cc
+++ b/chrome/browser/google_url_tracker.cc
@@ -25,9 +25,8 @@ GoogleURLTracker::GoogleURLTracker()
already_fetched_(false),
need_to_fetch_(false),
request_context_available_(!!Profile::GetDefaultRequestContext()) {
- NotificationService::current()->AddObserver(this,
- NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE,
- NotificationService::AllSources());
+ registrar_.Add(this, NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE,
+ NotificationService::AllSources());
// Because this function can be called during startup, when kicking off a URL
// fetch can eat up 20 ms of time, we delay five seconds, which is hopefully
@@ -42,9 +41,6 @@ GoogleURLTracker::GoogleURLTracker()
}
GoogleURLTracker::~GoogleURLTracker() {
- NotificationService::current()->RemoveObserver(this,
- NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE,
- NotificationService::AllSources());
}
// static
diff --git a/chrome/browser/google_url_tracker.h b/chrome/browser/google_url_tracker.h
index bdc7290..987987d 100644
--- a/chrome/browser/google_url_tracker.h
+++ b/chrome/browser/google_url_tracker.h
@@ -8,7 +8,7 @@
#include <string>
#include "chrome/browser/net/url_fetcher.h"
-#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
@@ -90,6 +90,7 @@ class GoogleURLTracker : public URLFetcher::Delegate,
static const char kDefaultGoogleHomepage[];
+ NotificationRegistrar registrar_;
GURL google_url_;
ScopedRunnableMethodFactory<GoogleURLTracker> fetcher_factory_;
scoped_ptr<URLFetcher> fetcher_;