Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: sync/sessions/session_state.h

Issue 10197004: [Sync] Convert SyncSessionSnapshot to a copy-able class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/internal_api/syncapi_unittest.cc ('k') | sync/sessions/session_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Default copy and assign welcome.
105 class SyncSessionSnapshot {
106 public:
107 SyncSessionSnapshot();
108 SyncSessionSnapshot( 108 SyncSessionSnapshot(
109 const SyncerStatus& syncer_status, 109 const SyncerStatus& syncer_status,
110 const ErrorCounters& errors, 110 const ErrorCounters& errors,
111 int64 num_server_changes_remaining, 111 int64 num_server_changes_remaining,
112 bool is_share_usable, 112 bool is_share_usable,
113 syncable::ModelTypeSet initial_sync_ended, 113 syncable::ModelTypeSet initial_sync_ended,
114 const std::string 114 const syncable::ModelTypePayloadMap& download_progress_markers,
115 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT],
116 bool more_to_sync, 115 bool more_to_sync,
117 bool is_silenced, 116 bool is_silenced,
118 int64 unsynced_count, 117 int64 unsynced_count,
119 int num_encryption_conflicts, 118 int num_encryption_conflicts,
120 int num_hierarchy_conflicts, 119 int num_hierarchy_conflicts,
121 int num_simple_conflicts, 120 int num_simple_conflicts,
122 int num_server_conflicts, 121 int num_server_conflicts,
123 bool did_commit_items, 122 bool did_commit_items,
124 const SyncSourceInfo& source, 123 const SyncSourceInfo& source,
125 bool notifications_enabled, 124 bool notifications_enabled,
126 size_t num_entries, 125 size_t num_entries,
127 base::Time sync_start_time, 126 base::Time sync_start_time,
128 bool retry_scheduled); 127 bool retry_scheduled);
129 ~SyncSessionSnapshot(); 128 ~SyncSessionSnapshot();
130 129
131 // Caller takes ownership of the returned dictionary. 130 // Caller takes ownership of the returned dictionary.
132 base::DictionaryValue* ToValue() const; 131 base::DictionaryValue* ToValue() const;
133 132
134 std::string ToString() const; 133 std::string ToString() const;
135 134
136 const SyncerStatus syncer_status; 135 SyncerStatus syncer_status() const;
137 const ErrorCounters errors; 136 ErrorCounters errors() const;
138 const int64 num_server_changes_remaining; 137 int64 num_server_changes_remaining() const;
139 const bool is_share_usable; 138 bool is_share_usable() const;
140 const syncable::ModelTypeSet initial_sync_ended; 139 syncable::ModelTypeSet initial_sync_ended() const;
141 const std::string download_progress_markers[syncable::MODEL_TYPE_COUNT]; 140 syncable::ModelTypePayloadMap download_progress_markers() const;
142 const bool has_more_to_sync; 141 bool has_more_to_sync() const;
143 const bool is_silenced; 142 bool is_silenced() const;
144 const int64 unsynced_count; 143 int64 unsynced_count() const;
145 const int num_encryption_conflicts; 144 int num_encryption_conflicts() const;
146 const int num_hierarchy_conflicts; 145 int num_hierarchy_conflicts() const;
147 const int num_simple_conflicts; 146 int num_simple_conflicts() const;
148 const int num_server_conflicts; 147 int num_server_conflicts() const;
149 const bool did_commit_items; 148 bool did_commit_items() const;
150 const SyncSourceInfo source; 149 SyncSourceInfo source() const;
151 const bool notifications_enabled; 150 bool notifications_enabled() const;
152 const size_t num_entries; 151 size_t num_entries() const;
153 base::Time sync_start_time; 152 base::Time sync_start_time() const;
154 const bool retry_scheduled; 153 bool retry_scheduled() const;
154
155 private:
156 SyncerStatus syncer_status_;
157 ErrorCounters errors_;
158 int64 num_server_changes_remaining_;
159 bool is_share_usable_;
160 syncable::ModelTypeSet initial_sync_ended_;
161 syncable::ModelTypePayloadMap download_progress_markers_;
162 bool has_more_to_sync_;
163 bool is_silenced_;
164 int64 unsynced_count_;
165 int num_encryption_conflicts_;
166 int num_hierarchy_conflicts_;
167 int num_simple_conflicts_;
168 int num_server_conflicts_;
169 bool did_commit_items_;
170 SyncSourceInfo source_;
171 bool notifications_enabled_;
172 size_t num_entries_;
173 base::Time sync_start_time_;
174 bool retry_scheduled_;
155 }; 175 };
156 176
157 // Tracks progress of conflicts and their resolutions. 177 // Tracks progress of conflicts and their resolutions.
158 class ConflictProgress { 178 class ConflictProgress {
159 public: 179 public:
160 explicit ConflictProgress(bool* dirty_flag); 180 explicit ConflictProgress(bool* dirty_flag);
161 ~ConflictProgress(); 181 ~ConflictProgress();
162 182
163 bool HasSimpleConflictItem(const syncable::Id &id) const; 183 bool HasSimpleConflictItem(const syncable::Id &id) const;
164 184
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 ~PerModelSafeGroupState(); 343 ~PerModelSafeGroupState();
324 344
325 UpdateProgress update_progress; 345 UpdateProgress update_progress;
326 ConflictProgress conflict_progress; 346 ConflictProgress conflict_progress;
327 }; 347 };
328 348
329 } // namespace sessions 349 } // namespace sessions
330 } // namespace browser_sync 350 } // namespace browser_sync
331 351
332 #endif // SYNC_SESSIONS_SESSION_STATE_H_ 352 #endif // SYNC_SESSIONS_SESSION_STATE_H_
OLDNEW
« no previous file with comments | « sync/internal_api/syncapi_unittest.cc ('k') | sync/sessions/session_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698