summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-30 04:37:48 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-30 04:37:48 +0000
commit62c28b9b77bb585b190ec8afaef43d5bcb764c79 (patch)
tree0081e6a5f3f5c3822929355cf6ef41b955c78d9b
parente841d0622eb6119d407d4acf4eeb6402c7c49ea8 (diff)
downloadchromium_src-62c28b9b77bb585b190ec8afaef43d5bcb764c79.zip
chromium_src-62c28b9b77bb585b190ec8afaef43d5bcb764c79.tar.gz
chromium_src-62c28b9b77bb585b190ec8afaef43d5bcb764c79.tar.bz2
Make SyncBackendRegistrar aware of loaded data
Adds a parameter to the SyncManager::Initialize() callback to inform the caller which sync data types were successfully loaded from disk. This allows the SyncBackendHost and related classes make better decisions during initialization. If necessary, the SyncBackendHost will send a configure request to the syncer during early initialization asking it to download the nigori node. Now we can guarantee that the node will be available by the type ProfileSyncService::OnBackendInitialized() is called. The SyncBackendHost test expectations had to be amended to account for this test. Most of the changes are related to the fact that our behaviour no longer depends on the SyncPrefs. The ProfileSyncService*Tests were very much affected by this change. Those tests are parameterized with a callback that is used to initialize the sync DB and pretend that it had been loaded from disk. Previously, this callback would be executed later on during initialization, around the time of ProfileSyncService::OnBackendInitialize(). That approach was incompatible with this change, which requires that we have access to the fully initialized database around the time we return from SyncBackendHost::Initialize(). The callback had to be moved, which meant that it now required an explicit UserShare parameter, which meant that a lot of call sites had to be updated. BUG=129825 TEST= Review URL: https://chromiumcodereview.appspot.com/10804039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148926 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc133
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.h13
-rw-r--r--chrome/browser/sync/glue/sync_backend_host_unittest.cc89
-rw-r--r--chrome/browser/sync/glue/sync_backend_registrar.cc41
-rw-r--r--chrome/browser/sync/glue/sync_backend_registrar.h14
-rw-r--r--chrome/browser/sync/glue/sync_backend_registrar_unittest.cc15
-rw-r--r--chrome/browser/sync/profile_sync_service.cc9
-rw-r--r--chrome/browser/sync/test_profile_sync_service.cc103
-rw-r--r--chrome/browser/sync/test_profile_sync_service.h31
-rw-r--r--sync/engine/sync_scheduler_unittest.cc3
-rw-r--r--sync/engine/sync_scheduler_whitebox_unittest.cc2
-rw-r--r--sync/engine/syncer_unittest.cc3
-rw-r--r--sync/internal_api/debug_info_event_listener.cc2
-rw-r--r--sync/internal_api/debug_info_event_listener.h4
-rw-r--r--sync/internal_api/internal_components_factory_impl.cc8
-rw-r--r--sync/internal_api/js_sync_manager_observer.cc8
-rw-r--r--sync/internal_api/js_sync_manager_observer.h3
-rw-r--r--sync/internal_api/js_sync_manager_observer_unittest.cc21
-rw-r--r--sync/internal_api/public/internal_components_factory.h1
-rw-r--r--sync/internal_api/public/internal_components_factory_impl.h1
-rw-r--r--sync/internal_api/public/sync_manager.h5
-rw-r--r--sync/internal_api/public/test/fake_sync_manager.h1
-rw-r--r--sync/internal_api/public/test/test_internal_components_factory.h1
-rw-r--r--sync/internal_api/sync_manager_impl.cc144
-rw-r--r--sync/internal_api/sync_manager_impl.h10
-rw-r--r--sync/internal_api/syncapi_unittest.cc10
-rw-r--r--sync/internal_api/test/fake_sync_manager.cc6
-rw-r--r--sync/internal_api/test/test_internal_components_factory.cc8
-rw-r--r--sync/sessions/sync_session_context.cc2
-rw-r--r--sync/sessions/sync_session_context.h1
-rw-r--r--sync/sessions/sync_session_unittest.cc27
-rw-r--r--sync/test/engine/syncer_command_test.h2
-rw-r--r--sync/tools/sync_client.cc1
33 files changed, 385 insertions, 337 deletions
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index 56f76b4..295bb8c 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -91,7 +91,8 @@ class SyncBackendHost::Core
const syncer::sessions::SyncSessionSnapshot& snapshot) OVERRIDE;
virtual void OnInitializationComplete(
const syncer::WeakHandle<syncer::JsBackend>& js_backend,
- bool success) OVERRIDE;
+ bool success,
+ syncer::ModelTypeSet restored_types) OVERRIDE;
virtual void OnConnectionStatusChange(
syncer::ConnectionStatus status) OVERRIDE;
virtual void OnPassphraseRequired(
@@ -369,7 +370,6 @@ void SyncBackendHost::Initialize(
SyncFrontend* frontend,
const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
const GURL& sync_service_url,
- syncer::ModelTypeSet initial_types,
const SyncCredentials& credentials,
bool delete_sync_data_folder,
syncer::SyncManagerFactory* sync_manager_factory,
@@ -386,14 +386,7 @@ void SyncBackendHost::Initialize(
frontend_ = frontend;
DCHECK(frontend);
- syncer::ModelTypeSet initial_types_with_nigori(initial_types);
- CHECK(sync_prefs_.get());
- if (sync_prefs_->HasSyncSetupCompleted()) {
- initial_types_with_nigori.Put(syncer::NIGORI);
- }
-
- registrar_.reset(new SyncBackendRegistrar(initial_types_with_nigori,
- name_,
+ registrar_.reset(new SyncBackendRegistrar(name_,
profile_,
sync_thread_.message_loop()));
syncer::ModelSafeRoutingInfo routing_info;
@@ -601,6 +594,14 @@ void SyncBackendHost::ConfigureDataTypes(
NigoriState nigori_state,
const base::Callback<void(syncer::ModelTypeSet)>& ready_task,
const base::Callback<void()>& retry_callback) {
+ // Only one configure is allowed at a time. This is guaranteed by our
+ // callers. The SyncBackendHost requests one configure as the backend is
+ // initializing and waits for it to complete. After initialization, all
+ // configurations will pass through the DataTypeManager, which is careful to
+ // never send a new configure request until the current request succeeds.
+
+ DCHECK_GT(initialization_state_, NOT_INITIALIZED);
+
syncer::ModelTypeSet types_to_add_with_nigori = types_to_add;
syncer::ModelTypeSet types_to_remove_with_nigori = types_to_remove;
if (nigori_state == WITH_NIGORI) {
@@ -610,53 +611,61 @@ void SyncBackendHost::ConfigureDataTypes(
types_to_add_with_nigori.Remove(syncer::NIGORI);
types_to_remove_with_nigori.Put(syncer::NIGORI);
}
- // Only one configure is allowed at a time (DataTypeManager handles user
- // changes that happen while the syncer is reconfiguring, and will only
- // trigger another call to ConfigureDataTypes once the current reconfiguration
- // completes).
- DCHECK_GT(initialization_state_, NOT_INITIALIZED);
- // The new set of enabled types is types_to_add_with_nigori + the
- // previously enabled types (on restart, the preferred types are already
- // enabled) - types_to_remove_with_nigori. After reconfiguring the registrar,
- // the new routing info will reflect the set of enabled types.
+ // The SyncBackendRegistrar's routing info will be updated by adding the
+ // types_to_add_with_nigori to the list then removing
+ // types_to_remove_with_nigori. Any types which are not in either of those
+ // sets will remain untouched.
+ //
+ // Types which were not in the list previously are not fully downloaded, so we
+ // must ask the syncer to download them. Any newly supported datatypes will
+ // not have been in that routing info list, so they will be among the types
+ // downloaded if they are enabled.
+ //
+ // The SyncBackendRegistrar's state was initially derived from the types
+ // marked initial_sync_ended when the sync database was loaded. Afterwards it
+ // is modified only by this function. We expect it to remain in sync with the
+ // backend because configuration requests are never aborted; they are retried
+ // until they succeed or the browser is closed.
+
+ syncer::ModelTypeSet types_to_download = registrar_->ConfigureDataTypes(
+ types_to_add_with_nigori, types_to_remove_with_nigori);
+ if (!types_to_download.Empty())
+ types_to_download.Put(syncer::NIGORI);
+
+ // TODO(sync): crbug.com/137550.
+ // It's dangerous to configure types that have progress markers. Types with
+ // progress markers can trigger a MIGRATION_DONE response. We are not
+ // prepared to handle a migration during a configure, so we must ensure that
+ // all our types_to_download actually contain no data before we sync them.
+ //
+ // The most common way to end up in this situation used to be types which had
+ // !initial_sync_ended, but did have some progress markers. We avoid problems
+ // with those types by purging the data of any such partially synced types
+ // soon after we load the directory.
+ //
+ // Another possible scenario is that we have newly supported or newly enabled
+ // data types being downloaded here but the nigori type, which is always
+ // included in any GetUpdates request, requires migration. The server has
+ // code to detect this scenario based on the configure reason, the fact that
+ // the nigori type is the only requested type which requires migration, and
+ // that the requested types list includes at least one non-nigori type. It
+ // will not send a MIGRATION_DONE response in that case. We still need to be
+ // careful to not send progress markers for non-nigori types, though. If a
+ // non-nigori type in the request requires migration, a MIGRATION_DONE
+ // response will be sent.
+
syncer::ModelSafeRoutingInfo routing_info;
- registrar_->ConfigureDataTypes(types_to_add_with_nigori,
- types_to_remove_with_nigori);
registrar_->GetModelSafeRoutingInfo(&routing_info);
- const syncer::ModelTypeSet enabled_types =
- GetRoutingInfoTypes(routing_info);
-
- // Figure out which types need to actually be downloaded. We pass those on
- // to the syncer while it's in configuration mode so that they can be
- // downloaded before we perform association. Once we switch to normal mode
- // downloads will get applied normally and hit the datatype's change
- // processor.
- // A datatype is in need of downloading if any of the following are true:
- // 1. it's enabled and initial_sync_ended is false (initial_sync_ended is
- // set after applying updates, and hence is a more conservative measure
- // than having a non-empty progress marker, which is set during
- // StoreTimestamps).
- // 2. the type is NIGORI, and any other datatype is being downloaded (nigori
- // is always included if we download a datatype).
- // TODO(sync): consider moving this logic onto the sync thread (perhaps
- // as part of SyncManager::ConfigureSyncer).
- syncer::ModelTypeSet initial_sync_ended_types =
- core_->sync_manager()->InitialSyncEndedTypes();
- initial_sync_ended_types.RetainAll(enabled_types);
- syncer::ModelTypeSet types_to_config =
- Difference(enabled_types, initial_sync_ended_types);
- if (!types_to_config.Empty() && enabled_types.Has(syncer::NIGORI))
- types_to_config.Put(syncer::NIGORI);
SDVLOG(1) << "Types "
- << syncer::ModelTypeSetToString(types_to_config)
+ << syncer::ModelTypeSetToString(types_to_download)
<< " added; calling DoConfigureSyncer";
// TODO(zea): figure out how to bypass this call if no types are being
// configured and GetKey is not needed. For now we rely on determining the
// need for GetKey as part of the SyncManager::ConfigureSyncer logic.
RequestConfigureSyncer(reason,
- types_to_config,
+ types_to_download,
routing_info,
ready_task,
retry_callback);
@@ -679,7 +688,6 @@ void SyncBackendHost::DeactivateDataType(syncer::ModelType type) {
}
syncer::UserShare* SyncBackendHost::GetUserShare() const {
- DCHECK(initialized());
return core_->sync_manager()->GetUserShare();
}
@@ -756,6 +764,13 @@ void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop(
ready_task.Run(failed_configuration_types);
}
+void SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop(
+ const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success,
+ syncer::ModelTypeSet restored_types) {
+ registrar_->SetInitialTypes(restored_types);
+ HandleInitializationCompletedOnFrontendLoop(js_backend, success);
+}
+
SyncBackendHost::DoInitializeOptions::DoInitializeOptions(
MessageLoop* sync_loop,
SyncBackendRegistrar* registrar,
@@ -828,12 +843,13 @@ void SyncBackendHost::Core::OnSyncCycleCompleted(
void SyncBackendHost::Core::OnInitializationComplete(
const syncer::WeakHandle<syncer::JsBackend>& js_backend,
- bool success) {
+ bool success,
+ const syncer::ModelTypeSet restored_types) {
DCHECK_EQ(MessageLoop::current(), sync_loop_);
host_.Call(
FROM_HERE,
- &SyncBackendHost::HandleInitializationCompletedOnFrontendLoop,
- js_backend, success);
+ &SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop,
+ js_backend, success, restored_types);
if (success) {
// Initialization is complete, so we can schedule recurring SaveChanges.
@@ -968,7 +984,6 @@ void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) {
options.service_url.SchemeIsSecure(),
BrowserThread::GetBlockingPool(),
options.make_http_bridge_factory_fn.Run().Pass(),
- options.routing_info,
options.workers,
options.extensions_activity_monitor,
options.registrar /* as SyncManager::ChangeDelegate */,
@@ -1167,17 +1182,15 @@ void SyncBackendHost::HandleInitializationCompletedOnFrontendLoop(
return;
}
- // If setup has completed, start off in DOWNLOADING_NIGORI so that
- // we start off by refreshing nigori.
- CHECK(sync_prefs_.get());
- if (sync_prefs_->HasSyncSetupCompleted() &&
- initialization_state_ < DOWNLOADING_NIGORI) {
- initialization_state_ = DOWNLOADING_NIGORI;
- }
-
// Run initialization state machine.
switch (initialization_state_) {
case NOT_INITIALIZED:
+ // This configuration should result in a download request if the nigori
+ // type's initial_sync_ended bit is unset. If the download request
+ // contains progress markers, there is a risk that the server will try to
+ // trigger migration. That would be disastrous, so we must rely on the
+ // sync manager to ensure that this type never has both progress markers
+ // and !initial_sync_ended.
initialization_state_ = DOWNLOADING_NIGORI;
ConfigureDataTypes(
syncer::CONFIGURE_REASON_NEW_CLIENT,
diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h
index eb362e7..a4b651b 100644
--- a/chrome/browser/sync/glue/sync_backend_host.h
+++ b/chrome/browser/sync/glue/sync_backend_host.h
@@ -43,8 +43,6 @@ class ChangeProcessor;
class ChromeSyncNotificationBridge;
struct Experiments;
class InvalidatorStorage;
-class JsBackend;
-class JsEventHandler;
class SyncBackendRegistrar;
class SyncPrefs;
@@ -170,7 +168,6 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
SyncFrontend* frontend,
const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
const GURL& service_url,
- syncer::ModelTypeSet initial_types,
const syncer::SyncCredentials& credentials,
bool delete_sync_data_folder,
syncer::SyncManagerFactory* sync_manager_factory,
@@ -246,8 +243,9 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
// Deactivates change processing for the given data type.
void DeactivateDataType(syncer::ModelType type);
- // Called on |frontend_loop_| to obtain a handle to the UserShare needed
- // for creating transactions.
+ // Called on |frontend_loop_| to obtain a handle to the UserShare needed for
+ // creating transactions. Should not be called before we signal
+ // initialization is complete with OnBackendInitialized().
syncer::UserShare* GetUserShare() const;
// Called from any thread to obtain current status information in detailed or
@@ -344,6 +342,11 @@ class SyncBackendHost : public BackendDataTypeConfigurer {
const syncer::ModelTypeSet failed_configuration_types,
const base::Callback<void(syncer::ModelTypeSet)>& ready_task);
+ // Called when the SyncManager has been constructed and initialized.
+ virtual void HandleSyncManagerInitializationOnFrontendLoop(
+ const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success,
+ syncer::ModelTypeSet restored_types);
+
private:
// The real guts of SyncBackendHost, to keep the public client API clean.
class Core;
diff --git a/chrome/browser/sync/glue/sync_backend_host_unittest.cc b/chrome/browser/sync/glue/sync_backend_host_unittest.cc
index 57d30eb..dcaddef 100644
--- a/chrome/browser/sync/glue/sync_backend_host_unittest.cc
+++ b/chrome/browser/sync/glue/sync_backend_host_unittest.cc
@@ -149,13 +149,12 @@ class SyncBackendHostTest : public testing::Test {
}
// Synchronously initializes the backend.
- void InitializeBackend(syncer::ModelTypeSet enabled_types) {
+ void InitializeBackend() {
EXPECT_CALL(mock_frontend_, OnBackendInitialized(_, true)).
WillOnce(InvokeWithoutArgs(QuitMessageLoop));
backend_->Initialize(&mock_frontend_,
syncer::WeakHandle<syncer::JsEventHandler>(),
GURL(""),
- enabled_types,
credentials_,
true,
&fake_sync_manager_factory_,
@@ -211,26 +210,22 @@ class SyncBackendHostTest : public testing::Test {
// Test basic initialization with no initial types (first time initialization).
// Only the nigori should be configured.
TEST_F(SyncBackendHostTest, InitShutdown) {
- InitializeBackend(syncer::ModelTypeSet());
+ InitializeBackend();
EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals(
syncer::ModelTypeSet(syncer::NIGORI)));
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(
syncer::ModelTypeSet(syncer::NIGORI)));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(
- syncer::ModelTypeSet(syncer::NIGORI)));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
syncer::ModelTypeSet(syncer::NIGORI)).Empty());
}
// Test first time sync scenario. All types should be properly configured.
TEST_F(SyncBackendHostTest, FirstTimeSync) {
- InitializeBackend(syncer::ModelTypeSet());
+ InitializeBackend();
EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals(
syncer::ModelTypeSet(syncer::NIGORI)));
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(
syncer::ModelTypeSet(syncer::NIGORI)));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(
- syncer::ModelTypeSet(syncer::NIGORI)));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
syncer::ModelTypeSet(syncer::NIGORI)).Empty());
@@ -253,12 +248,11 @@ TEST_F(SyncBackendHostTest, Restart) {
syncer::ModelTypeSet all_but_nigori = enabled_types_;
fake_manager_->set_progress_marker_types(enabled_types_);
fake_manager_->set_initial_sync_ended_types(enabled_types_);
- InitializeBackend(enabled_types_);
+ InitializeBackend();
EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty());
EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
enabled_types_).Empty());
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Empty());
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
enabled_types_).Empty());
@@ -287,20 +281,19 @@ TEST_F(SyncBackendHostTest, PartialTypes) {
fake_manager_->set_progress_marker_types(enabled_types_);
fake_manager_->set_initial_sync_ended_types(full_types);
- // All partial types should have been purged with nothing downloaded as part
- // of bringing up the backend.
- InitializeBackend(enabled_types_);
- EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty());
- EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
- enabled_types_).Empty());
+ // Bringing up the backend should purge all partial types, then proceed to
+ // download the Nigori.
+ InitializeBackend();
+ EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals(
+ syncer::ModelTypeSet(syncer::NIGORI)));
+ EXPECT_TRUE(fake_manager_->GetAndResetCleanedTypes().HasAll(partial_types));
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(
- full_types));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Empty());
+ Union(full_types, syncer::ModelTypeSet(syncer::NIGORI))));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
- enabled_types_).Equals(partial_types));
+ enabled_types_).Equals(
+ Difference(partial_types, syncer::ModelTypeSet(syncer::NIGORI))));
- // Now do the actual configuration, which should download and apply both
- // nigori and bookmarks.
+ // Now do the actual configuration, which should download and apply bookmarks.
ConfigureDataTypes(enabled_types_,
Difference(syncer::ModelTypeSet::All(),
enabled_types_),
@@ -319,16 +312,20 @@ TEST_F(SyncBackendHostTest, PartialTypes) {
// enabled, we should re-download all of them because we lost their data.
TEST_F(SyncBackendHostTest, LostDB) {
sync_prefs_->SetSyncSetupCompleted();
- // Don't set any progress marker or initial_sync_ended types before
- // initializing. Initialization should not affect the datatypes.
- InitializeBackend(enabled_types_);
- EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty());
- EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
- enabled_types_).Empty());
- EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Empty());
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Empty());
+ // Initialization should fetch the Nigori node. Everything else should be
+ // left untouched.
+ InitializeBackend();
+ EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals(
+ syncer::ModelTypeSet(syncer::NIGORI)));
+ EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(
+ syncer::ModelTypeSet(syncer::NIGORI)));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
- enabled_types_).Equals(enabled_types_));
+ enabled_types_).Equals(
+ Difference(enabled_types_, syncer::ModelTypeSet(syncer::NIGORI))));
+
+ // The database was empty, so any cleaning is entirely optional. We want to
+ // reset this value before running the next part of the test, though.
+ fake_manager_->GetAndResetCleanedTypes();
// The actual configuration should redownload and apply all the enabled types.
ConfigureDataTypes(enabled_types_,
@@ -347,7 +344,7 @@ TEST_F(SyncBackendHostTest, LostDB) {
TEST_F(SyncBackendHostTest, DisableTypes) {
// Simulate first time sync.
- InitializeBackend(syncer::ModelTypeSet());
+ InitializeBackend();
fake_manager_->GetAndResetCleanedTypes();
ConfigureDataTypes(enabled_types_,
Difference(syncer::ModelTypeSet::All(),
@@ -358,7 +355,6 @@ TEST_F(SyncBackendHostTest, DisableTypes) {
EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
enabled_types_).Empty());
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(enabled_types_));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
enabled_types_).Empty());
@@ -385,7 +381,7 @@ TEST_F(SyncBackendHostTest, DisableTypes) {
TEST_F(SyncBackendHostTest, AddTypes) {
// Simulate first time sync.
- InitializeBackend(syncer::ModelTypeSet());
+ InitializeBackend();
fake_manager_->GetAndResetCleanedTypes();
ConfigureDataTypes(enabled_types_,
Difference(syncer::ModelTypeSet::All(),
@@ -396,7 +392,6 @@ TEST_F(SyncBackendHostTest, AddTypes) {
EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
enabled_types_).Empty());
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(enabled_types_));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
enabled_types_).Empty());
@@ -424,7 +419,7 @@ TEST_F(SyncBackendHostTest, AddTypes) {
// And and disable in the same configuration.
TEST_F(SyncBackendHostTest, AddDisableTypes) {
// Simulate first time sync.
- InitializeBackend(syncer::ModelTypeSet());
+ InitializeBackend();
fake_manager_->GetAndResetCleanedTypes();
ConfigureDataTypes(enabled_types_,
Difference(syncer::ModelTypeSet::All(),
@@ -435,7 +430,6 @@ TEST_F(SyncBackendHostTest, AddDisableTypes) {
EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
enabled_types_).Empty());
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(enabled_types_));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Equals(enabled_types_));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
enabled_types_).Empty());
@@ -478,12 +472,11 @@ TEST_F(SyncBackendHostTest, NewlySupportedTypes) {
enabled_types_.PutAll(new_types);
// Does nothing.
- InitializeBackend(enabled_types_);
+ InitializeBackend();
EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty());
EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
- enabled_types_).Empty());
+ old_types).Empty());
EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(old_types));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Empty());
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
enabled_types_).Equals(new_types));
@@ -519,15 +512,17 @@ TEST_F(SyncBackendHostTest, NewlySupportedTypesWithPartialTypes) {
syncer::EXTENSION_SETTINGS);
enabled_types_.PutAll(new_types);
- // Purge the partial types.
- InitializeBackend(enabled_types_);
- EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Empty());
- EXPECT_TRUE(Intersection(fake_manager_->GetAndResetCleanedTypes(),
- enabled_types_).Empty());
- EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(full_types));
- EXPECT_TRUE(fake_manager_->GetAndResetEnabledTypes().Empty());
+ // Purge the partial types. The nigori will be among the purged types, but
+ // the syncer will re-download it by the time the initialization is complete.
+ InitializeBackend();
+ EXPECT_TRUE(fake_manager_->GetAndResetDownloadedTypes().Equals(
+ syncer::ModelTypeSet(syncer::NIGORI)));
+ EXPECT_TRUE(fake_manager_->GetAndResetCleanedTypes().HasAll(partial_types));
+ EXPECT_TRUE(fake_manager_->InitialSyncEndedTypes().Equals(
+ syncer::Union(full_types, syncer::ModelTypeSet(syncer::NIGORI))));
EXPECT_TRUE(fake_manager_->GetTypesWithEmptyProgressMarkerToken(
- enabled_types_).Equals(Union(new_types, partial_types)));
+ enabled_types_).Equals(Union(new_types, Difference(
+ partial_types, syncer::ModelTypeSet(syncer::NIGORI)))));
// Downloads and applies the new types and partial types (which includes
// nigori anyways).
diff --git a/chrome/browser/sync/glue/sync_backend_registrar.cc b/chrome/browser/sync/glue/sync_backend_registrar.cc
index 342a3d4..4cd91b7 100644
--- a/chrome/browser/sync/glue/sync_backend_registrar.cc
+++ b/chrome/browser/sync/glue/sync_backend_registrar.cc
@@ -54,7 +54,6 @@ bool IsOnThreadForGroup(syncer::ModelSafeGroup group) {
} // namespace
SyncBackendRegistrar::SyncBackendRegistrar(
- syncer::ModelTypeSet initial_types,
const std::string& name, Profile* profile,
MessageLoop* sync_loop) :
name_(name),
@@ -70,30 +69,42 @@ SyncBackendRegistrar::SyncBackendRegistrar(
workers_[syncer::GROUP_UI] = ui_worker_;
workers_[syncer::GROUP_PASSIVE] = new syncer::PassiveModelWorker(sync_loop_);
- // Any datatypes that we want the syncer to pull down must be in the
- // routing_info map. We set them to group passive, meaning that
- // updates will be applied to sync, but not dispatched to the native
- // models.
- for (syncer::ModelTypeSet::Iterator it = initial_types.First();
- it.Good(); it.Inc()) {
- routing_info_[it.Get()] = syncer::GROUP_PASSIVE;
- }
-
HistoryService* history_service =
HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS);
if (history_service) {
workers_[syncer::GROUP_HISTORY] = new HistoryModelWorker(history_service);
- } else {
- LOG_IF(WARNING, initial_types.Has(syncer::TYPED_URLS))
- << "History store disabled, cannot sync Omnibox History";
- routing_info_.erase(syncer::TYPED_URLS);
}
scoped_refptr<PasswordStore> password_store =
PasswordStoreFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS);
if (password_store.get()) {
workers_[syncer::GROUP_PASSWORD] = new PasswordModelWorker(password_store);
- } else {
+ }
+}
+
+void SyncBackendRegistrar::SetInitialTypes(syncer::ModelTypeSet initial_types) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ base::AutoLock lock(lock_);
+
+ // This function should be called only once, shortly after construction. The
+ // routing info at that point is expected to be emtpy.
+ DCHECK(routing_info_.empty());
+
+ // Set our initial state to reflect the current status of the sync directory.
+ // This will ensure that our calculations in ConfigureDataTypes() will always
+ // return correct results.
+ for (syncer::ModelTypeSet::Iterator it = initial_types.First();
+ it.Good(); it.Inc()) {
+ routing_info_[it.Get()] = syncer::GROUP_PASSIVE;
+ }
+
+ if (!workers_.count(syncer::GROUP_HISTORY)) {
+ LOG_IF(WARNING, initial_types.Has(syncer::TYPED_URLS))
+ << "History store disabled, cannot sync Omnibox History";
+ routing_info_.erase(syncer::TYPED_URLS);
+ }
+
+ if (!workers_.count(syncer::GROUP_PASSWORD)) {
LOG_IF(WARNING, initial_types.Has(syncer::PASSWORDS))
<< "Password store not initialized, cannot sync passwords";
routing_info_.erase(syncer::PASSWORDS);
diff --git a/chrome/browser/sync/glue/sync_backend_registrar.h b/chrome/browser/sync/glue/sync_backend_registrar.h
index 6e1f37f..4f18397 100644
--- a/chrome/browser/sync/glue/sync_backend_registrar.h
+++ b/chrome/browser/sync/glue/sync_backend_registrar.h
@@ -33,15 +33,17 @@ class UIModelWorker;
// events to the right processors.
class SyncBackendRegistrar : public syncer::SyncManager::ChangeDelegate {
public:
- // |initial_types| contains the initial set of types to sync
- // (initially put in the passive group). |name| is used for
- // debugging. Does not take ownership of |profile| or |sync_loop|.
- // Must be created on the UI thread.
- SyncBackendRegistrar(syncer::ModelTypeSet initial_types,
- const std::string& name,
+ // |name| is used for debugging. Does not take ownership of |profile| or
+ // |sync_loop|. Must be created on the UI thread.
+ SyncBackendRegistrar(const std::string& name,
Profile* profile,
MessageLoop* sync_loop);
+ // Informs the SyncBackendRegistrar of the currently enabled set of types.
+ // These types will be placed in the passive group. This function should be
+ // called exactly once during startup.
+ void SetInitialTypes(syncer::ModelTypeSet initial_types);
+
// SyncBackendRegistrar must be destroyed as follows:
//
// 1) On the sync thread, call OnSyncerShutdownComplete() after
diff --git a/chrome/browser/sync/glue/sync_backend_registrar_unittest.cc b/chrome/browser/sync/glue/sync_backend_registrar_unittest.cc
index 1950ed9..72158cb 100644
--- a/chrome/browser/sync/glue/sync_backend_registrar_unittest.cc
+++ b/chrome/browser/sync/glue/sync_backend_registrar_unittest.cc
@@ -74,7 +74,8 @@ class SyncBackendRegistrarTest : public testing::Test {
TEST_F(SyncBackendRegistrarTest, ConstructorEmpty) {
TestingProfile profile;
- SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_);
+ SyncBackendRegistrar registrar("test", &profile, &loop_);
+ registrar.SetInitialTypes(ModelTypeSet());
EXPECT_FALSE(registrar.IsNigoriEnabled());
{
std::vector<syncer::ModelSafeWorker*> workers;
@@ -90,7 +91,8 @@ TEST_F(SyncBackendRegistrarTest, ConstructorEmpty) {
TEST_F(SyncBackendRegistrarTest, ConstructorNonEmpty) {
TestingProfile profile;
const ModelTypeSet initial_types(BOOKMARKS, NIGORI, PASSWORDS);
- SyncBackendRegistrar registrar(initial_types, "test", &profile, &loop_);
+ SyncBackendRegistrar registrar("test", &profile, &loop_);
+ registrar.SetInitialTypes(initial_types);
EXPECT_TRUE(registrar.IsNigoriEnabled());
{
std::vector<syncer::ModelSafeWorker*> workers;
@@ -111,7 +113,8 @@ TEST_F(SyncBackendRegistrarTest, ConstructorNonEmpty) {
TEST_F(SyncBackendRegistrarTest, ConfigureDataTypes) {
TestingProfile profile;
- SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_);
+ SyncBackendRegistrar registrar("test", &profile, &loop_);
+ registrar.SetInitialTypes(ModelTypeSet());
// Add.
const ModelTypeSet types1(BOOKMARKS, NIGORI, AUTOFILL);
@@ -155,7 +158,8 @@ void TriggerChanges(SyncBackendRegistrar* registrar, ModelType type) {
TEST_F(SyncBackendRegistrarTest, ActivateDeactivateUIDataType) {
InSequence in_sequence;
TestingProfile profile;
- SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_);
+ SyncBackendRegistrar registrar("test", &profile, &loop_);
+ registrar.SetInitialTypes(ModelTypeSet());
// Should do nothing.
TriggerChanges(&registrar, BOOKMARKS);
@@ -202,7 +206,8 @@ TEST_F(SyncBackendRegistrarTest, ActivateDeactivateNonUIDataType) {
content::TestBrowserThread db_thread(BrowserThread::DB, &loop_);
InSequence in_sequence;
TestingProfile profile;
- SyncBackendRegistrar registrar(ModelTypeSet(), "test", &profile, &loop_);
+ SyncBackendRegistrar registrar("test", &profile, &loop_);
+ registrar.SetInitialTypes(ModelTypeSet());
// Should do nothing.
TriggerChanges(&registrar, AUTOFILL);
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 4b72b17..af0299b 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -327,14 +327,6 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
return;
}
- syncer::ModelTypeSet initial_types;
- // If sync setup hasn't finished, we don't want to initialize routing info
- // for any data types so that we don't download updates for types that the
- // user chooses not to sync on the first DownloadUpdatesCommand.
- if (HasSyncSetupCompleted()) {
- initial_types = GetPreferredDataTypes();
- }
-
SyncCredentials credentials = GetCredentials();
scoped_refptr<net::URLRequestContextGetter> request_context_getter(
@@ -351,7 +343,6 @@ void ProfileSyncService::InitializeBackend(bool delete_stale_data) {
this,
MakeWeakHandle(sync_js_controller_.AsWeakPtr()),
sync_service_url_,
- initial_types,
credentials,
delete_stale_data,
&sync_manager_factory_,
diff --git a/chrome/browser/sync/test_profile_sync_service.cc b/chrome/browser/sync/test_profile_sync_service.cc
index 6cd5ad5..063b8ed 100644
--- a/chrome/browser/sync/test_profile_sync_service.cc
+++ b/chrome/browser/sync/test_profile_sync_service.cc
@@ -32,12 +32,17 @@ SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest(
Profile* profile,
const base::WeakPtr<SyncPrefs>& sync_prefs,
const base::WeakPtr<InvalidatorStorage>& invalidator_storage,
+ syncer::TestIdFactory& id_factory,
+ base::Closure& callback,
bool set_initial_sync_ended_on_init,
bool synchronous_init,
bool fail_initial_download,
bool use_real_database)
: browser_sync::SyncBackendHost(
profile->GetDebugName(), profile, sync_prefs, invalidator_storage),
+ id_factory_(id_factory),
+ callback_(callback),
+ set_initial_sync_ended_on_init_(set_initial_sync_ended_on_init),
synchronous_init_(synchronous_init),
fail_initial_download_(fail_initial_download),
use_real_database_(use_real_database) {}
@@ -94,6 +99,54 @@ void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer(
ready_task);
}
+void SyncBackendHostForProfileSyncTest
+ ::HandleSyncManagerInitializationOnFrontendLoop(
+ const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success,
+ syncer::ModelTypeSet restored_types) {
+ // Here's our opportunity to pretend to do things that the SyncManager would
+ // normally do during initialization, but can't because this is a test.
+ bool send_passphrase_required = false;
+ if (success) {
+ // Set up any nodes the test wants around before model association.
+ if (!callback_.is_null()) {
+ callback_.Run();
+ }
+
+ // Pretend we downloaded initial updates and set initial sync ended bits
+ // if we were asked to.
+ if (set_initial_sync_ended_on_init_) {
+ UserShare* user_share = GetUserShare();
+ Directory* directory = user_share->directory.get();
+
+ if (!directory->initial_sync_ended_for_type(syncer::NIGORI)) {
+ ProfileSyncServiceTestHelper::CreateRoot(
+ syncer::NIGORI, user_share, &id_factory_);
+
+ // A side effect of adding the NIGORI mode (normally done by the
+ // syncer) is a decryption attempt, which will fail the first time.
+ send_passphrase_required = true;
+ }
+
+ SetInitialSyncEndedForAllTypes();
+ restored_types = syncer::ModelTypeSet::All();
+ }
+ }
+
+ SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop(
+ js_backend, success, restored_types);
+}
+
+void SyncBackendHostForProfileSyncTest::SetInitialSyncEndedForAllTypes() {
+ UserShare* user_share = GetUserShare();
+ Directory* directory = user_share->directory.get();
+
+ for (int i = syncer::FIRST_REAL_MODEL_TYPE;
+ i < syncer::MODEL_TYPE_COUNT; ++i) {
+ directory->set_initial_sync_ended_for_type(
+ syncer::ModelTypeFromInt(i), true);
+ }
+}
+
} // namespace browser_sync
syncer::TestIdFactory* TestProfileSyncService::id_factory() {
@@ -130,54 +183,10 @@ TestProfileSyncService::TestProfileSyncService(
TestProfileSyncService::~TestProfileSyncService() {
}
-void TestProfileSyncService::SetInitialSyncEndedForAllTypes() {
- UserShare* user_share = GetUserShare();
- Directory* directory = user_share->directory.get();
-
- for (int i = syncer::FIRST_REAL_MODEL_TYPE;
- i < syncer::MODEL_TYPE_COUNT; ++i) {
- directory->set_initial_sync_ended_for_type(
- syncer::ModelTypeFromInt(i), true);
- }
-}
-
void TestProfileSyncService::OnBackendInitialized(
const syncer::WeakHandle<syncer::JsBackend>& backend,
bool success) {
- bool send_passphrase_required = false;
- if (success) {
- // Set this so below code can access GetUserShare().
- backend_initialized_ = true;
-
- // Set up any nodes the test wants around before model association.
- if (!callback_.is_null()) {
- callback_.Run();
- callback_.Reset();
- }
-
- // Pretend we downloaded initial updates and set initial sync ended bits
- // if we were asked to.
- if (set_initial_sync_ended_on_init_) {
- UserShare* user_share = GetUserShare();
- Directory* directory = user_share->directory.get();
-
- if (!directory->initial_sync_ended_for_type(syncer::NIGORI)) {
- ProfileSyncServiceTestHelper::CreateRoot(
- syncer::NIGORI, GetUserShare(),
- id_factory());
-
- // A side effect of adding the NIGORI mode (normally done by the
- // syncer) is a decryption attempt, which will fail the first time.
- send_passphrase_required = true;
- }
-
- SetInitialSyncEndedForAllTypes();
- }
- }
-
ProfileSyncService::OnBackendInitialized(backend, success);
- if (success && send_passphrase_required)
- OnPassphraseRequired(syncer::REASON_DECRYPTION, sync_pb::EncryptedData());
// TODO(akalin): Figure out a better way to do this.
if (synchronous_backend_initialization_) {
@@ -196,6 +205,10 @@ void TestProfileSyncService::Observe(
}
}
+UserShare* TestProfileSyncService::GetUserShare() const {
+ return backend_->GetUserShare();
+}
+
void TestProfileSyncService::dont_set_initial_sync_ended_on_init() {
set_initial_sync_ended_on_init_ = false;
}
@@ -214,6 +227,8 @@ void TestProfileSyncService::CreateBackend() {
profile(),
sync_prefs_.AsWeakPtr(),
invalidator_storage_.AsWeakPtr(),
+ id_factory_,
+ callback_,
set_initial_sync_ended_on_init_,
synchronous_backend_initialization_,
fail_initial_download_,
diff --git a/chrome/browser/sync/test_profile_sync_service.h b/chrome/browser/sync/test_profile_sync_service.h
index c4ca6b2..95a11da 100644
--- a/chrome/browser/sync/test_profile_sync_service.h
+++ b/chrome/browser/sync/test_profile_sync_service.h
@@ -36,6 +36,8 @@ class SyncBackendHostForProfileSyncTest : public SyncBackendHost {
Profile* profile,
const base::WeakPtr<SyncPrefs>& sync_prefs,
const base::WeakPtr<InvalidatorStorage>& invalidator_storage,
+ syncer::TestIdFactory& id_factory,
+ base::Closure& callback,
bool set_initial_sync_ended_on_init,
bool synchronous_init,
bool fail_initial_download,
@@ -51,12 +53,23 @@ class SyncBackendHostForProfileSyncTest : public SyncBackendHost {
const base::Callback<void(syncer::ModelTypeSet)>& ready_task,
const base::Closure& retry_callback) OVERRIDE;
+ virtual void HandleSyncManagerInitializationOnFrontendLoop(
+ const syncer::WeakHandle<syncer::JsBackend>& js_backend, bool success,
+ syncer::ModelTypeSet restored_types) OVERRIDE;
+
static void SetHistoryServiceExpectations(ProfileMock* profile);
+ void SetInitialSyncEndedForAllTypes();
+ void dont_set_initial_sync_ended_on_init();
+
protected:
virtual void InitCore(const DoInitializeOptions& options) OVERRIDE;
private:
+ syncer::TestIdFactory& id_factory_;
+ base::Closure& callback_;
+
+ bool set_initial_sync_ended_on_init_;
bool synchronous_init_;
bool fail_initial_download_;
bool use_real_database_;
@@ -70,17 +83,16 @@ class TestProfileSyncService : public ProfileSyncService {
// callback fires.
// TODO(tim): Remove |synchronous_backend_initialization|, and add ability to
// inject TokenService alongside SigninManager.
- TestProfileSyncService(ProfileSyncComponentsFactory* factory,
- Profile* profile,
- SigninManager* signin,
- ProfileSyncService::StartBehavior behavior,
- bool synchronous_backend_initialization,
- const base::Closure& callback);
+ TestProfileSyncService(
+ ProfileSyncComponentsFactory* factory,
+ Profile* profile,
+ SigninManager* signin,
+ ProfileSyncService::StartBehavior behavior,
+ bool synchronous_backend_initialization,
+ const base::Closure& callback);
virtual ~TestProfileSyncService();
- void SetInitialSyncEndedForAllTypes();
-
virtual void OnBackendInitialized(
const syncer::WeakHandle<syncer::JsBackend>& backend,
bool success) OVERRIDE;
@@ -89,6 +101,9 @@ class TestProfileSyncService : public ProfileSyncService {
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+ // We implement our own version to avoid some DCHECKs.
+ virtual syncer::UserShare* GetUserShare() const OVERRIDE;
+
// If this is called, configuring data types will require a syncer
// nudge.
void dont_set_initial_sync_ended_on_init();
diff --git a/sync/engine/sync_scheduler_unittest.cc b/sync/engine/sync_scheduler_unittest.cc
index ff4787b..6d98372 100644
--- a/sync/engine/sync_scheduler_unittest.cc
+++ b/sync/engine/sync_scheduler_unittest.cc
@@ -118,9 +118,10 @@ class SyncSchedulerTest : public testing::Test {
connection_->SetServerReachable();
throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL));
context_.reset(new SyncSessionContext(
- connection_.get(), directory(), routing_info, workers,
+ connection_.get(), directory(), workers,
&extensions_activity_monitor_, throttled_data_type_tracker_.get(),
std::vector<SyncEngineEventListener*>(), NULL, NULL));
+ context_->set_routing_info(routing_info);
context_->set_notifications_enabled(true);
context_->set_account_name("Test");
scheduler_.reset(
diff --git a/sync/engine/sync_scheduler_whitebox_unittest.cc b/sync/engine/sync_scheduler_whitebox_unittest.cc
index 4581a07..b035686 100644
--- a/sync/engine/sync_scheduler_whitebox_unittest.cc
+++ b/sync/engine/sync_scheduler_whitebox_unittest.cc
@@ -48,7 +48,7 @@ class SyncSchedulerWhiteboxTest : public testing::Test {
context_.reset(
new SyncSessionContext(
connection_.get(), dir_maker_.directory(),
- routes, workers, &extensions_activity_monitor_,
+ workers, &extensions_activity_monitor_,
throttled_data_type_tracker_.get(),
std::vector<SyncEngineEventListener*>(), NULL, NULL));
context_->set_notifications_enabled(true);
diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc
index 458f5a1..053fc1d 100644
--- a/sync/engine/syncer_unittest.cc
+++ b/sync/engine/syncer_unittest.cc
@@ -236,9 +236,10 @@ class SyncerTest : public testing::Test,
context_.reset(
new SyncSessionContext(
- mock_server_.get(), directory(), routing_info, workers,
+ mock_server_.get(), directory(), workers,
&extensions_activity_monitor_, throttled_data_type_tracker_.get(),
listeners, NULL, &traffic_recorder_));
+ context_->set_routing_info(routing_info);
ASSERT_FALSE(context_->resolver());
syncer_ = new Syncer();
session_.reset(MakeSession());
diff --git a/sync/internal_api/debug_info_event_listener.cc b/sync/internal_api/debug_info_event_listener.cc
index 60d0806..b7e3cda 100644
--- a/sync/internal_api/debug_info_event_listener.cc
+++ b/sync/internal_api/debug_info_event_listener.cc
@@ -46,7 +46,7 @@ void DebugInfoEventListener::OnSyncCycleCompleted(
void DebugInfoEventListener::OnInitializationComplete(
const WeakHandle<JsBackend>& js_backend,
- bool success) {
+ bool success, ModelTypeSet restored_types) {
CreateAndAddEvent(sync_pb::DebugEventInfo::INITIALIZATION_COMPLETE);
}
diff --git a/sync/internal_api/debug_info_event_listener.h b/sync/internal_api/debug_info_event_listener.h
index 8606cf9..67017b9 100644
--- a/sync/internal_api/debug_info_event_listener.h
+++ b/sync/internal_api/debug_info_event_listener.h
@@ -33,8 +33,8 @@ class DebugInfoEventListener : public SyncManager::Observer,
virtual void OnSyncCycleCompleted(
const sessions::SyncSessionSnapshot& snapshot) OVERRIDE;
virtual void OnInitializationComplete(
- const WeakHandle<JsBackend>& js_backend,
- bool success) OVERRIDE;
+ const syncer::WeakHandle<JsBackend>& js_backend,
+ bool success, ModelTypeSet restored_types) OVERRIDE;
virtual void OnConnectionStatusChange(
ConnectionStatus connection_status) OVERRIDE;
virtual void OnPassphraseRequired(
diff --git a/sync/internal_api/internal_components_factory_impl.cc b/sync/internal_api/internal_components_factory_impl.cc
index d62d942..062ee0b 100644
--- a/sync/internal_api/internal_components_factory_impl.cc
+++ b/sync/internal_api/internal_components_factory_impl.cc
@@ -24,7 +24,6 @@ scoped_ptr<sessions::SyncSessionContext>
InternalComponentsFactoryImpl::BuildContext(
ServerConnectionManager* connection_manager,
syncable::Directory* directory,
- const ModelSafeRoutingInfo& routing_info,
const std::vector<ModelSafeWorker*> workers,
ExtensionsActivityMonitor* monitor,
ThrottledDataTypeTracker* throttled_data_type_tracker,
@@ -32,9 +31,10 @@ InternalComponentsFactoryImpl::BuildContext(
sessions::DebugInfoGetter* debug_info_getter,
TrafficRecorder* traffic_recorder) {
return scoped_ptr<sessions::SyncSessionContext>(
- new sessions::SyncSessionContext(connection_manager, directory,
- routing_info, workers, monitor, throttled_data_type_tracker,
- listeners, debug_info_getter, traffic_recorder));
+ new sessions::SyncSessionContext(
+ connection_manager, directory, workers, monitor,
+ throttled_data_type_tracker, listeners, debug_info_getter,
+ traffic_recorder));
}
scoped_ptr<syncable::DirectoryBackingStore>
diff --git a/sync/internal_api/js_sync_manager_observer.cc b/sync/internal_api/js_sync_manager_observer.cc
index 5eda7f1..078e1e9 100644
--- a/sync/internal_api/js_sync_manager_observer.cc
+++ b/sync/internal_api/js_sync_manager_observer.cc
@@ -124,13 +124,17 @@ void JsSyncManagerObserver::OnActionableError(
void JsSyncManagerObserver::OnInitializationComplete(
const WeakHandle<JsBackend>& js_backend,
- bool success) {
+ bool success, syncer::ModelTypeSet restored_types) {
if (!event_handler_.IsInitialized()) {
return;
}
// Ignore the |js_backend| argument; it's not really convertible to
// JSON anyway.
- HandleJsEvent(FROM_HERE, "onInitializationComplete", JsEventDetails());
+
+ DictionaryValue* details = new DictionaryValue();
+ details->Set("restoredTypes", ModelTypeSetToValue(restored_types));
+
+ HandleJsEvent(FROM_HERE, "onInitializationComplete", JsEventDetails(details));
}
void JsSyncManagerObserver::OnStopSyncingPermanently() {
diff --git a/sync/internal_api/js_sync_manager_observer.h b/sync/internal_api/js_sync_manager_observer.h
index 0988670..8d0622c 100644
--- a/sync/internal_api/js_sync_manager_observer.h
+++ b/sync/internal_api/js_sync_manager_observer.h
@@ -46,7 +46,8 @@ class JsSyncManagerObserver : public SyncManager::Observer {
bool encrypt_everything) OVERRIDE;
virtual void OnEncryptionComplete() OVERRIDE;
virtual void OnInitializationComplete(
- const WeakHandle<JsBackend>& js_backend, bool success) OVERRIDE;
+ const WeakHandle<JsBackend>& js_backend, bool success,
+ syncer::ModelTypeSet restored_types) OVERRIDE;
virtual void OnStopSyncingPermanently() OVERRIDE;
virtual void OnActionableError(
const SyncProtocolError& sync_protocol_error) OVERRIDE;
diff --git a/sync/internal_api/js_sync_manager_observer_unittest.cc b/sync/internal_api/js_sync_manager_observer_unittest.cc
index 72ea4f3..5e51bf4 100644
--- a/sync/internal_api/js_sync_manager_observer_unittest.cc
+++ b/sync/internal_api/js_sync_manager_observer_unittest.cc
@@ -48,22 +48,33 @@ TEST_F(JsSyncManagerObserverTest, NoArgNotifiations) {
InSequence dummy;
EXPECT_CALL(mock_js_event_handler_,
- HandleJsEvent("onInitializationComplete",
- HasDetails(JsEventDetails())));
- EXPECT_CALL(mock_js_event_handler_,
HandleJsEvent("onStopSyncingPermanently",
HasDetails(JsEventDetails())));
EXPECT_CALL(mock_js_event_handler_,
HandleJsEvent("onEncryptionComplete",
HasDetails(JsEventDetails())));
- js_sync_manager_observer_.OnInitializationComplete(WeakHandle<JsBackend>(),
- true);
js_sync_manager_observer_.OnStopSyncingPermanently();
js_sync_manager_observer_.OnEncryptionComplete();
PumpLoop();
}
+TEST_F(JsSyncManagerObserverTest, OnInitializationComplete) {
+ DictionaryValue expected_details;
+ syncer::ModelTypeSet restored_types;
+ restored_types.Put(BOOKMARKS);
+ restored_types.Put(NIGORI);
+ expected_details.Set("restoredTypes", ModelTypeSetToValue(restored_types));
+
+ EXPECT_CALL(mock_js_event_handler_,
+ HandleJsEvent("onInitializationComplete",
+ HasDetailsAsDictionary(expected_details)));
+
+ js_sync_manager_observer_.OnInitializationComplete(
+ WeakHandle<JsBackend>(), true, restored_types);
+ PumpLoop();
+}
+
TEST_F(JsSyncManagerObserverTest, OnSyncCycleCompleted) {
ModelTypePayloadMap download_progress_markers;
sessions::SyncSessionSnapshot snapshot(sessions::ModelNeutralState(),
diff --git a/sync/internal_api/public/internal_components_factory.h b/sync/internal_api/public/internal_components_factory.h
index ab7dddf..40c703e 100644
--- a/sync/internal_api/public/internal_components_factory.h
+++ b/sync/internal_api/public/internal_components_factory.h
@@ -46,7 +46,6 @@ class InternalComponentsFactory {
virtual scoped_ptr<sessions::SyncSessionContext> BuildContext(
ServerConnectionManager* connection_manager,
syncable::Directory* directory,
- const ModelSafeRoutingInfo& routing_info,
const std::vector<ModelSafeWorker*> workers,
ExtensionsActivityMonitor* monitor,
ThrottledDataTypeTracker* throttled_data_type_tracker,
diff --git a/sync/internal_api/public/internal_components_factory_impl.h b/sync/internal_api/public/internal_components_factory_impl.h
index 1398022..d15287a 100644
--- a/sync/internal_api/public/internal_components_factory_impl.h
+++ b/sync/internal_api/public/internal_components_factory_impl.h
@@ -24,7 +24,6 @@ class InternalComponentsFactoryImpl : public InternalComponentsFactory {
virtual scoped_ptr<sessions::SyncSessionContext> BuildContext(
ServerConnectionManager* connection_manager,
syncable::Directory* directory,
- const ModelSafeRoutingInfo& routing_info,
const std::vector<ModelSafeWorker*> workers,
ExtensionsActivityMonitor* monitor,
ThrottledDataTypeTracker* throttled_data_type_tracker,
diff --git a/sync/internal_api/public/sync_manager.h b/sync/internal_api/public/sync_manager.h
index 0429697..2cbbd5c 100644
--- a/sync/internal_api/public/sync_manager.h
+++ b/sync/internal_api/public/sync_manager.h
@@ -298,7 +298,9 @@ class SyncManager {
// function getChildNodeIds(id);
virtual void OnInitializationComplete(
- const WeakHandle<JsBackend>& js_backend, bool success) = 0;
+ const WeakHandle<syncer::JsBackend>& js_backend,
+ bool success,
+ syncer::ModelTypeSet restored_types) = 0;
// We are no longer permitted to communicate with the server. Sync should
// be disabled and state cleaned up at once. This can happen for a number
@@ -369,7 +371,6 @@ class SyncManager {
bool use_ssl,
const scoped_refptr<base::TaskRunner>& blocking_task_runner,
scoped_ptr<HttpPostProviderFactory> post_factory,
- const ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<ModelSafeWorker*>& workers,
ExtensionsActivityMonitor* extensions_activity_monitor,
ChangeDelegate* change_delegate,
diff --git a/sync/internal_api/public/test/fake_sync_manager.h b/sync/internal_api/public/test/fake_sync_manager.h
index 0183c8f..015605f 100644
--- a/sync/internal_api/public/test/fake_sync_manager.h
+++ b/sync/internal_api/public/test/fake_sync_manager.h
@@ -61,7 +61,6 @@ class FakeSyncManager : public SyncManager {
bool use_ssl,
const scoped_refptr<base::TaskRunner>& blocking_task_runner,
scoped_ptr<HttpPostProviderFactory> post_factory,
- const ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<ModelSafeWorker*>& workers,
ExtensionsActivityMonitor* extensions_activity_monitor,
ChangeDelegate* change_delegate,
diff --git a/sync/internal_api/public/test/test_internal_components_factory.h b/sync/internal_api/public/test/test_internal_components_factory.h
index 4218d56..3755447 100644
--- a/sync/internal_api/public/test/test_internal_components_factory.h
+++ b/sync/internal_api/public/test/test_internal_components_factory.h
@@ -29,7 +29,6 @@ class TestInternalComponentsFactory : public InternalComponentsFactory {
virtual scoped_ptr<sessions::SyncSessionContext> BuildContext(
ServerConnectionManager* connection_manager,
syncable::Directory* directory,
- const ModelSafeRoutingInfo& routing_info,
const std::vector<ModelSafeWorker*> workers,
ExtensionsActivityMonitor* monitor,
ThrottledDataTypeTracker* throttled_data_type_tracker,
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index 98ba4a3..24d614e 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -293,13 +293,11 @@ void SyncManagerImpl::ThrowUnrecoverableError() {
}
ModelTypeSet SyncManagerImpl::InitialSyncEndedTypes() {
- DCHECK(initialized_);
return directory()->initial_sync_ended_types();
}
ModelTypeSet SyncManagerImpl::GetTypesWithEmptyProgressMarkerToken(
ModelTypeSet types) {
- DCHECK(initialized_);
ModelTypeSet result;
for (ModelTypeSet::Iterator i = types.First(); i.Good(); i.Inc()) {
sync_pb::DataTypeProgressMarker marker;
@@ -365,7 +363,6 @@ bool SyncManagerImpl::Init(
bool use_ssl,
const scoped_refptr<base::TaskRunner>& blocking_task_runner,
scoped_ptr<HttpPostProviderFactory> post_factory,
- const ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<ModelSafeWorker*>& workers,
ExtensionsActivityMonitor* extensions_activity_monitor,
SyncManager::ChangeDelegate* change_delegate,
@@ -379,6 +376,8 @@ bool SyncManagerImpl::Init(
CHECK(!initialized_);
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(post_factory.get());
+ DCHECK(!credentials.email.empty());
+ DCHECK(!credentials.sync_token.empty());
DVLOG(1) << "SyncManager starting Init...";
weak_handle_this_ = MakeWeakHandle(weak_ptr_factory_.GetWeakPtr());
@@ -407,6 +406,7 @@ bool SyncManagerImpl::Init(
credentials.email, absolute_db_path).Pass();
DCHECK(backing_store.get());
+ share_.name = credentials.email;
share_.directory.reset(
new syncable::Directory(encryptor_,
unrecoverable_error_handler_,
@@ -415,11 +415,33 @@ bool SyncManagerImpl::Init(
connection_manager_.reset(new SyncAPIServerConnectionManager(
sync_server_and_path, port, use_ssl, post_factory.release()));
+ connection_manager_->AddListener(this);
- net::NetworkChangeNotifier::AddIPAddressObserver(this);
- observing_ip_address_changes_ = true;
+ DVLOG(1) << "Username: " << username_for_share();
+ if (!OpenDirectory()) {
+ FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
+ OnInitializationComplete(
+ MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()),
+ false, syncer::ModelTypeSet()));
+ return false;
+ }
- connection_manager_->AddListener(this);
+ // Retrieve and set the sync notifier state.
+ std::string unique_id = directory()->cache_guid();
+ DVLOG(1) << "Read notification unique ID: " << unique_id;
+ allstatus_.SetUniqueId(unique_id);
+ sync_notifier_->SetUniqueId(unique_id);
+
+ std::string state = directory()->GetNotificationState();
+ if (VLOG_IS_ON(1)) {
+ std::string encoded_state;
+ base::Base64Encode(state, &encoded_state);
+ DVLOG(1) << "Read notification state: " << encoded_state;
+ }
+
+ // TODO(tim): Remove once invalidation state has been migrated to new
+ // InvalidationStateTracker store. Bug 124140.
+ sync_notifier_->SetStateDeprecated(state);
// Build a SyncSessionContext and store the worker in it.
DVLOG(1) << "Sync is bringing up SyncSessionContext.";
@@ -429,7 +451,6 @@ bool SyncManagerImpl::Init(
session_context_ = internal_components_factory->BuildContext(
connection_manager_.get(),
directory(),
- model_safe_routing_info,
workers,
extensions_activity_monitor,
&throttled_data_type_tracker_,
@@ -440,49 +461,28 @@ bool SyncManagerImpl::Init(
scheduler_ = internal_components_factory->BuildScheduler(
name_, session_context_.get()).Pass();
- bool success = SignIn(credentials);
-
- if (success) {
- scheduler_->Start(SyncScheduler::CONFIGURATION_MODE);
-
- initialized_ = true;
-
- // Unapplied datatypes (those that do not have initial sync ended set) get
- // re-downloaded during any configuration. But, it's possible for a datatype
- // to have a progress marker but not have initial sync ended yet, making
- // it a candidate for migration. This is a problem, as the DataTypeManager
- // does not support a migration while it's already in the middle of a
- // configuration. As a result, any partially synced datatype can stall the
- // DTM, waiting for the configuration to complete, which it never will due
- // to the migration error. In addition, a partially synced nigori will
- // trigger the migration logic before the backend is initialized, resulting
- // in crashes. We therefore detect and purge any partially synced types as
- // part of initialization.
- if (!PurgePartiallySyncedTypes())
- success = false;
+ scheduler_->Start(SyncScheduler::CONFIGURATION_MODE);
- // Cryptographer should only be accessed while holding a
- // transaction. Grabbing the user share for the transaction
- // checks the initialization state, so this must come after
- // |initialized_| is set to true.
- ReadTransaction trans(FROM_HERE, GetUserShare());
- trans.GetCryptographer()->Bootstrap(restored_key_for_bootstrapping);
- trans.GetCryptographer()->AddObserver(this);
- }
+ initialized_ = true;
+
+ net::NetworkChangeNotifier::AddIPAddressObserver(this);
+ observing_ip_address_changes_ = true;
+
+ UpdateCredentials(credentials);
+
+ // Cryptographer should only be accessed while holding a
+ // transaction. Grabbing the user share for the transaction
+ // checks the initialization state, so this must come after
+ // |initialized_| is set to true.
+ ReadTransaction trans(FROM_HERE, GetUserShare());
+ trans.GetCryptographer()->Bootstrap(restored_key_for_bootstrapping);
+ trans.GetCryptographer()->AddObserver(this);
- // Notify that initialization is complete. Note: This should be the last to
- // execute if |signed_in| is false. Reason being in that case we would
- // post a task to shutdown sync. But if this function posts any other tasks
- // on the UI thread and if shutdown wins then that tasks would execute on
- // a freed pointer. This is because UI thread is not shut down.
FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
OnInitializationComplete(
MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()),
- success));
- if (!success)
- return false;
-
- return success;
+ true, InitialSyncEndedTypes()));
+ return true;
}
void SyncManagerImpl::RefreshNigori(const std::string& chrome_version,
@@ -658,36 +658,21 @@ bool SyncManagerImpl::OpenDirectory() {
return false;
}
- connection_manager_->set_client_id(directory()->cache_guid());
- return true;
-}
-
-bool SyncManagerImpl::SignIn(const SyncCredentials& credentials) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(share_.name.empty());
- share_.name = credentials.email;
-
- DVLOG(1) << "Signing in user: " << username_for_share();
- if (!OpenDirectory())
+ // Unapplied datatypes (those that do not have initial sync ended set) get
+ // re-downloaded during any configuration. But, it's possible for a datatype
+ // to have a progress marker but not have initial sync ended yet, making
+ // it a candidate for migration. This is a problem, as the DataTypeManager
+ // does not support a migration while it's already in the middle of a
+ // configuration. As a result, any partially synced datatype can stall the
+ // DTM, waiting for the configuration to complete, which it never will due
+ // to the migration error. In addition, a partially synced nigori will
+ // trigger the migration logic before the backend is initialized, resulting
+ // in crashes. We therefore detect and purge any partially synced types as
+ // part of initialization.
+ if (!PurgePartiallySyncedTypes())
return false;
- // Retrieve and set the sync notifier state. This should be done
- // only after OpenDirectory is called.
- std::string unique_id = directory()->cache_guid();
- std::string state = directory()->GetNotificationState();
- DVLOG(1) << "Read notification unique ID: " << unique_id;
- if (VLOG_IS_ON(1)) {
- std::string encoded_state;
- base::Base64Encode(state, &encoded_state);
- DVLOG(1) << "Read notification state: " << encoded_state;
- }
- allstatus_.SetUniqueId(unique_id);
- sync_notifier_->SetUniqueId(unique_id);
- // TODO(tim): Remove once invalidation state has been migrated to new
- // InvalidationStateTracker store. Bug 124140.
- sync_notifier_->SetStateDeprecated(state);
-
- UpdateCredentials(credentials);
+ connection_manager_->set_client_id(directory()->cache_guid());
return true;
}
@@ -707,18 +692,17 @@ bool SyncManagerImpl::PurgePartiallySyncedTypes() {
void SyncManagerImpl::UpdateCredentials(
const SyncCredentials& credentials) {
DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(initialized_);
DCHECK_EQ(credentials.email, share_.name);
DCHECK(!credentials.email.empty());
DCHECK(!credentials.sync_token.empty());
observing_ip_address_changes_ = true;
- if (connection_manager_->set_auth_token(credentials.sync_token)) {
- sync_notifier_->UpdateCredentials(
- credentials.email, credentials.sync_token);
- if (initialized_) {
- scheduler_->OnCredentialsUpdated();
- }
- }
+ if (!connection_manager_->set_auth_token(credentials.sync_token))
+ return; // Auth token is known to be invalid, so exit early.
+
+ sync_notifier_->UpdateCredentials(credentials.email, credentials.sync_token);
+ scheduler_->OnCredentialsUpdated();
}
void SyncManagerImpl::UpdateEnabledTypes(
diff --git a/sync/internal_api/sync_manager_impl.h b/sync/internal_api/sync_manager_impl.h
index bcb2c97..f3a57a1 100644
--- a/sync/internal_api/sync_manager_impl.h
+++ b/sync/internal_api/sync_manager_impl.h
@@ -65,7 +65,6 @@ class SyncManagerImpl : public SyncManager,
bool use_ssl,
const scoped_refptr<base::TaskRunner>& blocking_task_runner,
scoped_ptr<HttpPostProviderFactory> post_factory,
- const ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<ModelSafeWorker*>& workers,
ExtensionsActivityMonitor* extensions_activity_monitor,
SyncManager::ChangeDelegate* change_delegate,
@@ -221,11 +220,10 @@ class SyncManagerImpl : public SyncManager,
// Open the directory named with username_for_share
bool OpenDirectory();
- // Sign into sync with given credentials.
- // We do not verify the tokens given. After this call, the tokens are set
- // and the sync DB is open. True if successful, false if something
- // went wrong.
- bool SignIn(const SyncCredentials& credentials);
+ // Purge those types from |previously_enabled_types| that are no longer
+ // enabled in |currently_enabled_types|.
+ bool PurgeDisabledTypes(ModelTypeSet previously_enabled_types,
+ ModelTypeSet currently_enabled_types);
void RequestNudgeForDataTypes(
const tracked_objects::Location& nudge_location,
diff --git a/sync/internal_api/syncapi_unittest.cc b/sync/internal_api/syncapi_unittest.cc
index 3c55738..b563fa3 100644
--- a/sync/internal_api/syncapi_unittest.cc
+++ b/sync/internal_api/syncapi_unittest.cc
@@ -676,8 +676,9 @@ class SyncManagerObserverMock : public SyncManager::Observer {
public:
MOCK_METHOD1(OnSyncCycleCompleted,
void(const SyncSessionSnapshot&)); // NOLINT
- MOCK_METHOD2(OnInitializationComplete,
- void(const WeakHandle<JsBackend>&, bool)); // NOLINT
+ MOCK_METHOD3(OnInitializationComplete,
+ void(const WeakHandle<JsBackend>&, bool,
+ syncer::ModelTypeSet)); // NOLINT
MOCK_METHOD1(OnConnectionStatusChange, void(ConnectionStatus)); // NOLINT
MOCK_METHOD2(OnPassphraseRequired,
void(PassphraseRequiredReason,
@@ -743,7 +744,7 @@ class SyncManagerTest : public testing::Test,
UpdateCredentials(credentials.email, credentials.sync_token));
sync_manager_.AddObserver(&observer_);
- EXPECT_CALL(observer_, OnInitializationComplete(_, _)).
+ EXPECT_CALL(observer_, OnInitializationComplete(_, _, _)).
WillOnce(SaveArg<0>(&js_backend_));
EXPECT_FALSE(js_backend_.IsInitialized());
@@ -759,8 +760,7 @@ class SyncManagerTest : public testing::Test,
base::MessageLoopProxy::current(),
scoped_ptr<HttpPostProviderFactory>(
new TestHttpPostProviderFactory()),
- routing_info, workers,
- &extensions_activity_monitor_, this,
+ workers, &extensions_activity_monitor_, this,
credentials,
scoped_ptr<SyncNotifier>(sync_notifier_mock_),
"",
diff --git a/sync/internal_api/test/fake_sync_manager.cc b/sync/internal_api/test/fake_sync_manager.cc
index 8899314..1af7fac 100644
--- a/sync/internal_api/test/fake_sync_manager.cc
+++ b/sync/internal_api/test/fake_sync_manager.cc
@@ -56,7 +56,6 @@ bool FakeSyncManager::Init(
bool use_ssl,
const scoped_refptr<base::TaskRunner>& blocking_task_runner,
scoped_ptr<HttpPostProviderFactory> post_factory,
- const ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<ModelSafeWorker*>& workers,
ExtensionsActivityMonitor* extensions_activity_monitor,
ChangeDelegate* change_delegate,
@@ -72,8 +71,8 @@ bool FakeSyncManager::Init(
PurgePartiallySyncedTypes();
FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
OnInitializationComplete(
- WeakHandle<JsBackend>(),
- true));
+ syncer::WeakHandle<syncer::JsBackend>(),
+ true, initial_sync_ended_types_));
return true;
}
@@ -100,6 +99,7 @@ bool FakeSyncManager::PurgePartiallySyncedTypes() {
partial_types.Put(i.Get());
}
progress_marker_types_.RemoveAll(partial_types);
+ cleaned_types_.PutAll(partial_types);
return true;
}
diff --git a/sync/internal_api/test/test_internal_components_factory.cc b/sync/internal_api/test/test_internal_components_factory.cc
index 37aab64..ac3f8a8 100644
--- a/sync/internal_api/test/test_internal_components_factory.cc
+++ b/sync/internal_api/test/test_internal_components_factory.cc
@@ -27,7 +27,6 @@ scoped_ptr<sessions::SyncSessionContext>
TestInternalComponentsFactory::BuildContext(
ServerConnectionManager* connection_manager,
syncable::Directory* directory,
- const ModelSafeRoutingInfo& routing_info,
const std::vector<ModelSafeWorker*> workers,
ExtensionsActivityMonitor* monitor,
ThrottledDataTypeTracker* throttled_data_type_tracker,
@@ -38,9 +37,10 @@ TestInternalComponentsFactory::BuildContext(
// Tests don't wire up listeners.
std::vector<SyncEngineEventListener*> empty_listeners;
return scoped_ptr<sessions::SyncSessionContext>(
- new sessions::SyncSessionContext(connection_manager, directory,
- routing_info, workers, monitor, throttled_data_type_tracker,
- empty_listeners, debug_info_getter, traffic_recorder));
+ new sessions::SyncSessionContext(
+ connection_manager, directory, workers, monitor,
+ throttled_data_type_tracker, empty_listeners, debug_info_getter,
+ traffic_recorder));
}
scoped_ptr<syncable::DirectoryBackingStore>
diff --git a/sync/sessions/sync_session_context.cc b/sync/sessions/sync_session_context.cc
index 8e28b5f..7b6349b 100644
--- a/sync/sessions/sync_session_context.cc
+++ b/sync/sessions/sync_session_context.cc
@@ -17,7 +17,6 @@ const unsigned int kMaxMessageSizeToRecord = 5 * 1024;
SyncSessionContext::SyncSessionContext(
ServerConnectionManager* connection_manager,
syncable::Directory* directory,
- const ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<ModelSafeWorker*>& workers,
ExtensionsActivityMonitor* extensions_activity_monitor,
ThrottledDataTypeTracker* throttled_data_type_tracker,
@@ -27,7 +26,6 @@ SyncSessionContext::SyncSessionContext(
: resolver_(NULL),
connection_manager_(connection_manager),
directory_(directory),
- routing_info_(model_safe_routing_info),
workers_(workers),
extensions_activity_monitor_(extensions_activity_monitor),
notifications_enabled_(false),
diff --git a/sync/sessions/sync_session_context.h b/sync/sessions/sync_session_context.h
index 3255b94..cd26d5e 100644
--- a/sync/sessions/sync_session_context.h
+++ b/sync/sessions/sync_session_context.h
@@ -51,7 +51,6 @@ class SyncSessionContext {
public:
SyncSessionContext(ServerConnectionManager* connection_manager,
syncable::Directory* directory,
- const ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<ModelSafeWorker*>& workers,
ExtensionsActivityMonitor* extensions_activity_monitor,
ThrottledDataTypeTracker* throttled_data_type_tracker,
diff --git a/sync/sessions/sync_session_unittest.cc b/sync/sessions/sync_session_unittest.cc
index 1029e1d..bd17d359 100644
--- a/sync/sessions/sync_session_unittest.cc
+++ b/sync/sessions/sync_session_unittest.cc
@@ -41,17 +41,6 @@ class SyncSessionTest : public testing::Test,
}
virtual void SetUp() {
- ModelSafeRoutingInfo routing_info;
- std::vector<ModelSafeWorker*> workers;
-
- GetModelSafeRoutingInfo(&routing_info);
- GetWorkers(&workers);
-
- context_.reset(
- new SyncSessionContext(
- NULL, NULL, routing_info, workers, &extensions_activity_monitor_,
- throttled_data_type_tracker_.get(),
- std::vector<SyncEngineEventListener*>(), NULL, NULL));
routes_.clear();
routes_[BOOKMARKS] = GROUP_UI;
routes_[AUTOFILL] = GROUP_DB;
@@ -65,6 +54,22 @@ class SyncSessionTest : public testing::Test,
workers_.push_back(passive_worker);
workers_.push_back(ui_worker);
workers_.push_back(db_worker);
+
+ std::vector<ModelSafeWorker*> workers;
+ GetWorkers(&workers);
+
+ context_.reset(
+ new SyncSessionContext(
+ NULL,
+ NULL,
+ workers,
+ &extensions_activity_monitor_,
+ throttled_data_type_tracker_.get(),
+ std::vector<SyncEngineEventListener*>(),
+ NULL,
+ NULL));
+ context_->set_routing_info(routes_);
+
session_.reset(MakeSession());
throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL));
}
diff --git a/sync/test/engine/syncer_command_test.h b/sync/test/engine/syncer_command_test.h
index 6b957a8..0c0185e 100644
--- a/sync/test/engine/syncer_command_test.h
+++ b/sync/test/engine/syncer_command_test.h
@@ -123,7 +123,7 @@ class SyncerCommandTestBase : public testing::Test,
throttled_data_type_tracker_.reset(new ThrottledDataTypeTracker(NULL));
context_.reset(new sessions::SyncSessionContext(
mock_server_.get(), directory(),
- routing_info_, GetWorkers(), &extensions_activity_monitor_,
+ GetWorkers(), &extensions_activity_monitor_,
throttled_data_type_tracker_.get(),
std::vector<SyncEngineEventListener*>(),
&mock_debug_info_getter_,
diff --git a/sync/tools/sync_client.cc b/sync/tools/sync_client.cc
index caa6ee6..4da8cc1 100644
--- a/sync/tools/sync_client.cc
+++ b/sync/tools/sync_client.cc
@@ -355,7 +355,6 @@ int SyncClientMain(int argc, char* argv[]) {
kUseSsl,
blocking_task_runner,
post_factory.Pass(),
- routing_info,
workers,
extensions_activity_monitor,
&change_delegate,