OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The 'sessions' namespace comprises all the pieces of state that are | 5 // The 'sessions' namespace comprises all the pieces of state that are |
6 // combined to form a SyncSession instance. In that way, it can be thought of | 6 // combined to form a SyncSession instance. In that way, it can be thought of |
7 // as an extension of the SyncSession type itself. Session scoping gives | 7 // as an extension of the SyncSession type itself. Session scoping gives |
8 // context to things like "conflict progress", "update progress", etc, and the | 8 // context to things like "conflict progress", "update progress", etc, and the |
9 // separation this file provides allows clients to only include the parts they | 9 // separation this file provides allows clients to only include the parts they |
10 // need rather than the entire session stack. | 10 // need rather than the entire session stack. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 const int64 unsynced_count; | 154 const int64 unsynced_count; |
155 const int num_blocking_conflicting_updates; | 155 const int num_blocking_conflicting_updates; |
156 const int num_conflicting_updates; | 156 const int num_conflicting_updates; |
157 const bool did_commit_items; | 157 const bool did_commit_items; |
158 const SyncSourceInfo source; | 158 const SyncSourceInfo source; |
159 const size_t num_entries; | 159 const size_t num_entries; |
160 base::Time sync_start_time; | 160 base::Time sync_start_time; |
161 const bool retry_scheduled; | 161 const bool retry_scheduled; |
162 }; | 162 }; |
163 | 163 |
164 // Tracks progress of conflicts and their resolution using conflict sets. | 164 // Tracks progress of conflicts and their resolution. |
Nicolas Zea
2012/02/01 19:16:19
resolutions
rlarocque
2012/02/02 00:32:56
Done.
| |
165 class ConflictProgress { | 165 class ConflictProgress { |
166 public: | 166 public: |
167 explicit ConflictProgress(bool* dirty_flag); | 167 explicit ConflictProgress(bool* dirty_flag); |
168 ~ConflictProgress(); | 168 ~ConflictProgress(); |
169 // Various iterators, size, and retrieval functions for conflict sets. | 169 |
170 IdToConflictSetMap::const_iterator IdToConflictSetBegin() const; | 170 bool HasSimpleConflictItem(const syncable::Id &id) const; |
171 IdToConflictSetMap::const_iterator IdToConflictSetEnd() const; | |
172 IdToConflictSetMap::size_type IdToConflictSetSize() const; | |
173 IdToConflictSetMap::const_iterator IdToConflictSetFind( | |
174 const syncable::Id& the_id) const; | |
175 const ConflictSet* IdToConflictSetGet(const syncable::Id& the_id); | |
176 std::set<ConflictSet*>::const_iterator ConflictSetsBegin() const; | |
177 std::set<ConflictSet*>::const_iterator ConflictSetsEnd() const; | |
178 std::set<ConflictSet*>::size_type ConflictSetsSize() const; | |
179 bool HasSimpleConflictItem(const syncable::Id& id) const; | |
180 | 171 |
181 // Various mutators for tracking commit conflicts. | 172 // Various mutators for tracking commit conflicts. |
182 void AddConflictingItemById(const syncable::Id& the_id); | 173 void AddConflictingItemById(const syncable::Id& the_id); |
183 void EraseConflictingItemById(const syncable::Id& the_id); | 174 void EraseConflictingItemById(const syncable::Id& the_id); |
184 int ConflictingItemsSize() const { return conflicting_item_ids_.size(); } | 175 int ConflictingItemsSize() const { return conflicting_item_ids_.size(); } |
185 std::set<syncable::Id>::const_iterator ConflictingItemsBegin() const; | 176 std::set<syncable::Id>::const_iterator ConflictingItemsBegin() const; |
186 std::set<syncable::Id>::const_iterator ConflictingItemsEnd() const; | 177 std::set<syncable::Id>::const_iterator ConflictingItemsEnd() const; |
187 | 178 |
188 // Mutators for nonblocking conflicting items (see description below). | 179 // Mutators for nonblocking conflicting items (see description below). |
189 void AddNonblockingConflictingItemById(const syncable::Id& the_id); | 180 void AddNonblockingConflictingItemById(const syncable::Id& the_id); |
190 void EraseNonblockingConflictingItemById(const syncable::Id& the_id); | |
191 int NonblockingConflictingItemsSize() const { | 181 int NonblockingConflictingItemsSize() const { |
192 return nonblocking_conflicting_item_ids_.size(); | 182 return nonblocking_conflicting_item_ids_.size(); |
193 } | 183 } |
194 | 184 |
195 void MergeSets(const syncable::Id& set1, const syncable::Id& set2); | 185 void AddHierarchyConflictingItemById(const syncable::Id& id); |
196 void CleanupSets(); | 186 int HierarchyConflictingItemsSize() const { |
187 return hierarchy_conflicting_item_ids_.size(); | |
188 } | |
197 | 189 |
198 private: | 190 private: |
199 // TODO(sync): move away from sets if it makes more sense. | 191 // Conflicts that occur when an local and server changes collide, minus |
Nicolas Zea
2012/02/01 19:16:19
remove an
rlarocque
2012/02/02 00:32:56
Done.
| |
192 // the nonblocking and hierarchy conflicts. | |
200 std::set<syncable::Id> conflicting_item_ids_; | 193 std::set<syncable::Id> conflicting_item_ids_; |
201 std::map<syncable::Id, ConflictSet*> id_to_conflict_set_; | |
202 std::set<ConflictSet*> conflict_sets_; | |
203 | 194 |
204 // Nonblocking conflicts are not processed by the conflict resolver, but | 195 // Nonblocking conflicts are not processed by the conflict resolver, but |
205 // they will be processed in the APPLY_UDPATES_TO_RESOLVE_CONFLICTS step. | 196 // they will be processed in the APPLY_UDPATES_TO_RESOLVE_CONFLICTS step. |
206 std::set<syncable::Id> nonblocking_conflicting_item_ids_; | 197 std::set<syncable::Id> nonblocking_conflicting_item_ids_; |
207 | 198 |
199 // Hiearchy conflicts are updates that would violate tree invariants if | |
200 // they were applied. | |
201 std::set<syncable::Id> hierarchy_conflicting_item_ids_; | |
rlarocque
2012/01/31 19:12:17
I'm not sure this is the right thing to do. I dec
Nicolas Zea
2012/02/01 19:16:19
I prefer C, probably by adding an extra parameter
rlarocque
2012/02/02 00:32:56
Minor point: If we're going with option C, I'd pre
| |
202 | |
208 // Whether a conflicting item was added or removed since | 203 // Whether a conflicting item was added or removed since |
209 // the last call to reset_progress_changed(), if any. In practice this | 204 // the last call to reset_progress_changed(), if any. In practice this |
210 // points to StatusController::is_dirty_. | 205 // points to StatusController::is_dirty_. |
211 bool* dirty_; | 206 bool* dirty_; |
212 }; | 207 }; |
213 | 208 |
214 typedef std::pair<VerifyResult, sync_pb::SyncEntity> VerifiedUpdate; | 209 typedef std::pair<VerifyResult, sync_pb::SyncEntity> VerifiedUpdate; |
215 typedef std::pair<UpdateAttemptResponse, syncable::Id> AppliedUpdate; | 210 typedef std::pair<UpdateAttemptResponse, syncable::Id> AppliedUpdate; |
216 | 211 |
217 // Tracks update application and verification. | 212 // Tracks update application and verification. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 ~PerModelSafeGroupState(); | 322 ~PerModelSafeGroupState(); |
328 | 323 |
329 UpdateProgress update_progress; | 324 UpdateProgress update_progress; |
330 ConflictProgress conflict_progress; | 325 ConflictProgress conflict_progress; |
331 }; | 326 }; |
332 | 327 |
333 } // namespace sessions | 328 } // namespace sessions |
334 } // namespace browser_sync | 329 } // namespace browser_sync |
335 | 330 |
336 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ | 331 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ |
OLD | NEW |