diff options
Diffstat (limited to 'chrome/browser')
3 files changed, 140 insertions, 4 deletions
diff --git a/chrome/browser/sync/engine/model_changing_syncer_command.cc b/chrome/browser/sync/engine/model_changing_syncer_command.cc index 7c73631..797f795 100644 --- a/chrome/browser/sync/engine/model_changing_syncer_command.cc +++ b/chrome/browser/sync/engine/model_changing_syncer_command.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,9 +17,31 @@ void ModelChangingSyncerCommand::ExecuteImpl(sessions::SyncSession* session) { return; } + // Project the list of active types (i.e., types in the routing + // info) to a list of groups. + // + // TODO(akalin): Make this overrideable by subclasses (who might be + // working on a subset of |active_groups|). (See + // http://crbug.com/97832.) + std::set<ModelSafeGroup> active_groups; + const ModelSafeRoutingInfo& routing_info = session->routing_info(); + for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); + it != routing_info.end(); ++it) { + active_groups.insert(it->second); + } + // Always work on GROUP_PASSIVE, since that's the group that + // top-level folders map to. + active_groups.insert(GROUP_PASSIVE); + for (size_t i = 0; i < session->workers().size(); ++i) { ModelSafeWorker* worker = session->workers()[i]; ModelSafeGroup group = worker->GetModelSafeGroup(); + // Skip workers whose group isn't active. + if (active_groups.find(group) == active_groups.end()) { + VLOG(2) << "Skipping worker for group " + << ModelSafeGroupToString(group); + continue; + } sessions::StatusController* status = work_session_->status_controller(); sessions::ScopedModelSafeGroupRestriction r(status, group); diff --git a/chrome/browser/sync/engine/model_safe_worker.cc b/chrome/browser/sync/engine/model_safe_worker.cc index 8142be2..ae94b26 100644 --- a/chrome/browser/sync/engine/model_safe_worker.cc +++ b/chrome/browser/sync/engine/model_safe_worker.cc @@ -43,9 +43,6 @@ ModelSafeGroup GetGroupForModelType(const syncable::ModelType type, const ModelSafeRoutingInfo& routes) { ModelSafeRoutingInfo::const_iterator it = routes.find(type); if (it == routes.end()) { - // TODO(tim): We shouldn't end up here for TOP_LEVEL_FOLDER, but an issue - // with the server's PermanentItemPopulator is causing TLF updates in - // some cases. See bug 36735. if (type != syncable::UNSPECIFIED && type != syncable::TOP_LEVEL_FOLDER) LOG(WARNING) << "Entry does not belong to active ModelSafeGroup!"; return GROUP_PASSIVE; diff --git a/chrome/browser/sync/test/integration/enable_disable_test.cc b/chrome/browser/sync/test/integration/enable_disable_test.cc new file mode 100644 index 0000000..fd4363d --- /dev/null +++ b/chrome/browser/sync/test/integration/enable_disable_test.cc @@ -0,0 +1,117 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/sync/test/integration/sync_test.h" + +#include "chrome/browser/sync/profile_sync_service_harness.h" +#include "chrome/browser/sync/internal_api/read_node.h" +#include "chrome/browser/sync/internal_api/read_transaction.h" +#include "chrome/browser/sync/syncable/model_type.h" + +// This file contains tests that exercise enabling and disabling data +// types. + +namespace { + +class EnableDisableTest : public SyncTest { + public: + explicit EnableDisableTest(TestType test_type) : SyncTest(test_type) {} + virtual ~EnableDisableTest() {} + private: + DISALLOW_COPY_AND_ASSIGN(EnableDisableTest); +}; + +class EnableDisableSingleClientTest : public EnableDisableTest { + public: + EnableDisableSingleClientTest() : EnableDisableTest(SINGLE_CLIENT) {} + virtual ~EnableDisableSingleClientTest() {} + private: + DISALLOW_COPY_AND_ASSIGN(EnableDisableSingleClientTest); +}; + +bool DoesTopLevelNodeExist(sync_api::UserShare* user_share, + syncable::ModelType type) { + sync_api::ReadTransaction trans(FROM_HERE, user_share); + sync_api::ReadNode node(&trans); + return node.InitByTagLookup(syncable::ModelTypeToRootTag(type)); +} + +IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, EnableOneAtATime) { + ASSERT_TRUE(SetupClients()); + + DisableNotifications(); + + // Setup sync with no enabled types. + ASSERT_TRUE(GetClient(0)->SetupSync(syncable::ModelTypeSet())); + + syncable::ModelTypeSet registered_types; + GetClient(0)->service()->GetRegisteredDataTypes(®istered_types); + sync_api::UserShare* user_share = GetClient(0)->service()->GetUserShare(); + for (syncable::ModelTypeSet::const_iterator it = registered_types.begin(); + it != registered_types.end(); ++it) { + ASSERT_TRUE(GetClient(0)->EnableSyncForDatatype(*it)); + + // AUTOFILL_PROFILE is lumped together with AUTOFILL. + if (*it == syncable::AUTOFILL_PROFILE) { + continue; + } + + ASSERT_TRUE(DoesTopLevelNodeExist(user_share, *it)) + << syncable::ModelTypeToString(*it); + + // AUTOFILL_PROFILE is lumped together with AUTOFILL. + if (*it == syncable::AUTOFILL) { + ASSERT_TRUE(DoesTopLevelNodeExist(user_share, + syncable::AUTOFILL_PROFILE)); + } + } + + EnableNotifications(); +} + +IN_PROC_BROWSER_TEST_F(EnableDisableSingleClientTest, DisableOneAtATime) { + ASSERT_TRUE(SetupClients()); + + DisableNotifications(); + + // Setup sync with no disabled types. + ASSERT_TRUE(GetClient(0)->SetupSync()); + + syncable::ModelTypeSet registered_types; + GetClient(0)->service()->GetRegisteredDataTypes(®istered_types); + + sync_api::UserShare* user_share = GetClient(0)->service()->GetUserShare(); + + // Make sure all top-level nodes exist first. + for (syncable::ModelTypeSet::const_iterator it = registered_types.begin(); + it != registered_types.end(); ++it) { + ASSERT_TRUE(DoesTopLevelNodeExist(user_share, *it)); + } + + for (syncable::ModelTypeSet::const_iterator it = registered_types.begin(); + it != registered_types.end(); ++it) { + ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(*it)); + + // AUTOFILL_PROFILE is lumped together with AUTOFILL. + if (*it == syncable::AUTOFILL_PROFILE) { + continue; + } + + sync_api::UserShare* user_share = + GetClient(0)->service()->GetUserShare(); + + ASSERT_FALSE(DoesTopLevelNodeExist(user_share, *it)) + << syncable::ModelTypeToString(*it); + + // AUTOFILL_PROFILE is lumped together with AUTOFILL. + if (*it == syncable::AUTOFILL) { + ASSERT_FALSE(DoesTopLevelNodeExist(user_share, + syncable::AUTOFILL_PROFILE)); + } + } + + EnableNotifications(); +} + +} // namespace |