OLD | NEW |
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_ENTITY_TRACKER_H_ | 5 #ifndef SYNC_ENGINE_ENTITY_TRACKER_H_ |
6 #define SYNC_ENGINE_ENTITY_TRACKER_H_ | 6 #define SYNC_ENGINE_ENTITY_TRACKER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "sync/base/sync_export.h" | 13 #include "sync/base/sync_export.h" |
14 #include "sync/protocol/sync.pb.h" | 14 #include "sync/protocol/sync.pb.h" |
15 | 15 |
16 namespace syncer_v2 { | 16 namespace syncer_v2 { |
17 struct UpdateResponseData; | 17 struct UpdateResponseData; |
18 } // namespace syncer_v2 | |
19 | |
20 namespace syncer { | |
21 | 18 |
22 // Manages the pending commit and update state for an entity on the sync | 19 // Manages the pending commit and update state for an entity on the sync |
23 // thread. | 20 // thread. |
24 // | 21 // |
25 // It should be considered a helper class internal to the | 22 // It should be considered a helper class internal to the |
26 // ModelTypeSyncWorker. | 23 // ModelTypeSyncWorker. |
27 // | 24 // |
28 // Maintains the state associated with a particular sync entity which is | 25 // Maintains the state associated with a particular sync entity which is |
29 // necessary for decision-making on the sync thread. It can track pending | 26 // necessary for decision-making on the sync thread. It can track pending |
30 // commit state, received update state, and can detect conflicts. | 27 // commit state, received update state, and can detect conflicts. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 int64 sequence_number); | 82 int64 sequence_number); |
86 | 83 |
87 // Handles receipt of an update from the server. | 84 // Handles receipt of an update from the server. |
88 void ReceiveUpdate(int64 version); | 85 void ReceiveUpdate(int64 version); |
89 | 86 |
90 // Handles the receipt of an pending update from the server. | 87 // Handles the receipt of an pending update from the server. |
91 // | 88 // |
92 // Returns true if the tracker decides this item is worth keeping. Returns | 89 // Returns true if the tracker decides this item is worth keeping. Returns |
93 // false if the item is discarded, which could happen if the version number | 90 // false if the item is discarded, which could happen if the version number |
94 // is out of date. | 91 // is out of date. |
95 bool ReceivePendingUpdate(const syncer_v2::UpdateResponseData& data); | 92 bool ReceivePendingUpdate(const UpdateResponseData& data); |
96 | 93 |
97 // Functions to fetch the latest pending update. | 94 // Functions to fetch the latest pending update. |
98 bool HasPendingUpdate() const; | 95 bool HasPendingUpdate() const; |
99 syncer_v2::UpdateResponseData GetPendingUpdate() const; | 96 UpdateResponseData GetPendingUpdate() const; |
100 | 97 |
101 // Clears the pending update. Allows us to resume regular commit behavior. | 98 // Clears the pending update. Allows us to resume regular commit behavior. |
102 void ClearPendingUpdate(); | 99 void ClearPendingUpdate(); |
103 | 100 |
104 private: | 101 private: |
105 // Initializes received update state. Does not initialize state related to | 102 // Initializes received update state. Does not initialize state related to |
106 // pending commits and sets |is_commit_pending_| to false. | 103 // pending commits and sets |is_commit_pending_| to false. |
107 EntityTracker(const std::string& id, | 104 EntityTracker(const std::string& id, |
108 const std::string& client_tag_hash, | 105 const std::string& client_tag_hash, |
109 int64 highest_commit_response_version, | 106 int64 highest_commit_response_version, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 int64 base_version_; | 159 int64 base_version_; |
163 base::Time ctime_; | 160 base::Time ctime_; |
164 base::Time mtime_; | 161 base::Time mtime_; |
165 std::string non_unique_name_; | 162 std::string non_unique_name_; |
166 bool deleted_; | 163 bool deleted_; |
167 sync_pb::EntitySpecifics specifics_; | 164 sync_pb::EntitySpecifics specifics_; |
168 | 165 |
169 // An update for this item which can't be applied right now. The presence of | 166 // An update for this item which can't be applied right now. The presence of |
170 // an pending update prevents commits. As of this writing, the only source | 167 // an pending update prevents commits. As of this writing, the only source |
171 // of pending updates is updates we can't decrypt right now. | 168 // of pending updates is updates we can't decrypt right now. |
172 scoped_ptr<syncer_v2::UpdateResponseData> pending_update_; | 169 scoped_ptr<UpdateResponseData> pending_update_; |
173 | 170 |
174 DISALLOW_COPY_AND_ASSIGN(EntityTracker); | 171 DISALLOW_COPY_AND_ASSIGN(EntityTracker); |
175 }; | 172 }; |
176 | 173 |
177 } // namespace syncer | 174 } // namespace syncer |
178 | 175 |
179 #endif // SYNC_ENGINE_ENTITY_TRACKER_H_ | 176 #endif // SYNC_ENGINE_ENTITY_TRACKER_H_ |
OLD | NEW |