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

Side by Side Diff: chrome/browser/sync/sessions/status_controller.h

Issue 6104003: sync: use progress markers instead of timestamps during GetUpdates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tim's fixes Created 9 years, 11 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
OLDNEW
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 // StatusController handles all counter and status related number crunching and 5 // StatusController handles all counter and status related number crunching and
6 // state tracking on behalf of a SyncSession. It 'controls' the model data 6 // state tracking on behalf of a SyncSession. It 'controls' the model data
7 // defined in session_state.h. The most important feature of StatusController 7 // defined in session_state.h. The most important feature of StatusController
8 // is the ScopedModelSafetyRestriction. When one of these is active, the 8 // is the ScopedModelSafetyRestriction. When one of these is active, the
9 // underlying data set exposed via accessors is swapped out to the appropriate 9 // underlying data set exposed via accessors is swapped out to the appropriate
10 // set for the restricted ModelSafeGroup behind the scenes. For example, if 10 // set for the restricted ModelSafeGroup behind the scenes. For example, if
11 // GROUP_UI is set, then accessors such as conflict_progress() and commit_ids() 11 // GROUP_UI is set, then accessors such as conflict_progress() and commit_ids()
12 // are implicitly restricted to returning only data pertaining to GROUP_UI. 12 // are implicitly restricted to returning only data pertaining to GROUP_UI.
13 // You can see which parts of status fall into this "restricted" category, the 13 // You can see which parts of status fall into this "restricted" category, or
14 // global "shared" category for all model types, or the single per-model type 14 // the global "shared" category for all model types, by looking at the struct
15 // category by looking at the struct declarations in session_state.h. 15 // declarations in session_state.h. If these accessors are invoked without a
16 // If these accessors are invoked without a restriction in place, this is a 16 // restriction in place, this is a violation and will cause debug assertions
17 // violation and will cause debug assertions to surface improper use of the API 17 // to surface improper use of the API in development. Likewise for
18 // in development. Likewise for invocation of "shared" accessors when a 18 // invocation of "shared" accessors when a restriction is in place; for
19 // restriction is in place; for safety's sake, an assertion will fire. 19 // safety's sake, an assertion will fire.
20 // 20 //
21 // NOTE: There is no concurrent access protection provided by this class. It 21 // NOTE: There is no concurrent access protection provided by this class. It
22 // assumes one single thread is accessing this class for each unique 22 // assumes one single thread is accessing this class for each unique
23 // ModelSafeGroup, and also only one single thread (in practice, the 23 // ModelSafeGroup, and also only one single thread (in practice, the
24 // SyncerThread) responsible for all "shared" access when no restriction is in 24 // SyncerThread) responsible for all "shared" access when no restriction is in
25 // place. Thus, every bit of data is to be accessed mutually exclusively with 25 // place. Thus, every bit of data is to be accessed mutually exclusively with
26 // respect to threads. 26 // respect to threads.
27 // 27 //
28 // StatusController can also track if changes occur to certain parts of state 28 // StatusController can also track if changes occur to certain parts of state
29 // so that various parts of the sync engine can avoid broadcasting 29 // so that various parts of the sync engine can avoid broadcasting
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 80 }
81 ClientToServerMessage* mutable_commit_message() { 81 ClientToServerMessage* mutable_commit_message() {
82 return &shared_.commit_message; 82 return &shared_.commit_message;
83 } 83 }
84 const ClientToServerResponse& commit_response() const { 84 const ClientToServerResponse& commit_response() const {
85 return shared_.commit_response; 85 return shared_.commit_response;
86 } 86 }
87 ClientToServerResponse* mutable_commit_response() { 87 ClientToServerResponse* mutable_commit_response() {
88 return &shared_.commit_response; 88 return &shared_.commit_response;
89 } 89 }
90 const syncable::MultiTypeTimeStamp& updates_request_parameters() const { 90 const syncable::ModelTypeBitSet& updates_request_types() const {
91 return shared_.updates_request_parameters; 91 return shared_.updates_request_types;
92 } 92 }
93 void set_updates_request_parameters( 93 void set_updates_request_types(const syncable::ModelTypeBitSet& value) {
94 const syncable::MultiTypeTimeStamp& value) { 94 shared_.updates_request_types = value;
95 shared_.updates_request_parameters = value;
96 } 95 }
97 const ClientToServerResponse& updates_response() const { 96 const ClientToServerResponse& updates_response() const {
98 return shared_.updates_response; 97 return shared_.updates_response;
99 } 98 }
100 ClientToServerResponse* mutable_updates_response() { 99 ClientToServerResponse* mutable_updates_response() {
101 return &shared_.updates_response; 100 return &shared_.updates_response;
102 } 101 }
103 102
104 // Errors and SyncerStatus. 103 // Errors and SyncerStatus.
105 const ErrorCounters& error_counters() const { 104 const ErrorCounters& error_counters() const {
106 return shared_.error_counters.value(); 105 return shared_.error_counters.value();
107 } 106 }
108 const SyncerStatus& syncer_status() const { 107 const SyncerStatus& syncer_status() const {
109 return shared_.syncer_status.value(); 108 return shared_.syncer_status.value();
110 } 109 }
111 110
112 // Changelog related state. 111 // Changelog related state.
113 int64 num_server_changes_remaining() const { 112 int64 num_server_changes_remaining() const {
114 return shared_.num_server_changes_remaining.value(); 113 return shared_.num_server_changes_remaining.value();
115 } 114 }
116 // Aggregate max over all data type timestamps, used for UI reporting.
117 int64 ComputeMaxLocalTimestamp() const;
118 115
119 // Commit path data. 116 // Commit path data.
120 const std::vector<syncable::Id>& commit_ids() const { 117 const std::vector<syncable::Id>& commit_ids() const {
121 DCHECK(!group_restriction_in_effect_) << "Group restriction in effect!"; 118 DCHECK(!group_restriction_in_effect_) << "Group restriction in effect!";
122 return shared_.commit_set.GetAllCommitIds(); 119 return shared_.commit_set.GetAllCommitIds();
123 } 120 }
124 const OrderedCommitSet::Projection& commit_id_projection() { 121 const OrderedCommitSet::Projection& commit_id_projection() {
125 DCHECK(group_restriction_in_effect_) 122 DCHECK(group_restriction_in_effect_)
126 << "No group restriction for projection."; 123 << "No group restriction for projection.";
127 return shared_.commit_set.GetCommitIdProjection(group_restriction_); 124 return shared_.commit_set.GetCommitIdProjection(group_restriction_);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 196 }
200 197
201 // A toolbelt full of methods for updating counters and flags. 198 // A toolbelt full of methods for updating counters and flags.
202 void increment_num_conflicting_commits_by(int value); 199 void increment_num_conflicting_commits_by(int value);
203 void reset_num_conflicting_commits(); 200 void reset_num_conflicting_commits();
204 void set_num_consecutive_transient_error_commits(int value); 201 void set_num_consecutive_transient_error_commits(int value);
205 void increment_num_consecutive_transient_error_commits_by(int value); 202 void increment_num_consecutive_transient_error_commits_by(int value);
206 void set_num_consecutive_errors(int value); 203 void set_num_consecutive_errors(int value);
207 void increment_num_consecutive_errors(); 204 void increment_num_consecutive_errors();
208 void increment_num_consecutive_errors_by(int value); 205 void increment_num_consecutive_errors_by(int value);
209 void set_current_download_timestamp(syncable::ModelType model,
210 int64 current_timestamp);
211 void set_num_server_changes_remaining(int64 changes_remaining); 206 void set_num_server_changes_remaining(int64 changes_remaining);
212 void set_invalid_store(bool invalid_store); 207 void set_invalid_store(bool invalid_store);
213 void set_syncer_stuck(bool syncer_stuck); 208 void set_syncer_stuck(bool syncer_stuck);
214 void set_syncing(bool syncing); 209 void set_syncing(bool syncing);
215 void set_num_successful_bookmark_commits(int value); 210 void set_num_successful_bookmark_commits(int value);
216 void increment_num_successful_commits(); 211 void increment_num_successful_commits();
217 void increment_num_successful_bookmark_commits(); 212 void increment_num_successful_bookmark_commits();
213 void increment_num_updates_downloaded_by(int value);
214 void increment_num_tombstone_updates_downloaded_by(int value);
218 void set_unsynced_handles(const std::vector<int64>& unsynced_handles); 215 void set_unsynced_handles(const std::vector<int64>& unsynced_handles);
219 216
220 void set_commit_set(const OrderedCommitSet& commit_set); 217 void set_commit_set(const OrderedCommitSet& commit_set);
221 void update_conflict_sets_built(bool built); 218 void update_conflict_sets_built(bool built);
222 void update_conflicts_resolved(bool resolved); 219 void update_conflicts_resolved(bool resolved);
223 void reset_conflicts_resolved(); 220 void reset_conflicts_resolved();
224 void set_items_committed(); 221 void set_items_committed();
225 222
226 private: 223 private:
227 friend class ScopedModelSafeGroupRestriction; 224 friend class ScopedModelSafeGroupRestriction;
228 225
229 // Returns true iff the commit id projection for |group_restriction_| 226 // Returns true iff the commit id projection for |group_restriction_|
230 // references position |index| into the full set of commit ids in play. 227 // references position |index| into the full set of commit ids in play.
231 bool CurrentCommitIdProjectionHasIndex(size_t index); 228 bool CurrentCommitIdProjectionHasIndex(size_t index);
232 229
233 // Helper to lazily create objects for per-ModelSafeGroup state. 230 // Helper to lazily create objects for per-ModelSafeGroup state.
234 PerModelSafeGroupState* GetOrCreateModelSafeGroupState(bool restrict, 231 PerModelSafeGroupState* GetOrCreateModelSafeGroupState(bool restrict,
235 ModelSafeGroup group); 232 ModelSafeGroup group);
236 // Helper to lazily create objects for per-model type state.
237 PerModelTypeState* GetOrCreateModelTypeState(bool restrict,
238 syncable::ModelType model);
239 233
240 AllModelTypeState shared_; 234 AllModelTypeState shared_;
241 std::map<ModelSafeGroup, PerModelSafeGroupState*> per_model_group_; 235 std::map<ModelSafeGroup, PerModelSafeGroupState*> per_model_group_;
242 std::map<syncable::ModelType, PerModelTypeState*> per_model_type_;
243 236
244 STLValueDeleter<std::map<ModelSafeGroup, PerModelSafeGroupState*> > 237 STLValueDeleter<std::map<ModelSafeGroup, PerModelSafeGroupState*> >
245 per_model_group_deleter_; 238 per_model_group_deleter_;
246 STLValueDeleter<std::map<syncable::ModelType, PerModelTypeState*> >
247 per_model_type_deleter_;
248 239
249 // Set to true if any DirtyOnWrite pieces of state we maintain are changed. 240 // Set to true if any DirtyOnWrite pieces of state we maintain are changed.
250 // Reset to false by TestAndClearIsDirty. 241 // Reset to false by TestAndClearIsDirty.
251 bool is_dirty_; 242 bool is_dirty_;
252 243
253 // Used to fail read/write operations on state that don't obey the current 244 // Used to fail read/write operations on state that don't obey the current
254 // active ModelSafeWorker contract. 245 // active ModelSafeWorker contract.
255 bool group_restriction_in_effect_; 246 bool group_restriction_in_effect_;
256 ModelSafeGroup group_restriction_; 247 ModelSafeGroup group_restriction_;
257 248
(...skipping 19 matching lines...) Expand all
277 } 268 }
278 private: 269 private:
279 StatusController* status_; 270 StatusController* status_;
280 DISALLOW_COPY_AND_ASSIGN(ScopedModelSafeGroupRestriction); 271 DISALLOW_COPY_AND_ASSIGN(ScopedModelSafeGroupRestriction);
281 }; 272 };
282 273
283 } 274 }
284 } 275 }
285 276
286 #endif // CHROME_BROWSER_SYNC_SESSIONS_STATUS_CONTROLLER_H_ 277 #endif // CHROME_BROWSER_SYNC_SESSIONS_STATUS_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/sessions/session_state.cc ('k') | chrome/browser/sync/sessions/status_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698