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

Unified Diff: chrome/browser/sync/glue/typed_url_change_processor.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/typed_url_change_processor.cc
diff --git a/chrome/browser/sync/glue/typed_url_change_processor.cc b/chrome/browser/sync/glue/typed_url_change_processor.cc
index 6ce366f8b80f06fe8e2dc4e7b2ace4fd9f2910fa..9dc90ac8fb18e56e24c9ddeaf8d7c849fdc27b90 100644
--- a/chrome/browser/sync/glue/typed_url_change_processor.cc
+++ b/chrome/browser/sync/glue/typed_url_change_processor.cc
@@ -8,14 +8,12 @@
#include "base/metrics/histogram.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/history_backend.h"
#include "chrome/browser/history/history_notifications.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/glue/typed_url_model_associator.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/notification_service.h"
#include "sync/internal_api/public/change_record.h"
#include "sync/internal_api/public/read_node.h"
#include "sync/internal_api/public/write_node.h"
@@ -45,15 +43,12 @@ TypedUrlChangeProcessor::TypedUrlChangeProcessor(
model_associator_(model_associator),
history_backend_(history_backend),
backend_loop_(base::MessageLoop::current()),
- disconnected_(false) {
+ disconnected_(false),
+ history_backend_observer_(this) {
DCHECK(model_associator);
DCHECK(history_backend);
DCHECK(error_handler);
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
- // When running in unit tests, there is already a NotificationService object.
- // Since only one can exist at a time per thread, check first.
- if (!content::NotificationService::current())
sdefresne 2014/12/04 17:21:13 \o/
- notification_service_.reset(content::NotificationService::Create());
}
TypedUrlChangeProcessor::~TypedUrlChangeProcessor() {
@@ -62,24 +57,6 @@ TypedUrlChangeProcessor::~TypedUrlChangeProcessor() {
history_backend_->RemoveObserver(this);
}
-void TypedUrlChangeProcessor::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK(backend_loop_ == base::MessageLoop::current());
- DCHECK_EQ(type, chrome::NOTIFICATION_HISTORY_URLS_DELETED);
-
- base::AutoLock al(disconnect_lock_);
- if (disconnected_)
- return;
-
- DVLOG(1) << "Observed typed_url change.";
- HandleURLsDeleted(
- content::Details<history::URLsDeletedDetails>(details).ptr());
- UMA_HISTOGRAM_PERCENTAGE("Sync.TypedUrlChangeProcessorErrors",
- model_associator_->GetErrorPercentage());
-}
-
void TypedUrlChangeProcessor::OnURLVisited(
history::HistoryBackend* history_backend,
ui::PageTransition transition,
@@ -123,6 +100,21 @@ void TypedUrlChangeProcessor::OnURLsModified(
model_associator_->GetErrorPercentage());
}
+void TypedUrlChangeProcessor::OnURLsDeleted(
+ history::HistoryBackend* history_backend,
+ const history::URLsDeletedDetails& deleted_details) {
+ DCHECK(backend_loop_ == base::MessageLoop::current());
+
+ base::AutoLock al(disconnect_lock_);
+ if (disconnected_)
+ return;
+
+ DVLOG(1) << "Observed typed_url change.";
+ HandleURLsDeleted(const_cast<history::URLsDeletedDetails*>(&deleted_details));
+ UMA_HISTOGRAM_PERCENTAGE("Sync.TypedUrlChangeProcessorErrors",
+ model_associator_->GetErrorPercentage());
+}
+
bool TypedUrlChangeProcessor::CreateOrUpdateSyncNode(
history::URLRow url, syncer::WriteTransaction* trans) {
DCHECK_GT(url.typed_count(), 0);
@@ -347,20 +339,14 @@ void TypedUrlChangeProcessor::StartObserving() {
DCHECK(backend_loop_ == base::MessageLoop::current());
DCHECK(history_backend_);
DCHECK(profile_);
- notification_registrar_.Add(
- this, chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- content::Source<Profile>(profile_));
- history_backend_->AddObserver(this);
+ history_backend_observer_.Add(history_backend_);
}
void TypedUrlChangeProcessor::StopObserving() {
DCHECK(backend_loop_ == base::MessageLoop::current());
DCHECK(history_backend_);
DCHECK(profile_);
- notification_registrar_.Remove(
- this, chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- content::Source<Profile>(profile_));
- history_backend_->RemoveObserver(this);
+ history_backend_observer_.RemoveAll();
}
} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698