| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // Count the number of successful update applications that have happend this | 167 // Count the number of successful update applications that have happend this |
| 168 // cycle. Note that if an item is successfully applied twice, it will be | 168 // cycle. Note that if an item is successfully applied twice, it will be |
| 169 // double counted here. | 169 // double counted here. |
| 170 int SuccessfullyAppliedUpdateCount() const; | 170 int SuccessfullyAppliedUpdateCount() const; |
| 171 | 171 |
| 172 // Returns true if at least one update application failed due to a conflict | 172 // Returns true if at least one update application failed due to a conflict |
| 173 // during this sync cycle. | 173 // during this sync cycle. |
| 174 bool HasConflictingUpdates() const; | 174 bool HasConflictingUpdates() const; |
| 175 | 175 |
| 176 private: | 176 private: |
| 177 // Some container for updates that failed verification. | 177 // Container for updates that passed verification. |
| 178 std::vector<VerifiedUpdate> verified_updates_; | 178 std::vector<VerifiedUpdate> verified_updates_; |
| 179 | 179 |
| 180 // Stores the result of the various ApplyUpdate attempts we've made. | 180 // Stores the result of the various ApplyUpdate attempts we've made. |
| 181 // May contain duplicate entries. | 181 // May contain duplicate entries. |
| 182 std::vector<AppliedUpdate> applied_updates_; | 182 std::vector<AppliedUpdate> applied_updates_; |
| 183 }; | 183 }; |
| 184 | 184 |
| 185 struct SyncCycleControlParameters { | 185 struct SyncCycleControlParameters { |
| 186 SyncCycleControlParameters() : conflict_sets_built(false), | 186 SyncCycleControlParameters() : conflict_sets_built(false), |
| 187 conflicts_resolved(false), | 187 conflicts_resolved(false), |
| 188 items_committed(false), | 188 items_committed(false) {} |
| 189 got_new_timestamp(false) {} | |
| 190 // Set to true by BuildAndProcessConflictSetsCommand if the RESOLVE_CONFLICTS | 189 // Set to true by BuildAndProcessConflictSetsCommand if the RESOLVE_CONFLICTS |
| 191 // step is needed. | 190 // step is needed. |
| 192 bool conflict_sets_built; | 191 bool conflict_sets_built; |
| 193 | 192 |
| 194 // Set to true by ResolveConflictsCommand if any forward progress was made. | 193 // Set to true by ResolveConflictsCommand if any forward progress was made. |
| 195 bool conflicts_resolved; | 194 bool conflicts_resolved; |
| 196 | 195 |
| 197 // Set to true by PostCommitMessageCommand if any commits were successful. | 196 // Set to true by PostCommitMessageCommand if any commits were successful. |
| 198 bool items_committed; | 197 bool items_committed; |
| 199 | |
| 200 // The server sent us updates and a newer timestamp as part of the session. | |
| 201 bool got_new_timestamp; | |
| 202 }; | 198 }; |
| 203 | 199 |
| 204 // DirtyOnWrite wraps a value such that any write operation will update a | 200 // DirtyOnWrite wraps a value such that any write operation will update a |
| 205 // specified dirty bit, which can be used to determine if a notification should | 201 // specified dirty bit, which can be used to determine if a notification should |
| 206 // be sent due to state change. | 202 // be sent due to state change. |
| 207 template <typename T> | 203 template <typename T> |
| 208 class DirtyOnWrite { | 204 class DirtyOnWrite { |
| 209 public: | 205 public: |
| 210 explicit DirtyOnWrite(bool* dirty) : dirty_(dirty) {} | 206 explicit DirtyOnWrite(bool* dirty) : dirty_(dirty) {} |
| 211 DirtyOnWrite(bool* dirty, const T& t) : t_(t), dirty_(dirty) {} | 207 DirtyOnWrite(bool* dirty, const T& t) : t_(t), dirty_(dirty) {} |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 struct PerModelTypeState { | 258 struct PerModelTypeState { |
| 263 explicit PerModelTypeState(bool* dirty_flag) | 259 explicit PerModelTypeState(bool* dirty_flag) |
| 264 : current_sync_timestamp(dirty_flag, 0) {} | 260 : current_sync_timestamp(dirty_flag, 0) {} |
| 265 DirtyOnWrite<int64> current_sync_timestamp; | 261 DirtyOnWrite<int64> current_sync_timestamp; |
| 266 }; | 262 }; |
| 267 | 263 |
| 268 } // namespace sessions | 264 } // namespace sessions |
| 269 } // namespace browser_sync | 265 } // namespace browser_sync |
| 270 | 266 |
| 271 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ | 267 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ |
| OLD | NEW |