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 2d8bbd30de02708ec60e8d19baa8b4ca14e26c1b..12dccb0a4c163190e59d3e93fe5069d089d8c049 100644 |
--- a/chrome/browser/sync/profile_sync_service.cc |
+++ b/chrome/browser/sync/profile_sync_service.cc |
@@ -63,6 +63,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" |
@@ -70,8 +71,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" |
@@ -138,7 +137,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), |
is_first_time_sync_configure_(false), |
backend_initialized_(false), |
@@ -153,8 +151,7 @@ ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory, |
auto_start_enabled_(start_behavior == AUTO_START), |
failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(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 |
@@ -207,9 +204,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 |
@@ -442,8 +436,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 { |
@@ -533,79 +526,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_.get()) { |
- 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_.get()) { |
- 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_.get()) { |
- 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); |
@@ -659,9 +582,7 @@ 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_.get()) |
- UpdateInvalidatorRegistrarState(); |
+ |
cached_passphrase_.clear(); |
encryption_pending_ = false; |
encrypt_everything_ = false; |
@@ -683,7 +604,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(); |
@@ -710,6 +630,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(); |
@@ -793,17 +719,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>& |
@@ -848,7 +763,6 @@ void ProfileSyncService::OnBackendInitialized( |
} |
backend_initialized_ = true; |
- UpdateInvalidatorRegistrarState(); |
sync_js_controller_.AttachJsBackend(js_backend); |
debug_info_listener_ = debug_info_listener; |
@@ -894,7 +808,7 @@ void ProfileSyncService::OnSyncCycleCompleted() { |
GetSessionModelAssociator()->AsWeakPtr())); |
} |
DVLOG(2) << "Notifying observers sync cycle completed"; |
- NotifyObservers(); |
+ NotifySyncCycleCompleted(); |
} |
void ProfileSyncService::OnExperimentsChanged( |
@@ -2003,17 +1917,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); |
-} |
- |
void ProfileSyncService::ResetForTest() { |
Profile* profile = profile_; |
SigninManager* signin = SigninManagerFactory::GetForProfile(profile); |