Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Unified Diff: components/sync/model_impl/shared_model_type_processor.h

Issue 2915763005: [Sync] Implement support for updating storage key for new entities (Closed)
Patch Set: Rebase. Fix recommit for encryption scenario. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/sync/model_impl/shared_model_type_processor.h
diff --git a/components/sync/model_impl/shared_model_type_processor.h b/components/sync/model_impl/shared_model_type_processor.h
index d8b54483b8e008cff802ac04bc926c12144941b7..17ac9e9617057fda49f7b6e138a28306accb1efa 100644
--- a/components/sync/model_impl/shared_model_type_processor.h
+++ b/components/sync/model_impl/shared_model_type_processor.h
@@ -56,8 +56,8 @@ class SharedModelTypeProcessor : public ModelTypeProcessor,
MetadataChangeList* metadata_change_list) override;
void Delete(const std::string& storage_key,
MetadataChangeList* metadata_change_list) override;
- void UpdateStorageKey(const std::string& old_storage_key,
- const std::string& new_storage_key,
+ void UpdateStorageKey(const EntityData& entity_data,
+ const std::string& storage_key,
MetadataChangeList* metadata_change_list) override;
void ModelReadyToSync(std::unique_ptr<MetadataBatch> batch) override;
void OnSyncStarting(const ModelErrorHandler& error_handler,
@@ -145,6 +145,9 @@ class SharedModelTypeProcessor : public ModelTypeProcessor,
// Version of the above that generates a tag for |data|.
ProcessorEntityTracker* CreateEntity(const EntityData& data);
+ // Returns true if all processor entity trackers have non-empty storage keys.
+ bool AllStorageKeysPopulated() const;
+
/////////////////////
// Processor state //
/////////////////////
@@ -204,10 +207,15 @@ class SharedModelTypeProcessor : public ModelTypeProcessor,
// entities may not always contain model type data/specifics.
std::map<std::string, std::unique_ptr<ProcessorEntityTracker>> entities_;
- // The bridge wants to communicate entirely via storage keys that is free to
- // define and can understand more easily. All of the sync machinery wants to
- // use client tag hash. This mapping allows us to convert from storage key to
- // client tag hash. The other direction can use |entities_|.
+ // The bridge wants to communicate entirely via storage keys that it is free
+ // to define and can understand more easily. All of the sync machinery wants
+ // to use client tag hash. This mapping allows us to convert from storage key
+ // to client tag hash. The other direction can use |entities_|.
+ // Entity is temporarily not included in this map for the duration of
+ // MergeSyncData/ApplySyncChanges call when the bridge doesn't support
+ // GetStorageKey(). In this case the bridge is responsible for updating
+ // storage key with UpdateStorageKey() call from within
+ // MergeSyncData/ApplySyncChanges.
std::map<std::string, std::string> storage_key_to_tag_hash_;
SEQUENCE_CHECKER(sequence_checker_);

Powered by Google App Engine
This is Rietveld 408576698