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

Unified Diff: chrome/browser/sync/glue/favicon_cache.cc

Issue 773103004: Remove NOTIFICATION_HISTORY_URLS_DELETED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove NotificationObserver from InMemoryURLIndex Created 6 years 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/sync/glue/favicon_cache.cc
diff --git a/chrome/browser/sync/glue/favicon_cache.cc b/chrome/browser/sync/glue/favicon_cache.cc
index f591fe4fa24baefd3d234a439e9cce04dcaa5234..acf3a3597b30f698db384af2492f0a2a03224dfa 100644
--- a/chrome/browser/sync/glue/favicon_cache.cc
+++ b/chrome/browser/sync/glue/favicon_cache.cc
@@ -10,9 +10,9 @@
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/history/history_notifications.h"
+#include "chrome/browser/history/history_service.h"
+#include "chrome/browser/history/history_service_factory.h"
#include "components/history/core/browser/history_types.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_source.h"
#include "sync/api/time.h"
#include "sync/protocol/favicon_image_specifics.pb.h"
#include "sync/protocol/favicon_tracking_specifics.pb.h"
@@ -226,10 +226,14 @@ bool FaviconInfoHasValidTypeData(const SyncedFaviconInfo& favicon_info,
FaviconCache::FaviconCache(Profile* profile, int max_sync_favicon_limit)
: profile_(profile),
max_sync_favicon_limit_(max_sync_favicon_limit),
+ history_service_observer_(this),
weak_ptr_factory_(this) {
- notification_registrar_.Add(this,
- chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- content::Source<Profile>(profile_));
+ HistoryService* hs = NULL;
+ if (profile_)
+ hs = HistoryServiceFactory::GetForProfile(profile_,
+ Profile::EXPLICIT_ACCESS);
+ if (hs)
+ history_service_observer_.Add(hs);
DVLOG(1) << "Setting favicon limit to " << max_sync_favicon_limit;
}
@@ -571,41 +575,6 @@ void FaviconCache::OnReceivedSyncFaviconImpl(
syncer::SyncChange::ACTION_UPDATE));
}
-void FaviconCache::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(type, chrome::NOTIFICATION_HISTORY_URLS_DELETED);
-
- content::Details<history::URLsDeletedDetails> deleted_details(details);
-
- // We only care about actual user (or sync) deletions.
- if (deleted_details->expired)
- return;
-
- if (!deleted_details->all_history) {
- DeleteSyncedFavicons(deleted_details->favicon_urls);
- return;
- }
-
- // All history was cleared: just delete all favicons.
- DVLOG(1) << "History clear detected, deleting all synced favicons.";
- syncer::SyncChangeList image_deletions, tracking_deletions;
- while (!synced_favicons_.empty()) {
- DeleteSyncedFavicon(synced_favicons_.begin(),
- &image_deletions,
- &tracking_deletions);
- }
-
- if (favicon_images_sync_processor_.get()) {
- favicon_images_sync_processor_->ProcessSyncChanges(FROM_HERE,
- image_deletions);
- }
- if (favicon_tracking_sync_processor_.get()) {
- favicon_tracking_sync_processor_->ProcessSyncChanges(FROM_HERE,
- tracking_deletions);
- }
-}
-
bool FaviconCache::FaviconRecencyFunctor::operator()(
const linked_ptr<SyncedFaviconInfo>& lhs,
const linked_ptr<SyncedFaviconInfo>& rhs) const {
@@ -1065,4 +1034,34 @@ size_t FaviconCache::NumTasksForTest() const {
return page_task_map_.size();
}
+void FaviconCache::OnURLsDeleted(
+ HistoryService* history_service,
+ const history::URLsDeletedDetails& deleted_details) {
+ // We only care about actual user (or sync) deletions.
+ if (deleted_details.expired)
+ return;
+
+ if (!deleted_details.all_history) {
+ DeleteSyncedFavicons(deleted_details.favicon_urls);
+ return;
+ }
+
+ // All history was cleared: just delete all favicons.
+ DVLOG(1) << "History clear detected, deleting all synced favicons.";
+ syncer::SyncChangeList image_deletions, tracking_deletions;
+ while (!synced_favicons_.empty()) {
+ DeleteSyncedFavicon(synced_favicons_.begin(), &image_deletions,
+ &tracking_deletions);
+ }
+
+ if (favicon_images_sync_processor_.get()) {
+ favicon_images_sync_processor_->ProcessSyncChanges(FROM_HERE,
+ image_deletions);
+ }
+ if (favicon_tracking_sync_processor_.get()) {
+ favicon_tracking_sync_processor_->ProcessSyncChanges(FROM_HERE,
+ tracking_deletions);
+ }
+}
+
} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698