| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 const SyncerStatus& syncer_status, | 113 const SyncerStatus& syncer_status, |
| 114 const ErrorCounters& errors, | 114 const ErrorCounters& errors, |
| 115 int64 num_server_changes_remaining, | 115 int64 num_server_changes_remaining, |
| 116 bool is_share_usable, | 116 bool is_share_usable, |
| 117 syncable::ModelTypeSet initial_sync_ended, | 117 syncable::ModelTypeSet initial_sync_ended, |
| 118 const std::string | 118 const std::string |
| 119 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT], | 119 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT], |
| 120 bool more_to_sync, | 120 bool more_to_sync, |
| 121 bool is_silenced, | 121 bool is_silenced, |
| 122 int64 unsynced_count, | 122 int64 unsynced_count, |
| 123 int num_blocking_conflicting_updates, | 123 int num_simple_conflicting_updates, |
| 124 int num_conflicting_updates, | 124 int num_conflicting_updates, |
| 125 bool did_commit_items, | 125 bool did_commit_items, |
| 126 const SyncSourceInfo& source, | 126 const SyncSourceInfo& source, |
| 127 size_t num_entries, | 127 size_t num_entries, |
| 128 base::Time sync_start_time, | 128 base::Time sync_start_time, |
| 129 bool retry_scheduled); | 129 bool retry_scheduled); |
| 130 ~SyncSessionSnapshot(); | 130 ~SyncSessionSnapshot(); |
| 131 | 131 |
| 132 // Caller takes ownership of the returned dictionary. | 132 // Caller takes ownership of the returned dictionary. |
| 133 base::DictionaryValue* ToValue() const; | 133 base::DictionaryValue* ToValue() const; |
| 134 | 134 |
| 135 std::string ToString() const; | 135 std::string ToString() const; |
| 136 | 136 |
| 137 const SyncerStatus syncer_status; | 137 const SyncerStatus syncer_status; |
| 138 const ErrorCounters errors; | 138 const ErrorCounters errors; |
| 139 const int64 num_server_changes_remaining; | 139 const int64 num_server_changes_remaining; |
| 140 const bool is_share_usable; | 140 const bool is_share_usable; |
| 141 const syncable::ModelTypeSet initial_sync_ended; | 141 const syncable::ModelTypeSet initial_sync_ended; |
| 142 const std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; | 142 const std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; |
| 143 const bool has_more_to_sync; | 143 const bool has_more_to_sync; |
| 144 const bool is_silenced; | 144 const bool is_silenced; |
| 145 const int64 unsynced_count; | 145 const int64 unsynced_count; |
| 146 const int num_blocking_conflicting_updates; | 146 const int num_simple_conflicting_updates; |
| 147 const int num_conflicting_updates; | 147 const int num_conflicting_updates; |
| 148 const bool did_commit_items; | 148 const bool did_commit_items; |
| 149 const SyncSourceInfo source; | 149 const SyncSourceInfo source; |
| 150 const size_t num_entries; | 150 const size_t num_entries; |
| 151 base::Time sync_start_time; | 151 base::Time sync_start_time; |
| 152 const bool retry_scheduled; | 152 const bool retry_scheduled; |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 // Tracks progress of conflicts and their resolution using conflict sets. | 155 // Tracks progress of conflicts and their resolutions. |
| 156 class ConflictProgress { | 156 class ConflictProgress { |
| 157 public: | 157 public: |
| 158 explicit ConflictProgress(bool* dirty_flag); | 158 explicit ConflictProgress(bool* dirty_flag); |
| 159 ~ConflictProgress(); | 159 ~ConflictProgress(); |
| 160 // Various iterators, size, and retrieval functions for conflict sets. | 160 |
| 161 IdToConflictSetMap::const_iterator IdToConflictSetBegin() const; | 161 bool HasSimpleConflictItem(const syncable::Id &id) const; |
| 162 IdToConflictSetMap::const_iterator IdToConflictSetEnd() const; | |
| 163 IdToConflictSetMap::size_type IdToConflictSetSize() const; | |
| 164 IdToConflictSetMap::const_iterator IdToConflictSetFind( | |
| 165 const syncable::Id& the_id) const; | |
| 166 const ConflictSet* IdToConflictSetGet(const syncable::Id& the_id); | |
| 167 std::set<ConflictSet*>::const_iterator ConflictSetsBegin() const; | |
| 168 std::set<ConflictSet*>::const_iterator ConflictSetsEnd() const; | |
| 169 std::set<ConflictSet*>::size_type ConflictSetsSize() const; | |
| 170 bool HasSimpleConflictItem(const syncable::Id& id) const; | |
| 171 | 162 |
| 172 // Various mutators for tracking commit conflicts. | 163 // Various mutators for tracking commit conflicts. |
| 173 void AddConflictingItemById(const syncable::Id& the_id); | 164 void AddSimpleConflictingItemById(const syncable::Id& the_id); |
| 174 void EraseConflictingItemById(const syncable::Id& the_id); | 165 void EraseSimpleConflictingItemById(const syncable::Id& the_id); |
| 175 int ConflictingItemsSize() const { return conflicting_item_ids_.size(); } | 166 std::set<syncable::Id>::const_iterator SimpleConflictingItemsBegin() const; |
| 176 std::set<syncable::Id>::const_iterator ConflictingItemsBegin() const; | 167 std::set<syncable::Id>::const_iterator SimpleConflictingItemsEnd() const; |
| 177 std::set<syncable::Id>::const_iterator ConflictingItemsEnd() const; | 168 int SimpleConflictingItemsSize() const { |
| 178 | 169 return simple_conflicting_item_ids_.size(); |
| 179 // Mutators for nonblocking conflicting items (see description below). | |
| 180 void AddNonblockingConflictingItemById(const syncable::Id& the_id); | |
| 181 void EraseNonblockingConflictingItemById(const syncable::Id& the_id); | |
| 182 int NonblockingConflictingItemsSize() const { | |
| 183 return nonblocking_conflicting_item_ids_.size(); | |
| 184 } | 170 } |
| 185 | 171 |
| 186 void MergeSets(const syncable::Id& set1, const syncable::Id& set2); | 172 // Mutators for unresolvable conflicting items (see description below). |
| 187 void CleanupSets(); | 173 void AddEncryptionConflictingItemById(const syncable::Id& the_id); |
| 174 int EncryptionConflictingItemsSize() const { |
| 175 return num_encryption_conflicting_items; |
| 176 } |
| 177 |
| 178 void AddHierarchyConflictingItemById(const syncable::Id& id); |
| 179 int HierarchyConflictingItemsSize() const { |
| 180 return num_hierarchy_conflicting_items; |
| 181 } |
| 182 |
| 183 void AddServerConflictingItemById(const syncable::Id& id); |
| 184 int ServerConflictingItemsSize() const { |
| 185 return num_server_conflicting_items; |
| 186 } |
| 188 | 187 |
| 189 private: | 188 private: |
| 190 // TODO(sync): move away from sets if it makes more sense. | 189 // Conflicts that occur when local and server changes collide and can be |
| 191 std::set<syncable::Id> conflicting_item_ids_; | 190 // resolved locally. |
| 192 std::map<syncable::Id, ConflictSet*> id_to_conflict_set_; | 191 std::set<syncable::Id> simple_conflicting_item_ids_; |
| 193 std::set<ConflictSet*> conflict_sets_; | |
| 194 | 192 |
| 195 // Nonblocking conflicts are not processed by the conflict resolver, but | 193 // Unresolvable conflicts are not processed by the conflict resolver. We wait |
| 196 // they will be processed in the APPLY_UDPATES_TO_RESOLVE_CONFLICTS step. | 194 // and hope the server will provide us with an update that resolves these |
| 197 std::set<syncable::Id> nonblocking_conflicting_item_ids_; | 195 // conflicts. |
| 196 std::set<syncable::Id> unresolvable_conflicting_item_ids_; |
| 197 |
| 198 size_t num_server_conflicting_items; |
| 199 size_t num_hierarchy_conflicting_items; |
| 200 size_t num_encryption_conflicting_items; |
| 198 | 201 |
| 199 // Whether a conflicting item was added or removed since | 202 // Whether a conflicting item was added or removed since |
| 200 // the last call to reset_progress_changed(), if any. In practice this | 203 // the last call to reset_progress_changed(), if any. In practice this |
| 201 // points to StatusController::is_dirty_. | 204 // points to StatusController::is_dirty_. |
| 202 bool* dirty_; | 205 bool* dirty_; |
| 203 }; | 206 }; |
| 204 | 207 |
| 205 typedef std::pair<VerifyResult, sync_pb::SyncEntity> VerifiedUpdate; | 208 typedef std::pair<VerifyResult, sync_pb::SyncEntity> VerifiedUpdate; |
| 206 typedef std::pair<UpdateAttemptResponse, syncable::Id> AppliedUpdate; | 209 typedef std::pair<UpdateAttemptResponse, syncable::Id> AppliedUpdate; |
| 207 | 210 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 ~PerModelSafeGroupState(); | 321 ~PerModelSafeGroupState(); |
| 319 | 322 |
| 320 UpdateProgress update_progress; | 323 UpdateProgress update_progress; |
| 321 ConflictProgress conflict_progress; | 324 ConflictProgress conflict_progress; |
| 322 }; | 325 }; |
| 323 | 326 |
| 324 } // namespace sessions | 327 } // namespace sessions |
| 325 } // namespace browser_sync | 328 } // namespace browser_sync |
| 326 | 329 |
| 327 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ | 330 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ |
| OLD | NEW |