bookmark_update_preprocessing.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // This file contains various utility functions used by ModelTypeWorker to
  5. // preprocess remote bookmark updates, to deal with backward-compatibility of
  6. // data and migrate updates such that they resemble updates from a modern
  7. // client.
  8. #ifndef COMPONENTS_SYNC_ENGINE_BOOKMARK_UPDATE_PREPROCESSING_H_
  9. #define COMPONENTS_SYNC_ENGINE_BOOKMARK_UPDATE_PREPROCESSING_H_
  10. #include <string>
  11. namespace sync_pb {
  12. class SyncEntity;
  13. class EntitySpecifics;
  14. } // namespace sync_pb
  15. namespace syncer {
  16. // Populates |specifics->bookmark().unique_position()| from the various
  17. // supported proto fields in |update_entity| and worst-case falls back to a
  18. // random position. |specifics| must not be null. Returns true if
  19. // |unique_position| has been changed.
  20. bool AdaptUniquePositionForBookmark(const sync_pb::SyncEntity& update_entity,
  21. sync_pb::EntitySpecifics* specifics);
  22. // Populates |specifics->bookmark().type()| (i.e. whether a bookmark is a
  23. // folder) for the cases where the field isn't populated.
  24. void AdaptTypeForBookmark(const sync_pb::SyncEntity& update_entity,
  25. sync_pb::EntitySpecifics* specifics);
  26. // Populates |specifics->bookmark().legacy_canonicalized_title()| from the
  27. // various supported sources, or no-op if specifics already have the field set.
  28. // |specifics| must not be null.
  29. void AdaptTitleForBookmark(const sync_pb::SyncEntity& update_entity,
  30. sync_pb::EntitySpecifics* specifics,
  31. bool specifics_were_encrypted);
  32. // Tries to populates |specifics->bookmark().guid()| from the various supported
  33. // sources, or no-op if a) specifics already have the field set; or b) the GUID
  34. // cannot be inferred. |specifics| must not be null.
  35. void AdaptGuidForBookmark(const sync_pb::SyncEntity& update_entity,
  36. sync_pb::EntitySpecifics* specifics);
  37. // GUID-inferring function exposed for testing.
  38. std::string InferGuidForLegacyBookmarkForTesting(
  39. const std::string& originator_cache_guid,
  40. const std::string& originator_client_item_id);
  41. } // namespace syncer
  42. #endif // COMPONENTS_SYNC_ENGINE_BOOKMARK_UPDATE_PREPROCESSING_H_