Index: chrome/browser/sync/engine/apply_updates_command.cc |
diff --git a/chrome/browser/sync/engine/apply_updates_command.cc b/chrome/browser/sync/engine/apply_updates_command.cc |
index 8b5a6b8db8d28e10eca8fe405b2cb0b2b03df8d0..81d747d6f123e5ab0477e5bf52fa4178072db8c6 100644 |
--- a/chrome/browser/sync/engine/apply_updates_command.cc |
+++ b/chrome/browser/sync/engine/apply_updates_command.cc |
@@ -17,6 +17,40 @@ using sessions::SyncSession; |
ApplyUpdatesCommand::ApplyUpdatesCommand() {} |
ApplyUpdatesCommand::~ApplyUpdatesCommand() {} |
+bool ApplyUpdatesCommand::HasCustomGroupsToChange() const { |
+ // TODO(akalin): Set to true. |
+ return false; |
+} |
+ |
+std::set<ModelSafeGroup> ApplyUpdatesCommand::GetGroupsToChange( |
+ const sessions::SyncSession& session) const { |
+ std::set<ModelSafeGroup> groups_with_unapplied_updates; |
+ |
+ syncable::ModelTypeBitSet server_types_with_unapplied_updates; |
+ { |
+ syncable::ScopedDirLookup dir(session.context()->directory_manager(), |
+ session.context()->account_name()); |
+ if (!dir.good()) { |
+ LOG(ERROR) << "Scoped dir lookup failed!"; |
+ return groups_with_unapplied_updates; |
+ } |
+ |
+ syncable::ReadTransaction trans(FROM_HERE, dir); |
+ server_types_with_unapplied_updates = |
+ dir->GetServerTypesWithUnappliedUpdates(&trans); |
+ } |
+ |
+ for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) { |
+ const syncable::ModelType type = syncable::ModelTypeFromInt(i); |
+ if (server_types_with_unapplied_updates.test(type)) { |
+ groups_with_unapplied_updates.insert( |
+ GetGroupForModelType(type, session.routing_info())); |
+ } |
+ } |
+ |
+ return groups_with_unapplied_updates; |
+} |
+ |
void ApplyUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) { |
syncable::ScopedDirLookup dir(session->context()->directory_manager(), |
session->context()->account_name()); |
@@ -24,9 +58,27 @@ void ApplyUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) { |
LOG(ERROR) << "Scoped dir lookup failed!"; |
return; |
} |
+ |
syncable::WriteTransaction trans(FROM_HERE, syncable::SYNCER, dir); |
+ |
+ // Compute server types with unapplied updates that fall under our |
+ // group restriction. |
+ const syncable::ModelTypeBitSet server_types_with_unapplied_updates = |
+ dir->GetServerTypesWithUnappliedUpdates(&trans); |
+ syncable::ModelTypeBitSet server_type_restriction; |
+ for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) { |
+ const syncable::ModelType server_type = syncable::ModelTypeFromInt(i); |
+ if (server_types_with_unapplied_updates.test(server_type)) { |
+ if (GetGroupForModelType(server_type, session->routing_info()) == |
+ session->status_controller().group_restriction()) { |
+ server_type_restriction.set(server_type); |
+ } |
+ } |
+ } |
+ |
syncable::Directory::UnappliedUpdateMetaHandles handles; |
- dir->GetUnappliedUpdateMetaHandles(&trans, &handles); |
+ dir->GetUnappliedUpdateMetaHandles( |
+ &trans, server_type_restriction, &handles); |
UpdateApplicator applicator( |
session->context()->resolver(), |
@@ -42,13 +94,6 @@ void ApplyUpdatesCommand::ModelChangingExecuteImpl(SyncSession* session) { |
// some subset of the currently synced datatypes. |
const sessions::StatusController& status(session->status_controller()); |
if (status.ServerSaysNothingMoreToDownload()) { |
- syncable::ScopedDirLookup dir(session->context()->directory_manager(), |
- session->context()->account_name()); |
- if (!dir.good()) { |
- LOG(ERROR) << "Scoped dir lookup failed!"; |
- return; |
- } |
- |
for (int i = syncable::FIRST_REAL_MODEL_TYPE; |
i < syncable::MODEL_TYPE_COUNT; ++i) { |
syncable::ModelType model_type = syncable::ModelTypeFromInt(i); |