Commit 11941c5b authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[ModelTypeWorker] Store SyncEntities if encryption pending

This CL changes the way we process incoming SyncEntities when decryption
is pending. After the change:
 - PopulateUpdateResponseData() early returns and does not populate
   anything if decryption is pending.
 - ProcessGetUpdatesResponse() then stores the original SyncEntity
   instead of the previous (partially) populated UpdateResponseData.
 - DecryptStoredEntities() gets much simpler because it can now reuse
   PopulateUpdateResponseData() and does not have to duplicate the
   decryption logic.

As a result this CL reconciles all bookmarks adaptations into a single
place in PopulateUpdateResponseData().

This CL does not introduce any behavioral change.

Bug: 1007199
Change-Id: I5ebbfcbaf5dd6bd677aba1697e7ee8d8cd08d75f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1827427
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723431}
parent 8f8ca702
......@@ -142,25 +142,4 @@ void AdaptGuidForBookmark(const sync_pb::SyncEntity& update_entity,
}
}
void AdaptGuidForBookmarkEntityData(EntityData* entity_data) {
DCHECK(entity_data);
DCHECK(entity_data->specifics.has_bookmark());
DCHECK(!entity_data->specifics.has_encrypted());
if (entity_data->is_deleted() ||
!entity_data->server_defined_unique_tag.empty()) {
return;
}
if (entity_data->specifics.bookmark().has_guid()) {
LogGuidSource(BookmarkGuidSource::kSpecifics);
} else if (base::IsValidGUID(entity_data->originator_client_item_id)) {
entity_data->specifics.mutable_bookmark()->set_guid(
entity_data->originator_client_item_id);
LogGuidSource(BookmarkGuidSource::kValidOCII);
} else {
LogGuidSource(BookmarkGuidSource::kLeftEmpty);
}
}
} // namespace syncer
......@@ -37,11 +37,6 @@ void AdaptTitleForBookmark(const sync_pb::SyncEntity& update_entity,
void AdaptGuidForBookmark(const sync_pb::SyncEntity& update_entity,
sync_pb::EntitySpecifics* specifics);
// Analogous to AdaptGuidForBookmark() but deals with EntityData structs.
// |entity_data| must not be null.
// TODO(crbug.com/1007199): Reconcile with AdaptGuidForBookmark().
void AdaptGuidForBookmarkEntityData(EntityData* entity_data);
} // namespace syncer
#endif // COMPONENTS_SYNC_ENGINE_IMPL_BOOKMARK_UPDATE_PREPROCESSING_H_
......@@ -231,10 +231,10 @@ class ModelTypeWorker : public UpdateHandler,
// Interface used to access and send nudges to the sync scheduler. Not owned.
NudgeHandler* nudge_handler_;
// A map of update responses, keyed by server_id.
// Holds updates encrypted with pending keys.
std::map<std::string, std::unique_ptr<UpdateResponseData>>
entries_pending_decryption_;
// A map of sync entities, keyed by server_id. Holds updates encrypted with
// pending keys. Entries are stored in a map for de-duplication (applying only
// the latest).
std::map<std::string, sync_pb::SyncEntity> entries_pending_decryption_;
// Accumulates all the updates from a single GetUpdates cycle in memory so
// they can all be sent to the processor at once.
......
......@@ -127,6 +127,7 @@ INSTANTIATE(EntityMetadata)
INSTANTIATE(EntitySpecifics)
INSTANTIATE(ModelTypeState)
INSTANTIATE(PersistedEntityData)
INSTANTIATE(SyncEntity)
INSTANTIATE(UniquePosition)
} // namespace sync_pb
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment