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

Side by Side Diff: chrome/browser/sync/sessions/session_state.h

Issue 9305001: sync: Remove the remaining conflict sets code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review updates and renames Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 const SyncerStatus& syncer_status, 122 const SyncerStatus& syncer_status,
123 const ErrorCounters& errors, 123 const ErrorCounters& errors,
124 int64 num_server_changes_remaining, 124 int64 num_server_changes_remaining,
125 bool is_share_usable, 125 bool is_share_usable,
126 syncable::ModelTypeSet initial_sync_ended, 126 syncable::ModelTypeSet initial_sync_ended,
127 const std::string 127 const std::string
128 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT], 128 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT],
129 bool more_to_sync, 129 bool more_to_sync,
130 bool is_silenced, 130 bool is_silenced,
131 int64 unsynced_count, 131 int64 unsynced_count,
132 int num_blocking_conflicting_updates, 132 int num_blocking_conflicting_updates,
Nicolas Zea 2012/02/02 21:53:41 num_resolvable (here and below)
rlarocque 2012/02/03 22:31:15 Done, sort of. I'm using "simple" instead of reso
133 int num_conflicting_updates, 133 int num_conflicting_updates,
134 bool did_commit_items, 134 bool did_commit_items,
135 const SyncSourceInfo& source, 135 const SyncSourceInfo& source,
136 size_t num_entries, 136 size_t num_entries,
137 base::Time sync_start_time, 137 base::Time sync_start_time,
138 bool retry_scheduled); 138 bool retry_scheduled);
139 ~SyncSessionSnapshot(); 139 ~SyncSessionSnapshot();
140 140
141 // Caller takes ownership of the returned dictionary. 141 // Caller takes ownership of the returned dictionary.
142 base::DictionaryValue* ToValue() const; 142 base::DictionaryValue* ToValue() const;
(...skipping 11 matching lines...) Expand all
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 resolutions.
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 AddSimpleConflictingItemById(const syncable::Id& the_id);
183 void EraseConflictingItemById(const syncable::Id& the_id); 174 void EraseSimpleConflictingItemById(const syncable::Id& the_id);
184 int ConflictingItemsSize() const { return conflicting_item_ids_.size(); } 175 std::set<syncable::Id>::const_iterator SimpleConflictingItemsBegin() const;
185 std::set<syncable::Id>::const_iterator ConflictingItemsBegin() const; 176 std::set<syncable::Id>::const_iterator SimpleConflictingItemsEnd() const;
186 std::set<syncable::Id>::const_iterator ConflictingItemsEnd() const; 177 int SimpleConflictingItemsSize() const {
178 return simple_conflicting_item_ids_.size();
179 }
187 180
188 // Mutators for nonblocking conflicting items (see description below). 181 // Mutators for nonblocking conflicting items (see description below).
189 void AddNonblockingConflictingItemById(const syncable::Id& the_id); 182 void AddEncryptionConflictingItemById(const syncable::Id& the_id);
190 void EraseNonblockingConflictingItemById(const syncable::Id& the_id); 183 int EncryptionConflictingItemsSize() const {
191 int NonblockingConflictingItemsSize() const { 184 return num_encryption_conflicting_items;
192 return nonblocking_conflicting_item_ids_.size();
193 } 185 }
194 186
195 void MergeSets(const syncable::Id& set1, const syncable::Id& set2); 187 void AddHierarchyConflictingItemById(const syncable::Id& id);
196 void CleanupSets(); 188 int HierarchyConflictingItemsSize() const {
189 return num_hierarchy_conflicting_items;
190 }
191
192 void AddServerConflictingItemById(const syncable::Id& id);
193 int ServerConflictingItemsSize() const {
194 return num_server_conflicting_items;
195 }
197 196
198 private: 197 private:
199 // TODO(sync): move away from sets if it makes more sense. 198 // Conflicts that occur when local and server changes collide and can be
200 std::set<syncable::Id> conflicting_item_ids_; 199 // resolved locally.
201 std::map<syncable::Id, ConflictSet*> id_to_conflict_set_; 200 std::set<syncable::Id> simple_conflicting_item_ids_;
202 std::set<ConflictSet*> conflict_sets_;
203 201
204 // Nonblocking conflicts are not processed by the conflict resolver, but 202 // Unresolvable conflicts are not processed by the conflict resolver. We wait
205 // they will be processed in the APPLY_UDPATES_TO_RESOLVE_CONFLICTS step. 203 // and hope the server will provide us with an update that resolves these
206 std::set<syncable::Id> nonblocking_conflicting_item_ids_; 204 // conflicts.
205 std::set<syncable::Id> unresolvable_conflicting_item_ids_;
206
207 size_t num_server_conflicting_items;
208 size_t num_hierarchy_conflicting_items;
209 size_t num_encryption_conflicting_items;
207 210
208 // Whether a conflicting item was added or removed since 211 // Whether a conflicting item was added or removed since
209 // the last call to reset_progress_changed(), if any. In practice this 212 // the last call to reset_progress_changed(), if any. In practice this
210 // points to StatusController::is_dirty_. 213 // points to StatusController::is_dirty_.
211 bool* dirty_; 214 bool* dirty_;
212 }; 215 };
213 216
214 typedef std::pair<VerifyResult, sync_pb::SyncEntity> VerifiedUpdate; 217 typedef std::pair<VerifyResult, sync_pb::SyncEntity> VerifiedUpdate;
215 typedef std::pair<UpdateAttemptResponse, syncable::Id> AppliedUpdate; 218 typedef std::pair<UpdateAttemptResponse, syncable::Id> AppliedUpdate;
216 219
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 ~PerModelSafeGroupState(); 330 ~PerModelSafeGroupState();
328 331
329 UpdateProgress update_progress; 332 UpdateProgress update_progress;
330 ConflictProgress conflict_progress; 333 ConflictProgress conflict_progress;
331 }; 334 };
332 335
333 } // namespace sessions 336 } // namespace sessions
334 } // namespace browser_sync 337 } // namespace browser_sync
335 338
336 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ 339 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698