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