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

Unified Diff: sync/internal_api/sync_manager_impl.cc

Issue 10824161: [Sync] Avoid unregistering object IDs on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work around brittle unit test Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/sync_manager_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/sync_manager_impl.cc
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index 16232f4083a8560b39ac5f26dc6074d0e55387c3..28d6b3c2f4714fb753505b0fc1439e6b85b49640 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -396,6 +396,7 @@ void SyncManagerImpl::Init(
change_delegate_ = change_delegate;
sync_notifier_ = sync_notifier.Pass();
+ sync_notifier_->RegisterHandler(this);
AddObserver(&js_sync_manager_observer_);
SetJsEventHandler(event_handler);
@@ -733,18 +734,34 @@ void SyncManagerImpl::UpdateCredentials(
void SyncManagerImpl::UpdateEnabledTypes(
const ModelTypeSet& enabled_types) {
DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(initialized_);
sync_notifier_->UpdateRegisteredIds(
this,
ModelTypeSetToObjectIdSet(enabled_types));
}
+void SyncManagerImpl::RegisterInvalidationHandler(
+ SyncNotifierObserver* handler) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(initialized_);
+ sync_notifier_->RegisterHandler(handler);
+}
+
void SyncManagerImpl::UpdateRegisteredInvalidationIds(
SyncNotifierObserver* handler,
const ObjectIdSet& ids) {
DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(initialized_);
sync_notifier_->UpdateRegisteredIds(handler, ids);
}
+void SyncManagerImpl::UnregisterInvalidationHandler(
+ SyncNotifierObserver* handler) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(initialized_);
+ sync_notifier_->UnregisterHandler(handler);
+}
+
void SyncManagerImpl::SetEncryptionPassphrase(
const std::string& passphrase,
bool is_explicit) {
@@ -1216,14 +1233,17 @@ void SyncManagerImpl::ShutdownOnSyncThread() {
RemoveObserver(&debug_info_event_listener_);
- if (sync_notifier_.get()) {
- sync_notifier_->UpdateRegisteredIds(this, ObjectIdSet());
- }
+ // |sync_notifier_| and |connection_manager_| may end up being NULL here in
+ // tests (in synchronous initialization mode).
+ //
+ // TODO(akalin): Fix this behavior.
+
+ if (sync_notifier_.get())
+ sync_notifier_->UnregisterHandler(this);
sync_notifier_.reset();
- if (connection_manager_.get()) {
+ if (connection_manager_.get())
connection_manager_->RemoveListener(this);
- }
connection_manager_.reset();
net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/sync_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698