Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace browser_sync { | 30 namespace browser_sync { |
| 31 namespace sessions { | 31 namespace sessions { |
| 32 | 32 |
| 33 class UpdateProgress; | 33 class UpdateProgress; |
| 34 | 34 |
| 35 // Data pertaining to the status of an active Syncer object. | 35 // Data pertaining to the status of an active Syncer object. |
| 36 struct SyncerStatus { | 36 struct SyncerStatus { |
| 37 SyncerStatus() | 37 SyncerStatus() |
| 38 : invalid_store(false), syncer_stuck(false), | 38 : invalid_store(false), |
| 39 syncing(false), num_successful_commits(0), | 39 syncer_stuck(false), |
| 40 num_successful_bookmark_commits(0) {} | 40 syncing(false), |
| 41 num_successful_commits(0), | |
| 42 num_successful_bookmark_commits(0), | |
| 43 num_updates_downloaded(0), | |
| 44 num_tombstone_updates_downloaded(0) {} | |
| 41 | 45 |
| 42 // True when we get such an INVALID_STORE error from the server. | 46 // True when we get such an INVALID_STORE error from the server. |
| 43 bool invalid_store; | 47 bool invalid_store; |
| 44 // True iff we're stuck. | 48 // True iff we're stuck. |
| 45 bool syncer_stuck; | 49 bool syncer_stuck; |
| 46 bool syncing; | 50 bool syncing; |
| 47 int num_successful_commits; | 51 int num_successful_commits; |
| 48 // This is needed for monitoring extensions activity. | 52 // This is needed for monitoring extensions activity. |
| 49 int num_successful_bookmark_commits; | 53 int num_successful_bookmark_commits; |
| 54 | |
| 55 // Download event counters. | |
|
tim (not reviewing)
2011/01/11 19:14:23
It looks like you update the counters at the same
ncarter (slow)
2011/01/13 00:06:13
Moving these to the UpdateProgress would require a
| |
| 56 int num_updates_downloaded; | |
| 57 int num_tombstone_updates_downloaded; | |
| 50 }; | 58 }; |
| 51 | 59 |
| 52 // Counters for various errors that can occur repeatedly during a sync session. | 60 // Counters for various errors that can occur repeatedly during a sync session. |
| 53 struct ErrorCounters { | 61 struct ErrorCounters { |
| 54 ErrorCounters() : num_conflicting_commits(0), | 62 ErrorCounters() : num_conflicting_commits(0), |
| 55 consecutive_transient_error_commits(0), | 63 consecutive_transient_error_commits(0), |
| 56 consecutive_errors(0) {} | 64 consecutive_errors(0) {} |
| 57 int num_conflicting_commits; | 65 int num_conflicting_commits; |
| 58 | 66 |
| 59 // Number of commits hitting transient errors since the last successful | 67 // Number of commits hitting transient errors since the last successful |
| 60 // commit. | 68 // commit. |
| 61 int consecutive_transient_error_commits; | 69 int consecutive_transient_error_commits; |
| 62 | 70 |
| 63 // Incremented when get_updates fails, commit fails, and when hitting | 71 // Incremented when get_updates fails, commit fails, and when hitting |
| 64 // transient errors. When any of these succeed, this counter is reset. | 72 // transient errors. When any of these succeed, this counter is reset. |
| 65 // TODO(chron): Reduce number of weird counters we use. | 73 // TODO(chron): Reduce number of weird counters we use. |
| 66 int consecutive_errors; | 74 int consecutive_errors; |
| 67 }; | 75 }; |
| 68 | 76 |
| 69 // An immutable snapshot of state from a SyncSession. Convenient to use as | 77 // An immutable snapshot of state from a SyncSession. Convenient to use as |
| 70 // part of notifications as it is inherently thread-safe. | 78 // part of notifications as it is inherently thread-safe. |
| 71 struct SyncSessionSnapshot { | 79 struct SyncSessionSnapshot { |
| 72 SyncSessionSnapshot(const SyncerStatus& syncer_status, | 80 SyncSessionSnapshot( |
| 81 const SyncerStatus& syncer_status, | |
| 73 const ErrorCounters& errors, | 82 const ErrorCounters& errors, |
| 74 int64 num_server_changes_remaining, | 83 int64 num_server_changes_remaining, |
| 75 int64 max_local_timestamp, | |
| 76 bool is_share_usable, | 84 bool is_share_usable, |
| 77 const syncable::ModelTypeBitSet& initial_sync_ended, | 85 const syncable::ModelTypeBitSet& initial_sync_ended, |
| 86 std::string download_progress_markers[syncable::MODEL_TYPE_COUNT], | |
| 78 bool more_to_sync, | 87 bool more_to_sync, |
| 79 bool is_silenced, | 88 bool is_silenced, |
| 80 int64 unsynced_count, | 89 int64 unsynced_count, |
| 81 int num_conflicting_updates, | 90 int num_conflicting_updates, |
| 82 bool did_commit_items); | 91 bool did_commit_items); |
| 83 ~SyncSessionSnapshot(); | 92 ~SyncSessionSnapshot(); |
| 84 | 93 |
| 85 const SyncerStatus syncer_status; | 94 const SyncerStatus syncer_status; |
| 86 const ErrorCounters errors; | 95 const ErrorCounters errors; |
| 87 const int64 num_server_changes_remaining; | 96 const int64 num_server_changes_remaining; |
| 88 const int64 max_local_timestamp; | |
| 89 const bool is_share_usable; | 97 const bool is_share_usable; |
| 90 const syncable::ModelTypeBitSet initial_sync_ended; | 98 const syncable::ModelTypeBitSet initial_sync_ended; |
| 99 const std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; | |
| 91 const bool has_more_to_sync; | 100 const bool has_more_to_sync; |
| 92 const bool is_silenced; | 101 const bool is_silenced; |
| 93 const int64 unsynced_count; | 102 const int64 unsynced_count; |
| 94 const int num_conflicting_updates; | 103 const int num_conflicting_updates; |
| 95 const bool did_commit_items; | 104 const bool did_commit_items; |
| 96 }; | 105 }; |
| 97 | 106 |
| 98 // Tracks progress of conflicts and their resolution using conflict sets. | 107 // Tracks progress of conflicts and their resolution using conflict sets. |
| 99 class ConflictProgress { | 108 class ConflictProgress { |
| 100 public: | 109 public: |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 // a singleton with respect to model types. | 235 // a singleton with respect to model types. |
| 227 struct AllModelTypeState { | 236 struct AllModelTypeState { |
| 228 explicit AllModelTypeState(bool* dirty_flag); | 237 explicit AllModelTypeState(bool* dirty_flag); |
| 229 ~AllModelTypeState(); | 238 ~AllModelTypeState(); |
| 230 | 239 |
| 231 // Commits for all model types are bundled together into a single message. | 240 // Commits for all model types are bundled together into a single message. |
| 232 ClientToServerMessage commit_message; | 241 ClientToServerMessage commit_message; |
| 233 ClientToServerResponse commit_response; | 242 ClientToServerResponse commit_response; |
| 234 // We GetUpdates for some combination of types at once. | 243 // We GetUpdates for some combination of types at once. |
| 235 // requested_update_types stores the set of types which were requested. | 244 // requested_update_types stores the set of types which were requested. |
| 236 syncable::MultiTypeTimeStamp updates_request_parameters; | 245 syncable::ModelTypeBitSet updates_request_types; |
| 237 ClientToServerResponse updates_response; | 246 ClientToServerResponse updates_response; |
| 238 // Used to build the shared commit message. | 247 // Used to build the shared commit message. |
| 239 DirtyOnWrite<std::vector<int64> > unsynced_handles; | 248 DirtyOnWrite<std::vector<int64> > unsynced_handles; |
| 240 DirtyOnWrite<SyncerStatus> syncer_status; | 249 DirtyOnWrite<SyncerStatus> syncer_status; |
| 241 DirtyOnWrite<ErrorCounters> error_counters; | 250 DirtyOnWrite<ErrorCounters> error_counters; |
| 242 SyncCycleControlParameters control_params; | 251 SyncCycleControlParameters control_params; |
| 243 DirtyOnWrite<int64> num_server_changes_remaining; | 252 DirtyOnWrite<int64> num_server_changes_remaining; |
| 244 OrderedCommitSet commit_set; | 253 OrderedCommitSet commit_set; |
| 245 }; | 254 }; |
| 246 | 255 |
| 247 // Grouping of all state that applies to a single ModelSafeGroup. | 256 // Grouping of all state that applies to a single ModelSafeGroup. |
| 248 struct PerModelSafeGroupState { | 257 struct PerModelSafeGroupState { |
| 249 explicit PerModelSafeGroupState(bool* dirty_flag); | 258 explicit PerModelSafeGroupState(bool* dirty_flag); |
| 250 ~PerModelSafeGroupState(); | 259 ~PerModelSafeGroupState(); |
| 251 | 260 |
| 252 UpdateProgress update_progress; | 261 UpdateProgress update_progress; |
| 253 ConflictProgress conflict_progress; | 262 ConflictProgress conflict_progress; |
| 254 }; | 263 }; |
| 255 | 264 |
| 256 // Grouping of all state that applies to a single ModelType. | 265 // Grouping of all state that applies to a single ModelType. |
| 257 struct PerModelTypeState { | 266 struct PerModelTypeState { |
| 258 explicit PerModelTypeState(bool* dirty_flag); | 267 explicit PerModelTypeState(bool* dirty_flag); |
| 259 ~PerModelTypeState(); | 268 ~PerModelTypeState(); |
| 260 | |
| 261 DirtyOnWrite<int64> current_download_timestamp; | |
| 262 }; | 269 }; |
| 263 | 270 |
| 264 } // namespace sessions | 271 } // namespace sessions |
| 265 } // namespace browser_sync | 272 } // namespace browser_sync |
| 266 | 273 |
| 267 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ | 274 #endif // CHROME_BROWSER_SYNC_SESSIONS_SESSION_STATE_H_ |
| OLD | NEW |