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

Unified Diff: chrome/browser/sync/profile_sync_service.cc

Issue 11046008: [Invalidations] Require there to be no registered handlers on Invalidator destruction (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to HEAD Created 8 years, 2 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 | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/profile_sync_service.cc
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 92f7d1e1fac58904cbcc025e3563b3e10184c80e..31385719335a3aacaa54ec10849783ad7ac2a408 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -67,6 +67,7 @@
#include "sync/internal_api/public/util/sync_string_conversions.h"
#include "sync/js/js_arg_list.h"
#include "sync/js/js_event_details.h"
+#include "sync/notifier/invalidator_registrar.h"
#include "sync/util/cryptographer.h"
#include "ui/base/l10n/l10n_util.h"
@@ -189,6 +190,9 @@ bool ProfileSyncService::IsSyncTokenAvailable() {
}
void ProfileSyncService::Initialize() {
+ DCHECK(!invalidator_registrar_.get());
+ invalidator_registrar_.reset(new syncer::InvalidatorRegistrar());
+
InitSettings();
// We clear this here (vs Shutdown) because we want to remember that an error
@@ -435,7 +439,7 @@ void ProfileSyncService::StartUp() {
// http://crbug.com/140354).
if (backend_.get()) {
backend_->UpdateRegisteredInvalidationIds(
- invalidator_registrar_.GetAllRegisteredIds());
+ invalidator_registrar_->GetAllRegisteredIds());
}
if (!sync_global_error_.get()) {
@@ -450,29 +454,29 @@ void ProfileSyncService::StartUp() {
void ProfileSyncService::RegisterInvalidationHandler(
syncer::InvalidationHandler* handler) {
- invalidator_registrar_.RegisterHandler(handler);
+ invalidator_registrar_->RegisterHandler(handler);
}
void ProfileSyncService::UpdateRegisteredInvalidationIds(
syncer::InvalidationHandler* handler,
const syncer::ObjectIdSet& ids) {
- invalidator_registrar_.UpdateRegisteredIds(handler, ids);
+ invalidator_registrar_->UpdateRegisteredIds(handler, ids);
// If |backend_| is NULL, its registered IDs will be updated when
// it's created and initialized.
if (backend_.get()) {
backend_->UpdateRegisteredInvalidationIds(
- invalidator_registrar_.GetAllRegisteredIds());
+ invalidator_registrar_->GetAllRegisteredIds());
}
}
void ProfileSyncService::UnregisterInvalidationHandler(
syncer::InvalidationHandler* handler) {
- invalidator_registrar_.UnregisterHandler(handler);
+ invalidator_registrar_->UnregisterHandler(handler);
}
syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const {
- return invalidator_registrar_.GetInvalidatorState();
+ return invalidator_registrar_->GetInvalidatorState();
}
void ProfileSyncService::EmitInvalidationForTest(
@@ -487,6 +491,7 @@ void ProfileSyncService::EmitInvalidationForTest(
}
void ProfileSyncService::Shutdown() {
+ DCHECK(invalidator_registrar_.get());
// TODO(akalin): Remove this once http://crbug.com/153827 is fixed.
ExtensionService* const extension_service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
@@ -495,6 +500,10 @@ void ProfileSyncService::Shutdown() {
if (extension_service)
extension_service->OnProfileSyncServiceShutdown();
+ // Reset |invalidator_registrar_| first so that ShutdownImpl cannot
+ // use it.
+ invalidator_registrar_.reset();
+
ShutdownImpl(false);
}
@@ -688,14 +697,14 @@ void ProfileSyncService::DisableBrokenDatatype(
void ProfileSyncService::OnInvalidatorStateChange(
syncer::InvalidatorState state) {
- invalidator_registrar_.UpdateInvalidatorState(state);
+ invalidator_registrar_->UpdateInvalidatorState(state);
}
void ProfileSyncService::OnIncomingInvalidation(
const syncer::ObjectIdInvalidationMap& invalidation_map,
syncer::IncomingInvalidationSource source) {
- invalidator_registrar_.DispatchInvalidationsToHandlers(invalidation_map,
- source);
+ invalidator_registrar_->DispatchInvalidationsToHandlers(invalidation_map,
+ source);
}
void ProfileSyncService::OnBackendInitialized(
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698