| 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 818d57947bbcd06e9666ed09d0c9329e5b103e13..ecc708fc0e46aba5b5f85f19c1a7a411e58c390b 100644
|
| --- a/chrome/browser/sync/profile_sync_service.cc
|
| +++ b/chrome/browser/sync/profile_sync_service.cc
|
| @@ -65,6 +65,7 @@
|
| #include "google_apis/gaia/gaia_constants.h"
|
| #include "grit/generated_resources.h"
|
| #include "net/cookies/cookie_monster.h"
|
| +#include "net/url_request/url_request_context_getter.h"
|
| #include "sync/api/sync_error.h"
|
| #include "sync/internal_api/public/configure_reason.h"
|
| #include "sync/internal_api/public/sync_encryption_handler.h"
|
| @@ -72,8 +73,6 @@
|
| #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/notifier/invalidator_state.h"
|
| #include "sync/util/cryptographer.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
|
|
| @@ -144,7 +143,6 @@ ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory,
|
| profile_(profile),
|
| // |profile| may be NULL in unit tests.
|
| sync_prefs_(profile_ ? profile_->GetPrefs() : NULL),
|
| - invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL),
|
| sync_service_url_(kDevServerUrl),
|
| data_type_requested_sync_startup_(false),
|
| is_first_time_sync_configure_(false),
|
| @@ -160,8 +158,7 @@ ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory,
|
| auto_start_enabled_(start_behavior == AUTO_START),
|
| failed_datatypes_handler_(this),
|
| configure_status_(DataTypeManager::UNKNOWN),
|
| - setup_in_progress_(false),
|
| - invalidator_state_(syncer::DEFAULT_INVALIDATION_ERROR) {
|
| + setup_in_progress_(false) {
|
| // By default, dev, canary, and unbranded Chromium users will go to the
|
| // development servers. Development servers have more features than standard
|
| // sync servers. Users with officially-branded Chrome stable and beta builds
|
| @@ -218,9 +215,6 @@ bool ProfileSyncService::ShouldEnablePasswordSyncForAndroid() const {
|
| #endif
|
|
|
| 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
|
| @@ -475,8 +469,7 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
|
| void ProfileSyncService::CreateBackend() {
|
| backend_.reset(
|
| new SyncBackendHost(profile_->GetDebugName(),
|
| - profile_, sync_prefs_.AsWeakPtr(),
|
| - invalidator_storage_.AsWeakPtr()));
|
| + profile_, sync_prefs_.AsWeakPtr()));
|
| }
|
|
|
| bool ProfileSyncService::IsEncryptedDatatypeEnabled() const {
|
| @@ -605,79 +598,9 @@ void ProfileSyncService::StartUpSlowBackendComponents() {
|
| // we'll want to start from a fresh SyncDB, so delete any old one that might
|
| // be there.
|
| InitializeBackend(!HasSyncSetupCompleted());
|
| -
|
| - // |backend_| may end up being NULL here in tests (in synchronous
|
| - // initialization mode).
|
| - //
|
| - // TODO(akalin): Fix this horribly non-intuitive behavior (see
|
| - // http://crbug.com/140354).
|
| - if (backend_) {
|
| - backend_->UpdateRegisteredInvalidationIds(
|
| - invalidator_registrar_->GetAllRegisteredIds());
|
| - for (AckHandleReplayQueue::const_iterator it = ack_replay_queue_.begin();
|
| - it != ack_replay_queue_.end(); ++it) {
|
| - backend_->AcknowledgeInvalidation(it->first, it->second);
|
| - }
|
| - ack_replay_queue_.clear();
|
| - }
|
| -}
|
| -
|
| -void ProfileSyncService::RegisterInvalidationHandler(
|
| - syncer::InvalidationHandler* handler) {
|
| - invalidator_registrar_->RegisterHandler(handler);
|
| -}
|
| -
|
| -void ProfileSyncService::UpdateRegisteredInvalidationIds(
|
| - syncer::InvalidationHandler* handler,
|
| - const syncer::ObjectIdSet& ids) {
|
| - invalidator_registrar_->UpdateRegisteredIds(handler, ids);
|
| -
|
| - // If |backend_| is NULL, its registered IDs will be updated when
|
| - // it's created and initialized.
|
| - if (backend_) {
|
| - backend_->UpdateRegisteredInvalidationIds(
|
| - invalidator_registrar_->GetAllRegisteredIds());
|
| - }
|
| -}
|
| -
|
| -void ProfileSyncService::UnregisterInvalidationHandler(
|
| - syncer::InvalidationHandler* handler) {
|
| - invalidator_registrar_->UnregisterHandler(handler);
|
| -}
|
| -
|
| -void ProfileSyncService::AcknowledgeInvalidation(
|
| - const invalidation::ObjectId& id,
|
| - const syncer::AckHandle& ack_handle) {
|
| - if (backend_) {
|
| - backend_->AcknowledgeInvalidation(id, ack_handle);
|
| - } else {
|
| - // If |backend_| is NULL, save the acknowledgements to replay when
|
| - // it's created and initialized.
|
| - ack_replay_queue_.push_back(std::make_pair(id, ack_handle));
|
| - }
|
| -}
|
| -
|
| -syncer::InvalidatorState ProfileSyncService::GetInvalidatorState() const {
|
| - return invalidator_registrar_->GetInvalidatorState();
|
| -}
|
| -
|
| -void ProfileSyncService::EmitInvalidationForTest(
|
| - const invalidation::ObjectId& id,
|
| - const std::string& payload) {
|
| - syncer::ObjectIdSet notify_ids;
|
| - notify_ids.insert(id);
|
| -
|
| - const syncer::ObjectIdInvalidationMap& invalidation_map =
|
| - ObjectIdSetToInvalidationMap(notify_ids, payload);
|
| - OnIncomingInvalidation(invalidation_map);
|
| }
|
|
|
| void ProfileSyncService::Shutdown() {
|
| - DCHECK(invalidator_registrar_.get());
|
| - // Reset |invalidator_registrar_| first so that ShutdownImpl cannot
|
| - // use it.
|
| - invalidator_registrar_.reset();
|
| -
|
| if (signin_)
|
| signin_->signin_global_error()->RemoveProvider(this);
|
|
|
| @@ -732,9 +655,6 @@ void ProfileSyncService::ShutdownImpl(bool sync_disabled) {
|
| expect_sync_configuration_aborted_ = false;
|
| is_auth_in_progress_ = false;
|
| backend_initialized_ = false;
|
| - // NULL if we're called from Shutdown().
|
| - if (invalidator_registrar_)
|
| - UpdateInvalidatorRegistrarState();
|
| cached_passphrase_.clear();
|
| encryption_pending_ = false;
|
| encrypt_everything_ = false;
|
| @@ -757,7 +677,6 @@ void ProfileSyncService::DisableForUser() {
|
| // Clear prefs (including SyncSetupHasCompleted) before shutting down so
|
| // PSS clients don't think we're set up while we're shutting down.
|
| sync_prefs_.ClearPreferences();
|
| - invalidator_storage_.Clear();
|
| ClearUnrecoverableError();
|
| ShutdownImpl(true);
|
| NotifyObservers();
|
| @@ -784,6 +703,12 @@ void ProfileSyncService::NotifyObservers() {
|
| "onServiceStateChanged", JsEventDetails());
|
| }
|
|
|
| +void ProfileSyncService::NotifySyncCycleCompleted() {
|
| + FOR_EACH_OBSERVER(Observer, observers_, OnSyncCycleCompleted());
|
| + sync_js_controller_.HandleJsEvent(
|
| + "onServiceStateChanged", JsEventDetails());
|
| +}
|
| +
|
| void ProfileSyncService::ClearStaleErrors() {
|
| ClearUnrecoverableError();
|
| last_actionable_error_ = SyncProtocolError();
|
| @@ -869,17 +794,6 @@ void ProfileSyncService::DisableBrokenDatatype(
|
| weak_factory_.GetWeakPtr()));
|
| }
|
|
|
| -void ProfileSyncService::OnInvalidatorStateChange(
|
| - syncer::InvalidatorState state) {
|
| - invalidator_state_ = state;
|
| - UpdateInvalidatorRegistrarState();
|
| -}
|
| -
|
| -void ProfileSyncService::OnIncomingInvalidation(
|
| - const syncer::ObjectIdInvalidationMap& invalidation_map) {
|
| - invalidator_registrar_->DispatchInvalidationsToHandlers(invalidation_map);
|
| -}
|
| -
|
| void ProfileSyncService::OnBackendInitialized(
|
| const syncer::WeakHandle<syncer::JsBackend>& js_backend,
|
| const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
|
| @@ -923,7 +837,6 @@ void ProfileSyncService::OnBackendInitialized(
|
| }
|
|
|
| backend_initialized_ = true;
|
| - UpdateInvalidatorRegistrarState();
|
|
|
| sync_js_controller_.AttachJsBackend(js_backend);
|
| debug_info_listener_ = debug_info_listener;
|
| @@ -972,7 +885,7 @@ void ProfileSyncService::OnSyncCycleCompleted() {
|
| GetSessionModelAssociator()->AsWeakPtr()));
|
| }
|
| DVLOG(2) << "Notifying observers sync cycle completed";
|
| - NotifyObservers();
|
| + NotifySyncCycleCompleted();
|
| }
|
|
|
| void ProfileSyncService::OnExperimentsChanged(
|
| @@ -2089,17 +2002,6 @@ void ProfileSyncService::OnInternalUnrecoverableError(
|
| OnUnrecoverableErrorImpl(from_here, message, delete_sync_database);
|
| }
|
|
|
| -void ProfileSyncService::UpdateInvalidatorRegistrarState() {
|
| - const syncer::InvalidatorState effective_state =
|
| - backend_initialized_ ?
|
| - invalidator_state_ : syncer::TRANSIENT_INVALIDATION_ERROR;
|
| - DVLOG(1) << "New invalidator state: "
|
| - << syncer::InvalidatorStateToString(invalidator_state_)
|
| - << ", effective state: "
|
| - << syncer::InvalidatorStateToString(effective_state);
|
| - invalidator_registrar_->UpdateInvalidatorState(effective_state);
|
| -}
|
| -
|
| std::string ProfileSyncService::GetEffectiveUsername() {
|
| #if defined(ENABLE_MANAGED_USERS)
|
| if (ManagedUserService::ProfileIsManaged(profile_)) {
|
| @@ -2110,4 +2012,3 @@ std::string ProfileSyncService::GetEffectiveUsername() {
|
|
|
| return signin_->GetAuthenticatedUsername();
|
| }
|
| -
|
|
|