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

Side by Side Diff: components/sync/core/processor_entity_tracker.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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_SYNC_CORE_PROCESSOR_ENTITY_TRACKER_H_ 5 #ifndef COMPONENTS_SYNC_CORE_PROCESSOR_ENTITY_TRACKER_H_
6 #define COMPONENTS_SYNC_CORE_PROCESSOR_ENTITY_TRACKER_H_ 6 #define COMPONENTS_SYNC_CORE_PROCESSOR_ENTITY_TRACKER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 10 matching lines...) Expand all
21 struct UpdateResponseData; 21 struct UpdateResponseData;
22 22
23 // This class is used by the SharedModelTypeProcessor to track the state of each 23 // This class is used by the SharedModelTypeProcessor to track the state of each
24 // entity with its type. It can be considered a helper class internal to the 24 // entity with its type. It can be considered a helper class internal to the
25 // processor. It manages the metadata for its entity and caches entity data 25 // processor. It manages the metadata for its entity and caches entity data
26 // upon a local change until commit confirmation is received. 26 // upon a local change until commit confirmation is received.
27 class SYNC_EXPORT ProcessorEntityTracker { 27 class SYNC_EXPORT ProcessorEntityTracker {
28 public: 28 public:
29 // Construct an instance representing a new locally-created item. 29 // Construct an instance representing a new locally-created item.
30 static std::unique_ptr<ProcessorEntityTracker> CreateNew( 30 static std::unique_ptr<ProcessorEntityTracker> CreateNew(
31 const std::string& client_tag, 31 const std::string& storage_key,
32 const std::string& client_tag_hash, 32 const std::string& client_tag_hash,
33 const std::string& id, 33 const std::string& id,
34 base::Time creation_time); 34 base::Time creation_time);
35 35
36 // Construct an instance representing an item loaded from storage on init. 36 // Construct an instance representing an item loaded from storage on init.
37 // This method swaps out the contents of |metadata|. 37 // This method swaps out the contents of |metadata|.
38 static std::unique_ptr<ProcessorEntityTracker> CreateFromMetadata( 38 static std::unique_ptr<ProcessorEntityTracker> CreateFromMetadata(
39 const std::string& client_tag, 39 const std::string& storage_key,
40 sync_pb::EntityMetadata* metadata); 40 sync_pb::EntityMetadata* metadata);
41 41
42 ~ProcessorEntityTracker(); 42 ~ProcessorEntityTracker();
43 43
44 const std::string& client_tag() const { return client_tag_; } 44 const std::string& storage_key() const { return storage_key_; }
45 const sync_pb::EntityMetadata& metadata() const { return metadata_; } 45 const sync_pb::EntityMetadata& metadata() const { return metadata_; }
46 const EntityDataPtr& commit_data() const { return commit_data_; } 46 const EntityDataPtr& commit_data() const { return commit_data_; }
47 47
48 // Returns true if this data is out of sync with the server. 48 // Returns true if this data is out of sync with the server.
49 // A commit may or may not be in progress at this time. 49 // A commit may or may not be in progress at this time.
50 bool IsUnsynced() const; 50 bool IsUnsynced() const;
51 51
52 // Returns true if this data is out of sync with the sync thread. 52 // Returns true if this data is out of sync with the sync thread.
53 // 53 //
54 // There may or may not be a commit in progress for this item, but there's 54 // There may or may not be a commit in progress for this item, but there's
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 bool MatchesBaseData(const EntityData& data) const; 119 bool MatchesBaseData(const EntityData& data) const;
120 120
121 // Increment sequence number in the metadata. This will also update the 121 // Increment sequence number in the metadata. This will also update the
122 // base_specifics_hash if the entity was not already unsynced. 122 // base_specifics_hash if the entity was not already unsynced.
123 void IncrementSequenceNumber(); 123 void IncrementSequenceNumber();
124 124
125 private: 125 private:
126 friend class ProcessorEntityTrackerTest; 126 friend class ProcessorEntityTrackerTest;
127 127
128 // The constructor swaps the data from the passed metadata. 128 // The constructor swaps the data from the passed metadata.
129 ProcessorEntityTracker(const std::string& client_tag, 129 ProcessorEntityTracker(const std::string& storage_key,
130 sync_pb::EntityMetadata* metadata); 130 sync_pb::EntityMetadata* metadata);
131 131
132 // Check whether |specifics| matches the stored specifics_hash. 132 // Check whether |specifics| matches the stored specifics_hash.
133 bool MatchesSpecificsHash(const sync_pb::EntitySpecifics& specifics) const; 133 bool MatchesSpecificsHash(const sync_pb::EntitySpecifics& specifics) const;
134 134
135 // Update hash string for EntitySpecifics in the metadata. 135 // Update hash string for EntitySpecifics in the metadata.
136 void UpdateSpecificsHash(const sync_pb::EntitySpecifics& specifics); 136 void UpdateSpecificsHash(const sync_pb::EntitySpecifics& specifics);
137 137
138 // Client tag. Should always be available. 138 // Storage key. Should always be available.
139 std::string client_tag_; 139 const std::string storage_key_;
140 140
141 // Serializable Sync metadata. 141 // Serializable Sync metadata.
142 sync_pb::EntityMetadata metadata_; 142 sync_pb::EntityMetadata metadata_;
143 143
144 // Sync data that exists for items being committed only. 144 // Sync data that exists for items being committed only.
145 // The data is reset once commit confirmation is received. 145 // The data is reset once commit confirmation is received.
146 EntityDataPtr commit_data_; 146 EntityDataPtr commit_data_;
147 147
148 // The sequence number of the last item sent to the sync thread. 148 // The sequence number of the last item sent to the sync thread.
149 int64_t commit_requested_sequence_number_; 149 int64_t commit_requested_sequence_number_;
150 }; 150 };
151 151
152 } // namespace syncer_v2 152 } // namespace syncer_v2
153 153
154 #endif // COMPONENTS_SYNC_CORE_PROCESSOR_ENTITY_TRACKER_H_ 154 #endif // COMPONENTS_SYNC_CORE_PROCESSOR_ENTITY_TRACKER_H_
OLDNEW
« no previous file with comments | « components/sync/core/data_batch_impl_unittest.cc ('k') | components/sync/core/processor_entity_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698