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

Side by Side Diff: sync/engine/worker_entity_tracker.h

Issue 1933803002: [Sync] USS: Ignore encryption changes during conflict resolution 2/2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment. 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_ENGINE_WORKER_ENTITY_TRACKER_H_ 5 #ifndef SYNC_ENGINE_WORKER_ENTITY_TRACKER_H_
6 #define SYNC_ENGINE_WORKER_ENTITY_TRACKER_H_ 6 #define SYNC_ENGINE_WORKER_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/macros.h" 13 #include "base/macros.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "sync/base/sync_export.h" 15 #include "sync/base/sync_export.h"
16 #include "sync/protocol/sync.pb.h" 16 #include "sync/protocol/sync.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 // Manages the pending commit and update state for an entity on the sync 23 // Manages the pending commit and update state for an entity on the sync
23 // thread. 24 // thread.
24 // 25 //
25 // It should be considered a helper class internal to the 26 // It should be considered a helper class internal to the
26 // ModelTypeWorker. 27 // ModelTypeWorker.
27 // 28 //
28 // Maintains the state associated with a particular sync entity which is 29 // Maintains the state associated with a particular sync entity which is
29 // necessary for decision-making on the sync thread. It can track pending 30 // necessary for decision-making on the sync thread. It can track pending
30 // commit state, received update state, and can detect conflicts. 31 // commit state, received update state, and can detect conflicts.
31 // 32 //
32 // This object may contain state associated with a pending commit, pending 33 // This object may contain state associated with a pending commit, pending
33 // update, or both. 34 // update, or both.
34 class SYNC_EXPORT WorkerEntityTracker { 35 class SYNC_EXPORT WorkerEntityTracker {
35 public: 36 public:
36 // Initializes the entity tracker's main fields. Does not initialize state 37 // Initializes the entity tracker's main fields. Does not initialize state
37 // related to a pending commit. 38 // related to a pending commit.
38 WorkerEntityTracker(const std::string& id, 39 WorkerEntityTracker(const std::string& id,
39 const std::string& client_tag_hash); 40 const std::string& client_tag_hash);
40 41
41 ~WorkerEntityTracker(); 42 ~WorkerEntityTracker();
42 43
43 // Returns true if this entity should be commited to the server. 44 // Returns true if this entity should be commited to the server.
44 bool HasPendingCommit() const; 45 bool HasPendingCommit() const;
45 46
46 // Populates a sync_pb::SyncEntity for a commit. Also sets the 47 // Populates a sync_pb::SyncEntity for a commit.
47 // |sequence_number|, so we can track it throughout the commit process. 48 void PopulateCommitProto(sync_pb::SyncEntity* commit_entity) const;
48 void PopulateCommitProto(sync_pb::SyncEntity* commit_entity,
49 int64_t* sequence_number) const;
50 49
51 // Updates this entity with data from the latest version that the 50 // Updates this entity with data from the latest version that the
52 // model asked us to commit. May clobber state related to the 51 // model asked us to commit. May clobber state related to the
53 // model's previous commit attempt(s). 52 // model's previous commit attempt(s).
54 void RequestCommit(const CommitRequestData& data); 53 void RequestCommit(const CommitRequestData& data);
55 54
56 // Handles the receipt of a commit response. 55 // Tracks the receipt of a commit response and fills in some local-only data
57 // 56 // on it to be passed back to the processor.
58 // Since commits happen entirely on the sync thread, we can safely assume 57 void ReceiveCommitResponse(CommitResponseData* ack);
59 // that our item's state at the end of the commit is the same as it was at
60 // the start.
61 void ReceiveCommitResponse(const std::string& response_id,
62 int64_t response_version,
63 int64_t sequence_number);
64 58
65 // Handles receipt of an update from the server. 59 // Handles receipt of an update from the server.
66 void ReceiveUpdate(int64_t version); 60 void ReceiveUpdate(int64_t version);
67 61
68 // Handles the receipt of an encrypted update from the server. 62 // Handles the receipt of an encrypted update from the server.
69 // 63 //
70 // Returns true if the tracker decides this item is worth keeping. Returns 64 // Returns true if the tracker decides this item is worth keeping. Returns
71 // false if the item is discarded, which could happen if the version number 65 // false if the item is discarded, which could happen if the version number
72 // is out of date. 66 // is out of date.
73 bool ReceiveEncryptedUpdate(const UpdateResponseData& data); 67 bool ReceiveEncryptedUpdate(const UpdateResponseData& data);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // to do here is return it back to the model thread when the pending commit 102 // to do here is return it back to the model thread when the pending commit
109 // is completed and confirmed. Not valid if no commit is pending. 103 // is completed and confirmed. Not valid if no commit is pending.
110 int64_t sequence_number_; 104 int64_t sequence_number_;
111 105
112 // The server version on which this item is based. 106 // The server version on which this item is based.
113 int64_t base_version_; 107 int64_t base_version_;
114 108
115 // A commit for this entity waiting for a sync cycle to be committed. 109 // A commit for this entity waiting for a sync cycle to be committed.
116 std::unique_ptr<CommitRequestData> pending_commit_; 110 std::unique_ptr<CommitRequestData> pending_commit_;
117 111
112 // The specifics hash for the pending commit if there is one, "" otherwise.
113 std::string pending_commit_specifics_hash_;
114
118 // An update for this entity which can't be applied right now. The presence 115 // An update for this entity which can't be applied right now. The presence
119 // of an pending update prevents commits. As of this writing, the only 116 // of an pending update prevents commits. As of this writing, the only
120 // source of pending updates is updates that can't currently be decrypted. 117 // source of pending updates is updates that can't currently be decrypted.
121 std::unique_ptr<UpdateResponseData> encrypted_update_; 118 std::unique_ptr<UpdateResponseData> encrypted_update_;
122 119
123 DISALLOW_COPY_AND_ASSIGN(WorkerEntityTracker); 120 DISALLOW_COPY_AND_ASSIGN(WorkerEntityTracker);
124 }; 121 };
125 122
126 } // namespace syncer_v2 123 } // namespace syncer_v2
127 124
128 #endif // SYNC_ENGINE_WORKER_ENTITY_TRACKER_H_ 125 #endif // SYNC_ENGINE_WORKER_ENTITY_TRACKER_H_
OLDNEW
« no previous file with comments | « sync/engine/non_blocking_type_commit_contribution.cc ('k') | sync/engine/worker_entity_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698