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

Side by Side Diff: sync/internal_api/public/processor_entity_tracker.h

Issue 1918923002: [Sync] USS: Ignore encryption changes during conflict resolution 1/2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 7 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 SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_ 5 #ifndef SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_
6 #define SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_ 6 #define SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 12
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "sync/api/entity_data.h" 14 #include "sync/api/entity_data.h"
15 #include "sync/base/sync_export.h" 15 #include "sync/base/sync_export.h"
16 #include "sync/protocol/entity_metadata.pb.h" 16 #include "sync/protocol/entity_metadata.pb.h"
17 17
18 namespace syncer_v2 { 18 namespace syncer_v2 {
19 struct CommitRequestData; 19 struct CommitRequestData;
20 struct CommitResponseData;
20 struct UpdateResponseData; 21 struct UpdateResponseData;
21 22
22 // 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
23 // 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
24 // 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
25 // upon a local change until commit confirmation is received. 26 // upon a local change until commit confirmation is received.
26 class SYNC_EXPORT ProcessorEntityTracker { 27 class SYNC_EXPORT ProcessorEntityTracker {
27 public: 28 public:
28 // Construct an instance representing a new locally-created item. 29 // Construct an instance representing a new locally-created item.
29 static std::unique_ptr<ProcessorEntityTracker> CreateNew( 30 static std::unique_ptr<ProcessorEntityTracker> CreateNew(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 void InitializeCommitRequestData(CommitRequestData* request); 89 void InitializeCommitRequestData(CommitRequestData* request);
89 90
90 // Receives a successful commit response. 91 // Receives a successful commit response.
91 // 92 //
92 // Successful commit responses can overwrite an item's ID. 93 // Successful commit responses can overwrite an item's ID.
93 // 94 //
94 // Note that the receipt of a successful commit response does not necessarily 95 // Note that the receipt of a successful commit response does not necessarily
95 // unset IsUnsynced(). If many local changes occur in quick succession, it's 96 // unset IsUnsynced(). If many local changes occur in quick succession, it's
96 // possible that the committed item was already out of date by the time it 97 // possible that the committed item was already out of date by the time it
97 // reached the server. 98 // reached the server.
98 void ReceiveCommitResponse(const std::string& id, 99 void ReceiveCommitResponse(const CommitResponseData& data);
99 int64_t sequence_number,
100 int64_t response_version);
101 100
102 // Clears any in-memory sync state associated with outstanding commits. 101 // Clears any in-memory sync state associated with outstanding commits.
103 void ClearTransientSyncState(); 102 void ClearTransientSyncState();
104 103
105 // Takes the passed commit data and caches it in the instance. 104 // Takes the passed commit data and caches it in the instance.
106 // The data is swapped from the input struct without copying. 105 // The data is swapped from the input struct without copying.
107 void CacheCommitData(EntityData* data); 106 void CacheCommitData(EntityData* data);
108 107
109 // Caches the a copy of |data_ptr|, which doesn't copy the data itself. 108 // Caches the a copy of |data_ptr|, which doesn't copy the data itself.
110 void CacheCommitData(const EntityDataPtr& data_ptr); 109 void CacheCommitData(const EntityDataPtr& data_ptr);
111 110
112 // Check if the instance has cached commit data. 111 // Check if the instance has cached commit data.
113 bool HasCommitData() const; 112 bool HasCommitData() const;
114 113
115 // Check whether |specifics| matches the stored specifics_hash. 114 // Check whether |data| matches the stored specifics hash.
116 bool MatchesSpecificsHash(const sync_pb::EntitySpecifics& specifics) const;
117
118 // Check whether |data| matches the stored metadata.
119 bool MatchesData(const EntityData& data) const; 115 bool MatchesData(const EntityData& data) const;
120 116
121 // Increment sequence number in the metadata. 117 // Check whether |data| matches the stored base (shared between client and
118 // server) specifics hash.
119 bool MatchesBaseData(const EntityData& data) const;
120
121 // Increment sequence number in the metadata. This will also update the
122 // base_specifics_hash if the entity was not already unsynced.
122 void IncrementSequenceNumber(); 123 void IncrementSequenceNumber();
123 124
124 private: 125 private:
125 friend class ProcessorEntityTrackerTest; 126 friend class ProcessorEntityTrackerTest;
126 127
127 // The constructor swaps the data from the passed metadata. 128 // The constructor swaps the data from the passed metadata.
128 ProcessorEntityTracker(const std::string& client_tag, 129 ProcessorEntityTracker(const std::string& client_tag,
129 sync_pb::EntityMetadata* metadata); 130 sync_pb::EntityMetadata* metadata);
130 131
132 // Check whether |specifics| matches the stored specifics_hash.
133 bool MatchesSpecificsHash(const sync_pb::EntitySpecifics& specifics) const;
134
131 // Update hash string for EntitySpecifics in the metadata. 135 // Update hash string for EntitySpecifics in the metadata.
132 void UpdateSpecificsHash(const sync_pb::EntitySpecifics& specifics); 136 void UpdateSpecificsHash(const sync_pb::EntitySpecifics& specifics);
133 137
134 // Client tag. Should always be available. 138 // Client tag. Should always be available.
135 std::string client_tag_; 139 std::string client_tag_;
136 140
137 // Serializable Sync metadata. 141 // Serializable Sync metadata.
138 sync_pb::EntityMetadata metadata_; 142 sync_pb::EntityMetadata metadata_;
139 143
140 // Sync data that exists for items being committed only. 144 // Sync data that exists for items being committed only.
141 // The data is reset once commit confirmation is received. 145 // The data is reset once commit confirmation is received.
142 EntityDataPtr commit_data_; 146 EntityDataPtr commit_data_;
143 147
144 // 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.
145 int64_t commit_requested_sequence_number_; 149 int64_t commit_requested_sequence_number_;
146 }; 150 };
147 151
148 } // namespace syncer_v2 152 } // namespace syncer_v2
149 153
150 #endif // SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_ 154 #endif // SYNC_INTERNAL_API_PUBLIC_PROCESSOR_ENTITY_TRACKER_H_
OLDNEW
« no previous file with comments | « sync/internal_api/public/non_blocking_sync_common.cc ('k') | sync/internal_api/shared_model_type_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698