OLD | NEW |
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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 // be there. | 424 // be there. |
425 InitializeBackend(!HasSyncSetupCompleted()); | 425 InitializeBackend(!HasSyncSetupCompleted()); |
426 | 426 |
427 // |backend_| may end up being NULL here in tests (in synchronous | 427 // |backend_| may end up being NULL here in tests (in synchronous |
428 // initialization mode). | 428 // initialization mode). |
429 // | 429 // |
430 // TODO(akalin): Fix this horribly non-intuitive behavior (see | 430 // TODO(akalin): Fix this horribly non-intuitive behavior (see |
431 // http://crbug.com/140354). | 431 // http://crbug.com/140354). |
432 if (backend_.get()) { | 432 if (backend_.get()) { |
433 backend_->UpdateRegisteredInvalidationIds( | 433 backend_->UpdateRegisteredInvalidationIds( |
434 notifier_registrar_.GetAllRegisteredIds()); | 434 invalidator_registrar_.GetAllRegisteredIds()); |
435 } | 435 } |
436 | 436 |
437 if (!sync_global_error_.get()) { | 437 if (!sync_global_error_.get()) { |
438 #if !defined(OS_ANDROID) | 438 #if !defined(OS_ANDROID) |
439 sync_global_error_.reset(new SyncGlobalError(this, signin())); | 439 sync_global_error_.reset(new SyncGlobalError(this, signin())); |
440 #endif | 440 #endif |
441 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( | 441 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( |
442 sync_global_error_.get()); | 442 sync_global_error_.get()); |
443 AddObserver(sync_global_error_.get()); | 443 AddObserver(sync_global_error_.get()); |
444 } | 444 } |
445 } | 445 } |
446 | 446 |
447 void ProfileSyncService::RegisterInvalidationHandler( | 447 void ProfileSyncService::RegisterInvalidationHandler( |
448 syncer::SyncNotifierObserver* handler) { | 448 syncer::InvalidationHandler* handler) { |
449 notifier_registrar_.RegisterHandler(handler); | 449 invalidator_registrar_.RegisterHandler(handler); |
450 } | 450 } |
451 | 451 |
452 void ProfileSyncService::UpdateRegisteredInvalidationIds( | 452 void ProfileSyncService::UpdateRegisteredInvalidationIds( |
453 syncer::SyncNotifierObserver* handler, | 453 syncer::InvalidationHandler* handler, |
454 const syncer::ObjectIdSet& ids) { | 454 const syncer::ObjectIdSet& ids) { |
455 notifier_registrar_.UpdateRegisteredIds(handler, ids); | 455 invalidator_registrar_.UpdateRegisteredIds(handler, ids); |
456 | 456 |
457 // If |backend_| is NULL, its registered IDs will be updated when | 457 // If |backend_| is NULL, its registered IDs will be updated when |
458 // it's created and initialized. | 458 // it's created and initialized. |
459 if (backend_.get()) { | 459 if (backend_.get()) { |
460 backend_->UpdateRegisteredInvalidationIds( | 460 backend_->UpdateRegisteredInvalidationIds( |
461 notifier_registrar_.GetAllRegisteredIds()); | 461 invalidator_registrar_.GetAllRegisteredIds()); |
462 } | 462 } |
463 } | 463 } |
464 | 464 |
465 void ProfileSyncService::UnregisterInvalidationHandler( | 465 void ProfileSyncService::UnregisterInvalidationHandler( |
466 syncer::SyncNotifierObserver* handler) { | 466 syncer::InvalidationHandler* handler) { |
467 notifier_registrar_.UnregisterHandler(handler); | 467 invalidator_registrar_.UnregisterHandler(handler); |
468 } | 468 } |
469 | 469 |
470 void ProfileSyncService::Shutdown() { | 470 void ProfileSyncService::Shutdown() { |
471 ShutdownImpl(false); | 471 ShutdownImpl(false); |
472 } | 472 } |
473 | 473 |
474 void ProfileSyncService::ShutdownImpl(bool sync_disabled) { | 474 void ProfileSyncService::ShutdownImpl(bool sync_disabled) { |
475 // First, we spin down the backend and wait for it to stop syncing completely | 475 // First, we spin down the backend and wait for it to stop syncing completely |
476 // before we Stop the data type manager. This is to avoid a late sync cycle | 476 // before we Stop the data type manager. This is to avoid a late sync cycle |
477 // applying changes to the sync db that wouldn't get applied via | 477 // applying changes to the sync db that wouldn't get applied via |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 // the task that we are going to post, this type would still be disabled. | 653 // the task that we are going to post, this type would still be disabled. |
654 failed_datatypes_handler_.UpdateFailedDatatypes(errors, | 654 failed_datatypes_handler_.UpdateFailedDatatypes(errors, |
655 FailedDatatypesHandler::RUNTIME); | 655 FailedDatatypesHandler::RUNTIME); |
656 | 656 |
657 MessageLoop::current()->PostTask(FROM_HERE, | 657 MessageLoop::current()->PostTask(FROM_HERE, |
658 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, | 658 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, |
659 weak_factory_.GetWeakPtr())); | 659 weak_factory_.GetWeakPtr())); |
660 } | 660 } |
661 | 661 |
662 void ProfileSyncService::OnNotificationsEnabled() { | 662 void ProfileSyncService::OnNotificationsEnabled() { |
663 notifier_registrar_.EmitOnNotificationsEnabled(); | 663 invalidator_registrar_.EmitOnNotificationsEnabled(); |
664 } | 664 } |
665 | 665 |
666 void ProfileSyncService::OnNotificationsDisabled( | 666 void ProfileSyncService::OnNotificationsDisabled( |
667 syncer::NotificationsDisabledReason reason) { | 667 syncer::NotificationsDisabledReason reason) { |
668 notifier_registrar_.EmitOnNotificationsDisabled(reason); | 668 invalidator_registrar_.EmitOnNotificationsDisabled(reason); |
669 } | 669 } |
670 | 670 |
671 void ProfileSyncService::OnIncomingNotification( | 671 void ProfileSyncService::OnIncomingNotification( |
672 const syncer::ObjectIdStateMap& id_state_map, | 672 const syncer::ObjectIdStateMap& id_state_map, |
673 syncer::IncomingNotificationSource source) { | 673 syncer::IncomingNotificationSource source) { |
674 notifier_registrar_.DispatchInvalidationsToHandlers(id_state_map, source); | 674 invalidator_registrar_.DispatchInvalidationsToHandlers(id_state_map, source); |
675 } | 675 } |
676 | 676 |
677 void ProfileSyncService::OnBackendInitialized( | 677 void ProfileSyncService::OnBackendInitialized( |
678 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success) { | 678 const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success) { |
679 is_first_time_sync_configure_ = !HasSyncSetupCompleted(); | 679 is_first_time_sync_configure_ = !HasSyncSetupCompleted(); |
680 | 680 |
681 if (is_first_time_sync_configure_) { | 681 if (is_first_time_sync_configure_) { |
682 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); | 682 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); |
683 } else { | 683 } else { |
684 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); | 684 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1808 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 1808 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
1809 ProfileSyncService* old_this = this; | 1809 ProfileSyncService* old_this = this; |
1810 this->~ProfileSyncService(); | 1810 this->~ProfileSyncService(); |
1811 new(old_this) ProfileSyncService( | 1811 new(old_this) ProfileSyncService( |
1812 new ProfileSyncComponentsFactoryImpl(profile, | 1812 new ProfileSyncComponentsFactoryImpl(profile, |
1813 CommandLine::ForCurrentProcess()), | 1813 CommandLine::ForCurrentProcess()), |
1814 profile, | 1814 profile, |
1815 signin, | 1815 signin, |
1816 behavior); | 1816 behavior); |
1817 } | 1817 } |
OLD | NEW |