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 342a049a3f680b4adf7a27992278e9b06e32f419..1a331e79ad09ea800f9a591af8c37cba4e97a5ac 100644 |
--- a/chrome/browser/sync/glue/favicon_cache.cc |
+++ b/chrome/browser/sync/glue/favicon_cache.cc |
@@ -6,13 +6,11 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/metrics/histogram.h" |
-#include "chrome/browser/chrome_notification_types.h" |
#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 +224,15 @@ 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_, ServiceAccessType::EXPLICIT_ACCESS); |
+ } |
+ if (hs) |
+ history_service_observer_.Add(hs); |
DVLOG(1) << "Setting favicon limit to " << max_sync_favicon_limit; |
} |
@@ -571,41 +574,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 +1033,36 @@ size_t FaviconCache::NumTasksForTest() const { |
return page_task_map_.size(); |
} |
+void FaviconCache::OnURLsDeleted(HistoryService* history_service, |
+ bool all_history, |
+ bool expired, |
+ const history::URLRows& deleted_rows, |
+ const std::set<GURL>& favicon_urls) { |
+ // We only care about actual user (or sync) deletions. |
+ if (expired) |
+ return; |
+ |
+ if (!all_history) { |
+ DeleteSyncedFavicons(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 |