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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browsing_data/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data/browsing_data_remover.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 #if defined(ENABLE_WEBRTC) 94 #if defined(ENABLE_WEBRTC)
95 #include "chrome/browser/media/webrtc_log_list.h" 95 #include "chrome/browser/media/webrtc_log_list.h"
96 #include "chrome/browser/media/webrtc_log_util.h" 96 #include "chrome/browser/media/webrtc_log_util.h"
97 #endif 97 #endif
98 98
99 using base::UserMetricsAction; 99 using base::UserMetricsAction;
100 using content::BrowserContext; 100 using content::BrowserContext;
101 using content::BrowserThread; 101 using content::BrowserThread;
102 using content::DOMStorageContext; 102 using content::DOMStorageContext;
103 103
104 namespace {
105
106 using CallbackList =
107 base::CallbackList<void(const BrowsingDataRemover::NotificationDetails&)>;
108
109 // Contains all registered callbacks for browsing data removed notifications.
110 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.
111
112 // Accessor for |*on_browsing_data_removed_callbacks_|. Creates a new object
113 // the first time so that it always returns a valid object.
114 CallbackList* GetOnBrowsingDataRemovedCallbacks() {
115 if (!on_browsing_data_removed_callbacks_)
116 on_browsing_data_removed_callbacks_ = new CallbackList();
117 return on_browsing_data_removed_callbacks_;
118 }
119
120 } // namespace
121
104 bool BrowsingDataRemover::is_removing_ = false; 122 bool BrowsingDataRemover::is_removing_ = false;
105 123
106 BrowsingDataRemover::CompletionInhibitor* 124 BrowsingDataRemover::CompletionInhibitor*
107 BrowsingDataRemover::completion_inhibitor_ = NULL; 125 BrowsingDataRemover::completion_inhibitor_ = NULL;
108 126
109 // Helper to create callback for BrowsingDataRemover::DoesOriginMatchMask. 127 // Helper to create callback for BrowsingDataRemover::DoesOriginMatchMask.
110 // Static. 128 // Static.
111 bool DoesOriginMatchMask( 129 bool DoesOriginMatchMask(
112 int origin_set_mask, 130 int origin_set_mask,
113 const GURL& origin, 131 const GURL& origin,
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 TemplateURLServiceFactory::GetForProfile(profile_); 819 TemplateURLServiceFactory::GetForProfile(profile_);
802 model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_); 820 model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_);
803 waiting_for_clear_keyword_data_ = false; 821 waiting_for_clear_keyword_data_ = false;
804 template_url_sub_.reset(); 822 template_url_sub_.reset();
805 NotifyAndDeleteIfDone(); 823 NotifyAndDeleteIfDone();
806 } 824 }
807 825
808 void BrowsingDataRemover::NotifyAndDelete() { 826 void BrowsingDataRemover::NotifyAndDelete() {
809 set_removing(false); 827 set_removing(false);
810 828
811 // Send global notification, then notify any explicit observers. 829 // Notify observers.
812 BrowsingDataRemover::NotificationDetails details(delete_begin_, remove_mask_, 830 BrowsingDataRemover::NotificationDetails details(delete_begin_, remove_mask_,
813 origin_set_mask_); 831 origin_set_mask_);
814 content::NotificationService::current()->Notify( 832
815 chrome::NOTIFICATION_BROWSING_DATA_REMOVED, 833 GetOnBrowsingDataRemovedCallbacks()->Notify(details);
816 content::Source<Profile>(profile_),
817 content::Details<BrowsingDataRemover::NotificationDetails>(&details));
818 834
819 FOR_EACH_OBSERVER(Observer, observer_list_, OnBrowsingDataRemoverDone()); 835 FOR_EACH_OBSERVER(Observer, observer_list_, OnBrowsingDataRemoverDone());
820 836
821 // History requests aren't happy if you delete yourself from the callback. 837 // History requests aren't happy if you delete yourself from the callback.
822 // As such, we do a delete later. 838 // As such, we do a delete later.
823 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 839 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
824 } 840 }
825 841
826 void BrowsingDataRemover::NotifyAndDeleteIfDone() { 842 void BrowsingDataRemover::NotifyAndDeleteIfDone() {
827 // TODO(brettw) http://crbug.com/305259: This should also observe session 843 // TODO(brettw) http://crbug.com/305259: This should also observe session
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 waiting_for_clear_webrtc_logs_ = false; 1208 waiting_for_clear_webrtc_logs_ = false;
1193 NotifyAndDeleteIfDone(); 1209 NotifyAndDeleteIfDone();
1194 } 1210 }
1195 #endif 1211 #endif
1196 1212
1197 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { 1213 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() {
1198 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1214 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1199 waiting_for_clear_domain_reliability_monitor_ = false; 1215 waiting_for_clear_domain_reliability_monitor_ = false;
1200 NotifyAndDeleteIfDone(); 1216 NotifyAndDeleteIfDone();
1201 } 1217 }
1218
1219 // static
1220 BrowsingDataRemover::CallbackSubscription
1221 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
1222 const BrowsingDataRemover::Callback& callback) {
1223 return GetOnBrowsingDataRemovedCallbacks()->Add(callback);
1224 }
OLDNEW
« 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