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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 | 90 |
91 // Any protocol errors that we received during this sync session. | 91 // Any protocol errors that we received during this sync session. |
92 SyncProtocolError sync_protocol_error; | 92 SyncProtocolError sync_protocol_error; |
93 | 93 |
94 // Records the most recent results of PostCommit and GetUpdates commands. | 94 // Records the most recent results of PostCommit and GetUpdates commands. |
95 SyncerError last_download_updates_result; | 95 SyncerError last_download_updates_result; |
96 SyncerError last_post_commit_result; | 96 SyncerError last_post_commit_result; |
97 SyncerError last_process_commit_response_result; | 97 SyncerError last_process_commit_response_result; |
98 }; | 98 }; |
99 | 99 |
100 // Caller takes ownership of the returned dictionary. | |
101 base::DictionaryValue* DownloadProgressMarkersToValue( | |
102 const std::string | |
103 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT]); | |
104 | |
105 // An immutable snapshot of state from a SyncSession. Convenient to use as | 100 // An immutable snapshot of state from a SyncSession. Convenient to use as |
106 // part of notifications as it is inherently thread-safe. | 101 // part of notifications as it is inherently thread-safe. |
107 struct SyncSessionSnapshot { | 102 // TODO(zea): if copying this all over the place starts getting expensive, |
103 // consider passing around immutable references instead of values. | |
104 // refs. | |
tim (not reviewing)
2012/04/24 01:22:08
remove
Nicolas Zea
2012/04/24 18:06:51
Done.
| |
105 // Default copy and assign welcome. | |
106 class SyncSessionSnapshot { | |
107 public: | |
108 SyncSessionSnapshot(); | |
108 SyncSessionSnapshot( | 109 SyncSessionSnapshot( |
109 const SyncerStatus& syncer_status, | 110 const SyncerStatus& syncer_status, |
110 const ErrorCounters& errors, | 111 const ErrorCounters& errors, |
111 int64 num_server_changes_remaining, | 112 int64 num_server_changes_remaining, |
112 bool is_share_usable, | 113 bool is_share_usable, |
113 syncable::ModelTypeSet initial_sync_ended, | 114 syncable::ModelTypeSet initial_sync_ended, |
114 const std::string | 115 const syncable::ModelTypePayloadMap& download_progress_markers, |
115 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT], | |
116 bool more_to_sync, | 116 bool more_to_sync, |
117 bool is_silenced, | 117 bool is_silenced, |
118 int64 unsynced_count, | 118 int64 unsynced_count, |
119 int num_encryption_conflicts, | 119 int num_encryption_conflicts, |
120 int num_hierarchy_conflicts, | 120 int num_hierarchy_conflicts, |
121 int num_simple_conflicts, | 121 int num_simple_conflicts, |
122 int num_server_conflicts, | 122 int num_server_conflicts, |
123 bool did_commit_items, | 123 bool did_commit_items, |
124 const SyncSourceInfo& source, | 124 const SyncSourceInfo& source, |
125 bool notifications_enabled, | 125 bool notifications_enabled, |
126 size_t num_entries, | 126 size_t num_entries, |
127 base::Time sync_start_time, | 127 base::Time sync_start_time, |
128 bool retry_scheduled); | 128 bool retry_scheduled); |
129 ~SyncSessionSnapshot(); | 129 ~SyncSessionSnapshot(); |
130 | 130 |
131 // Caller takes ownership of the returned dictionary. | 131 // Caller takes ownership of the returned dictionary. |
132 base::DictionaryValue* ToValue() const; | 132 base::DictionaryValue* ToValue() const; |
133 | 133 |
134 std::string ToString() const; | 134 std::string ToString() const; |
135 | 135 |
136 const SyncerStatus syncer_status; | 136 SyncerStatus syncer_status() const; |
137 const ErrorCounters errors; | 137 ErrorCounters errors() const; |
138 const int64 num_server_changes_remaining; | 138 int64 num_server_changes_remaining() const; |
139 const bool is_share_usable; | 139 bool is_share_usable() const; |
140 const syncable::ModelTypeSet initial_sync_ended; | 140 syncable::ModelTypeSet initial_sync_ended() const; |
141 const std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; | 141 syncable::ModelTypePayloadMap download_progress_markers() const; |
142 const bool has_more_to_sync; | 142 bool has_more_to_sync() const; |
143 const bool is_silenced; | 143 bool is_silenced() const; |
144 const int64 unsynced_count; | 144 int64 unsynced_count() const; |
145 const int num_encryption_conflicts; | 145 int num_encryption_conflicts() const; |
146 const int num_hierarchy_conflicts; | 146 int num_hierarchy_conflicts() const; |
147 const int num_simple_conflicts; | 147 int num_simple_conflicts() const; |
148 const int num_server_conflicts; | 148 int num_server_conflicts() const; |
149 const bool did_commit_items; | 149 bool did_commit_items() const; |
150 const SyncSourceInfo source; | 150 SyncSourceInfo source() const; |
151 const bool notifications_enabled; | 151 bool notifications_enabled() const; |
152 const size_t num_entries; | 152 size_t num_entries() const; |
153 base::Time sync_start_time; | 153 base::Time sync_start_time() const; |
154 const bool retry_scheduled; | 154 bool retry_scheduled() const; |
155 | |
156 private: | |
157 SyncerStatus syncer_status_; | |
158 ErrorCounters errors_; | |
159 int64 num_server_changes_remaining_; | |
160 bool is_share_usable_; | |
161 syncable::ModelTypeSet initial_sync_ended_; | |
162 syncable::ModelTypePayloadMap download_progress_markers_; | |
163 bool has_more_to_sync_; | |
164 bool is_silenced_; | |
165 int64 unsynced_count_; | |
166 int num_encryption_conflicts_; | |
167 int num_hierarchy_conflicts_; | |
168 int num_simple_conflicts_; | |
169 int num_server_conflicts_; | |
170 bool did_commit_items_; | |
171 SyncSourceInfo source_; | |
172 bool notifications_enabled_; | |
173 size_t num_entries_; | |
174 base::Time sync_start_time_; | |
175 bool retry_scheduled_; | |
155 }; | 176 }; |
156 | 177 |
157 // Tracks progress of conflicts and their resolutions. | 178 // Tracks progress of conflicts and their resolutions. |
158 class ConflictProgress { | 179 class ConflictProgress { |
159 public: | 180 public: |
160 explicit ConflictProgress(bool* dirty_flag); | 181 explicit ConflictProgress(bool* dirty_flag); |
161 ~ConflictProgress(); | 182 ~ConflictProgress(); |
162 | 183 |
163 bool HasSimpleConflictItem(const syncable::Id &id) const; | 184 bool HasSimpleConflictItem(const syncable::Id &id) const; |
164 | 185 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 ~PerModelSafeGroupState(); | 344 ~PerModelSafeGroupState(); |
324 | 345 |
325 UpdateProgress update_progress; | 346 UpdateProgress update_progress; |
326 ConflictProgress conflict_progress; | 347 ConflictProgress conflict_progress; |
327 }; | 348 }; |
328 | 349 |
329 } // namespace sessions | 350 } // namespace sessions |
330 } // namespace browser_sync | 351 } // namespace browser_sync |
331 | 352 |
332 #endif // SYNC_SESSIONS_SESSION_STATE_H_ | 353 #endif // SYNC_SESSIONS_SESSION_STATE_H_ |
OLD | NEW |