| 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 backend_->UpdateRegisteredInvalidationIds( | 460 backend_->UpdateRegisteredInvalidationIds( |
| 461 invalidator_registrar_.GetAllRegisteredIds()); | 461 invalidator_registrar_.GetAllRegisteredIds()); |
| 462 } | 462 } |
| 463 } | 463 } |
| 464 | 464 |
| 465 void ProfileSyncService::UnregisterInvalidationHandler( | 465 void ProfileSyncService::UnregisterInvalidationHandler( |
| 466 syncer::InvalidationHandler* handler) { | 466 syncer::InvalidationHandler* handler) { |
| 467 invalidator_registrar_.UnregisterHandler(handler); | 467 invalidator_registrar_.UnregisterHandler(handler); |
| 468 } | 468 } |
| 469 | 469 |
| 470 syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const { |
| 471 return invalidator_registrar_.GetInvalidatorState(); |
| 472 } |
| 473 |
| 470 void ProfileSyncService::Shutdown() { | 474 void ProfileSyncService::Shutdown() { |
| 471 ShutdownImpl(false); | 475 ShutdownImpl(false); |
| 472 } | 476 } |
| 473 | 477 |
| 474 void ProfileSyncService::ShutdownImpl(bool sync_disabled) { | 478 void ProfileSyncService::ShutdownImpl(bool sync_disabled) { |
| 475 // First, we spin down the backend and wait for it to stop syncing completely | 479 // 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 | 480 // 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 | 481 // applying changes to the sync db that wouldn't get applied via |
| 478 // ChangeProcessors, leading to back-from-the-dead bugs. | 482 // ChangeProcessors, leading to back-from-the-dead bugs. |
| 479 base::Time shutdown_start_time = base::Time::Now(); | 483 base::Time shutdown_start_time = base::Time::Now(); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 // Update this before posting a task. So if a configure happens before | 656 // Update this before posting a task. So if a configure happens before |
| 653 // the task that we are going to post, this type would still be disabled. | 657 // the task that we are going to post, this type would still be disabled. |
| 654 failed_datatypes_handler_.UpdateFailedDatatypes(errors, | 658 failed_datatypes_handler_.UpdateFailedDatatypes(errors, |
| 655 FailedDatatypesHandler::RUNTIME); | 659 FailedDatatypesHandler::RUNTIME); |
| 656 | 660 |
| 657 MessageLoop::current()->PostTask(FROM_HERE, | 661 MessageLoop::current()->PostTask(FROM_HERE, |
| 658 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, | 662 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, |
| 659 weak_factory_.GetWeakPtr())); | 663 weak_factory_.GetWeakPtr())); |
| 660 } | 664 } |
| 661 | 665 |
| 662 void ProfileSyncService::OnNotificationsEnabled() { | 666 void ProfileSyncService::OnInvalidatorStateChange( |
| 663 invalidator_registrar_.EmitOnNotificationsEnabled(); | 667 syncer::InvalidatorState state) { |
| 668 invalidator_registrar_.UpdateInvalidatorState(state); |
| 664 } | 669 } |
| 665 | 670 |
| 666 void ProfileSyncService::OnNotificationsDisabled( | 671 void ProfileSyncService::OnIncomingInvalidation( |
| 667 syncer::NotificationsDisabledReason reason) { | |
| 668 invalidator_registrar_.EmitOnNotificationsDisabled(reason); | |
| 669 } | |
| 670 | |
| 671 void ProfileSyncService::OnIncomingNotification( | |
| 672 const syncer::ObjectIdStateMap& id_state_map, | 672 const syncer::ObjectIdStateMap& id_state_map, |
| 673 syncer::IncomingNotificationSource source) { | 673 syncer::IncomingInvalidationSource source) { |
| 674 invalidator_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 { |
| (...skipping 1124 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 |