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

Unified Diff: chrome/browser/browsing_data/browsing_data_remover.cc

Issue 874613004: Remove NOTIFICATION_BROWSING_DATA_REMOVED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 11 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
Index: chrome/browser/browsing_data/browsing_data_remover.cc
diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc
index 7987a92b972853da4aa464556bc68cac0b1fb197..ebd2309065244a983ac134f88eda933cc76bbad4 100644
--- a/chrome/browser/browsing_data/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover.cc
@@ -101,6 +101,24 @@ using content::BrowserContext;
using content::BrowserThread;
using content::DOMStorageContext;
+namespace {
+
+using CallbackList =
+ base::CallbackList<void(const BrowsingDataRemover::NotificationDetails&)>;
+
+// Contains all registered callbacks for browsing data removed notifications.
+CallbackList* on_browsing_data_removed_callbacks_ = nullptr;
Bernhard Bauer 2015/01/26 18:24:22 Name this |g_on_browsing_data_removed_callbacks| n
Simon Que 2015/01/26 18:43:00 Done.
+
+// Accessor for |*on_browsing_data_removed_callbacks_|. Creates a new object
+// the first time so that it always returns a valid object.
+CallbackList* GetOnBrowsingDataRemovedCallbacks() {
+ if (!on_browsing_data_removed_callbacks_)
+ on_browsing_data_removed_callbacks_ = new CallbackList();
+ return on_browsing_data_removed_callbacks_;
+}
+
+} // namespace
+
bool BrowsingDataRemover::is_removing_ = false;
BrowsingDataRemover::CompletionInhibitor*
@@ -808,13 +826,11 @@ void BrowsingDataRemover::OnKeywordsLoaded() {
void BrowsingDataRemover::NotifyAndDelete() {
set_removing(false);
- // Send global notification, then notify any explicit observers.
+ // Notify observers.
BrowsingDataRemover::NotificationDetails details(delete_begin_, remove_mask_,
origin_set_mask_);
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_BROWSING_DATA_REMOVED,
- content::Source<Profile>(profile_),
- content::Details<BrowsingDataRemover::NotificationDetails>(&details));
+
+ GetOnBrowsingDataRemovedCallbacks()->Notify(details);
FOR_EACH_OBSERVER(Observer, observer_list_, OnBrowsingDataRemoverDone());
@@ -1199,3 +1215,10 @@ void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() {
waiting_for_clear_domain_reliability_monitor_ = false;
NotifyAndDeleteIfDone();
}
+
+// static
+BrowsingDataRemover::CallbackSubscription
+ BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
+ const BrowsingDataRemover::Callback& callback) {
+ return GetOnBrowsingDataRemovedCallbacks()->Add(callback);
+}
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover.h ('k') | chrome/browser/browsing_data/browsing_data_remover_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698