Index: chrome/browser/sync/glue/chrome_sync_notification_bridge.cc |
=================================================================== |
--- chrome/browser/sync/glue/chrome_sync_notification_bridge.cc (revision 150991) |
+++ chrome/browser/sync/glue/chrome_sync_notification_bridge.cc (working copy) |
@@ -6,13 +6,11 @@ |
#include "base/bind.h" |
#include "base/location.h" |
-#include "base/logging.h" |
-#include "base/memory/scoped_ptr.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/notification_service.h" |
+#include "sync/notifier/sync_notifier_helper.h" |
#include "sync/notifier/sync_notifier_observer.h" |
-#include "sync/notifier/sync_notifier_registrar.h" |
using content::BrowserThread; |
@@ -27,14 +25,9 @@ |
// All member functions below must be called on the sync task runner. |
- void InitializeOnSyncThread(); |
- void CleanupOnSyncThread(); |
- |
void UpdateEnabledTypes(syncer::ModelTypeSet enabled_types); |
- void RegisterHandler(syncer::SyncNotifierObserver* handler); |
void UpdateRegisteredIds(syncer::SyncNotifierObserver* handler, |
const syncer::ObjectIdSet& ids); |
- void UnregisterHandler(syncer::SyncNotifierObserver* handler); |
void EmitNotification( |
const syncer::ModelTypePayloadMap& payload_map, |
@@ -50,7 +43,7 @@ |
// Used only on |sync_task_runner_|. |
syncer::ModelTypeSet enabled_types_; |
- scoped_ptr<syncer::SyncNotifierRegistrar> notifier_registrar_; |
+ syncer::SyncNotifierHelper helper_; |
}; |
ChromeSyncNotificationBridge::Core::Core( |
@@ -63,42 +56,21 @@ |
ChromeSyncNotificationBridge::Core::~Core() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
sync_task_runner_->RunsTasksOnCurrentThread()); |
- DCHECK(!notifier_registrar_.get()); |
} |
-void ChromeSyncNotificationBridge::Core::InitializeOnSyncThread() { |
- notifier_registrar_.reset(new syncer::SyncNotifierRegistrar()); |
-} |
- |
-void ChromeSyncNotificationBridge::Core::CleanupOnSyncThread() { |
- notifier_registrar_.reset(); |
-} |
- |
void ChromeSyncNotificationBridge::Core::UpdateEnabledTypes( |
syncer::ModelTypeSet types) { |
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
enabled_types_ = types; |
} |
-void ChromeSyncNotificationBridge::Core::RegisterHandler( |
- syncer::SyncNotifierObserver* handler) { |
- DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
- notifier_registrar_->RegisterHandler(handler); |
-} |
- |
void ChromeSyncNotificationBridge::Core::UpdateRegisteredIds( |
syncer::SyncNotifierObserver* handler, |
const syncer::ObjectIdSet& ids) { |
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
- notifier_registrar_->UpdateRegisteredIds(handler, ids); |
+ helper_.UpdateRegisteredIds(handler, ids); |
} |
-void ChromeSyncNotificationBridge::Core::UnregisterHandler( |
- syncer::SyncNotifierObserver* handler) { |
- DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
- notifier_registrar_->UnregisterHandler(handler); |
-} |
- |
void ChromeSyncNotificationBridge::Core::EmitNotification( |
const syncer::ModelTypePayloadMap& payload_map, |
syncer::IncomingNotificationSource notification_source) { |
@@ -108,7 +80,7 @@ |
syncer::ModelTypePayloadMapFromEnumSet(enabled_types_, std::string()) : |
payload_map; |
- notifier_registrar_->DispatchInvalidationsToHandlers( |
+ helper_.DispatchInvalidationsToHandlers( |
ModelTypePayloadMapToObjectIdPayloadMap(effective_payload_map), |
notification_source); |
} |
@@ -124,34 +96,16 @@ |
content::Source<Profile>(profile)); |
registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_REMOTE, |
content::Source<Profile>(profile)); |
- |
- if (!sync_task_runner_->PostTask( |
- FROM_HERE, base::Bind(&Core::InitializeOnSyncThread, core_))) { |
- NOTREACHED(); |
- } |
} |
ChromeSyncNotificationBridge::~ChromeSyncNotificationBridge() {} |
-void ChromeSyncNotificationBridge::StopForShutdown() { |
- if (!sync_task_runner_->PostTask( |
- FROM_HERE, base::Bind(&Core::CleanupOnSyncThread, core_))) { |
- NOTREACHED(); |
- } |
-} |
- |
void ChromeSyncNotificationBridge::UpdateEnabledTypes( |
syncer::ModelTypeSet types) { |
DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
core_->UpdateEnabledTypes(types); |
} |
-void ChromeSyncNotificationBridge::RegisterHandler( |
- syncer::SyncNotifierObserver* handler) { |
- DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
- core_->RegisterHandler(handler); |
-} |
- |
void ChromeSyncNotificationBridge::UpdateRegisteredIds( |
syncer::SyncNotifierObserver* handler, |
const syncer::ObjectIdSet& ids) { |
@@ -159,12 +113,6 @@ |
core_->UpdateRegisteredIds(handler, ids); |
} |
-void ChromeSyncNotificationBridge::UnregisterHandler( |
- syncer::SyncNotifierObserver* handler) { |
- DCHECK(sync_task_runner_->RunsTasksOnCurrentThread()); |
- core_->UnregisterHandler(handler); |
-} |
- |
void ChromeSyncNotificationBridge::Observe( |
int type, |
const content::NotificationSource& source, |
@@ -184,12 +132,10 @@ |
content::Details<const syncer::ModelTypePayloadMap> |
payload_details(details); |
const syncer::ModelTypePayloadMap& payload_map = *(payload_details.ptr()); |
- if (!sync_task_runner_->PostTask( |
- FROM_HERE, |
- base::Bind(&Core::EmitNotification, |
- core_, payload_map, notification_source))) { |
- NOTREACHED(); |
- } |
+ sync_task_runner_->PostTask( |
+ FROM_HERE, |
+ base::Bind(&Core::EmitNotification, |
+ core_, payload_map, notification_source)); |
} |
} // namespace browser_sync |