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

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

Issue 2222373003: [Sync] Adding storage key concept for ModelTypeServices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing redundant hash value. Created 4 years, 4 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/core/shared_model_type_processor.h
diff --git a/components/sync/core/shared_model_type_processor.h b/components/sync/core/shared_model_type_processor.h
index e037ddc9a3d47a0f34b85e49be4d10355f2d7fec..122f410eab732ace6948523c85c3b0fd09d995b3 100644
--- a/components/sync/core/shared_model_type_processor.h
+++ b/components/sync/core/shared_model_type_processor.h
@@ -53,10 +53,10 @@ class SYNC_EXPORT SharedModelTypeProcessor : public ModelTypeProcessor,
bool IsConnected() const;
// ModelTypeChangeProcessor implementation.
- void Put(const std::string& client_tag,
+ void Put(const std::string& storage_key,
std::unique_ptr<EntityData> entity_data,
MetadataChangeList* metadata_change_list) override;
- void Delete(const std::string& client_tag,
+ void Delete(const std::string& storage_key,
MetadataChangeList* metadata_change_list) override;
void OnMetadataLoaded(syncer::SyncError error,
std::unique_ptr<MetadataBatch> batch) override;
@@ -121,15 +121,23 @@ class SYNC_EXPORT SharedModelTypeProcessor : public ModelTypeProcessor,
// Computes the client tag hash for the given client |tag|.
std::string GetHashForTag(const std::string& tag);
- // Gets the entity for the given tag, or null if there isn't one.
- ProcessorEntityTracker* GetEntityForTag(const std::string& tag);
+ // Looks up the client tag hash for the given |storage_key|, and regenerates
+ // with |data| if the lookup finds nothing. Does not update the storage key to
+ // client tag hash mapping.
+ std::string GetClientTagHash(const std::string& storage_key,
+ const EntityData& data);
+
+ // Gets the entity for the given storage key, or null if there isn't one.
+ ProcessorEntityTracker* GetEntityForStorageKey(
+ const std::string& storage_key);
// Gets the entity for the given tag hash, or null if there isn't one.
ProcessorEntityTracker* GetEntityForTagHash(const std::string& tag_hash);
- // Create an entity in the entity map for |tag| and return a pointer to it.
- // Requires that no entity for |tag| already exists in the map.
- ProcessorEntityTracker* CreateEntity(const std::string& tag,
+ // Create an entity in the entity map for |storage_key| and return a pointer
+ // to it.
+ // Requires that no entity for |storage_key| already exists in the map.
+ ProcessorEntityTracker* CreateEntity(const std::string& storage_key,
const EntityData& data);
// Version of the above that generates a tag for |data|.
@@ -158,9 +166,17 @@ class SYNC_EXPORT SharedModelTypeProcessor : public ModelTypeProcessor,
// useful in tests.
std::unique_ptr<CommitQueue> worker_;
- // The set of sync entities known to this object.
+ // A map of client tag hash to sync entities known to this processor. This
+ // should contain entries and metadata for most everything, although the
+ // entities may not always contain model type data/specifics.
EntityMap entities_;
+ // The service wants to communicate entirly 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_|.
+ std::map<std::string, std::string> storage_key_to_tag_hash_;
+
// ModelTypeService linked to this processor.
// The service owns this processor instance so the pointer should never
// become invalid.
« no previous file with comments | « components/sync/core/processor_entity_tracker_unittest.cc ('k') | components/sync/core/shared_model_type_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698