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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 10824161: [Sync] Avoid unregistering object IDs on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove now-unneeded param 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // we'll want to start from a fresh SyncDB, so delete any old one that might 421 // we'll want to start from a fresh SyncDB, so delete any old one that might
422 // be there. 422 // be there.
423 InitializeBackend(!HasSyncSetupCompleted()); 423 InitializeBackend(!HasSyncSetupCompleted());
424 424
425 // |backend_| may end up being NULL here in tests (in synchronous 425 // |backend_| may end up being NULL here in tests (in synchronous
426 // initialization mode). 426 // initialization mode).
427 // 427 //
428 // TODO(akalin): Fix this horribly non-intuitive behavior (see 428 // TODO(akalin): Fix this horribly non-intuitive behavior (see
429 // http://crbug.com/140354). 429 // http://crbug.com/140354).
430 if (backend_.get()) { 430 if (backend_.get()) {
431 backend_->UpdateRegisteredInvalidationIds(all_registered_ids_); 431 backend_->UpdateRegisteredInvalidationIds(
432 notifier_helper_.GetAllRegisteredIds());
432 } 433 }
433 434
434 if (!sync_global_error_.get()) { 435 if (!sync_global_error_.get()) {
435 #if !defined(OS_ANDROID) 436 #if !defined(OS_ANDROID)
436 sync_global_error_.reset(new SyncGlobalError(this, signin())); 437 sync_global_error_.reset(new SyncGlobalError(this, signin()));
437 #endif 438 #endif
438 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( 439 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(
439 sync_global_error_.get()); 440 sync_global_error_.get());
440 AddObserver(sync_global_error_.get()); 441 AddObserver(sync_global_error_.get());
441 } 442 }
442 } 443 }
443 444
445 void ProfileSyncService::SetInvalidationHandler(
446 const std::string& handler_name,
447 syncer::SyncNotifierObserver* handler) {
448 notifier_helper_.SetHandler(handler_name, handler);
449 }
450
444 void ProfileSyncService::UpdateRegisteredInvalidationIds( 451 void ProfileSyncService::UpdateRegisteredInvalidationIds(
445 syncer::SyncNotifierObserver* handler, 452 const std::string& handler_name,
446 const syncer::ObjectIdSet& ids) { 453 const syncer::ObjectIdSet& ids) {
447 all_registered_ids_ = notifier_helper_.UpdateRegisteredIds(handler, ids); 454 notifier_helper_.UpdateRegisteredIds(handler_name, ids);
455
448 // If |backend_| is NULL, its registered IDs will be updated when 456 // If |backend_| is NULL, its registered IDs will be updated when
449 // it's created and initialized. 457 // it's created and initialized.
450 if (backend_.get()) { 458 if (backend_.get()) {
451 backend_->UpdateRegisteredInvalidationIds(all_registered_ids_); 459 backend_->UpdateRegisteredInvalidationIds(
460 notifier_helper_.GetAllRegisteredIds());
452 } 461 }
453 } 462 }
454 463
455 void ProfileSyncService::Shutdown() { 464 void ProfileSyncService::Shutdown() {
456 ShutdownImpl(false); 465 ShutdownImpl(false);
457 } 466 }
458 467
459 void ProfileSyncService::ShutdownImpl(bool sync_disabled) { 468 void ProfileSyncService::ShutdownImpl(bool sync_disabled) {
460 // First, we spin down the backend and wait for it to stop syncing completely 469 // First, we spin down the backend and wait for it to stop syncing completely
461 // before we Stop the data type manager. This is to avoid a late sync cycle 470 // before we Stop the data type manager. This is to avoid a late sync cycle
462 // applying changes to the sync db that wouldn't get applied via 471 // applying changes to the sync db that wouldn't get applied via
463 // ChangeProcessors, leading to back-from-the-dead bugs. 472 // ChangeProcessors, leading to back-from-the-dead bugs.
464 base::Time shutdown_start_time = base::Time::Now(); 473 base::Time shutdown_start_time = base::Time::Now();
465 if (backend_.get()) { 474 if (backend_.get()) {
466 backend_->StopSyncingForShutdown(); 475 backend_->StopSyncingForShutdown();
467 backend_->UpdateRegisteredInvalidationIds(syncer::ObjectIdSet());
468 } 476 }
469 477
470 // Stop all data type controllers, if needed. Note that until Stop 478 // Stop all data type controllers, if needed. Note that until Stop
471 // completes, it is possible in theory to have a ChangeProcessor apply a 479 // completes, it is possible in theory to have a ChangeProcessor apply a
472 // change from a native model. In that case, it will get applied to the sync 480 // change from a native model. In that case, it will get applied to the sync
473 // database (which doesn't get destroyed until we destroy the backend below) 481 // database (which doesn't get destroyed until we destroy the backend below)
474 // as an unsynced change. That will be persisted, and committed on restart. 482 // as an unsynced change. That will be persisted, and committed on restart.
475 if (data_type_manager_.get()) { 483 if (data_type_manager_.get()) {
476 if (data_type_manager_->state() != DataTypeManager::STOPPED) { 484 if (data_type_manager_->state() != DataTypeManager::STOPPED) {
477 // When aborting as part of shutdown, we should expect an aborted sync 485 // When aborting as part of shutdown, we should expect an aborted sync
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1800 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1793 ProfileSyncService* old_this = this; 1801 ProfileSyncService* old_this = this;
1794 this->~ProfileSyncService(); 1802 this->~ProfileSyncService();
1795 new(old_this) ProfileSyncService( 1803 new(old_this) ProfileSyncService(
1796 new ProfileSyncComponentsFactoryImpl(profile, 1804 new ProfileSyncComponentsFactoryImpl(profile,
1797 CommandLine::ForCurrentProcess()), 1805 CommandLine::ForCurrentProcess()),
1798 profile, 1806 profile,
1799 signin, 1807 signin,
1800 behavior); 1808 behavior);
1801 } 1809 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698