OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 void set_sync_protocol_error(const SyncProtocolError& error); | 232 void set_sync_protocol_error(const SyncProtocolError& error); |
233 | 233 |
234 void set_commit_set(const OrderedCommitSet& commit_set); | 234 void set_commit_set(const OrderedCommitSet& commit_set); |
235 void update_conflict_sets_built(bool built); | 235 void update_conflict_sets_built(bool built); |
236 void update_conflicts_resolved(bool resolved); | 236 void update_conflicts_resolved(bool resolved); |
237 void reset_conflicts_resolved(); | 237 void reset_conflicts_resolved(); |
238 void set_items_committed(); | 238 void set_items_committed(); |
239 | 239 |
240 void SetSyncInProgressAndUpdateStartTime(bool sync_in_progress); | 240 void SetSyncInProgressAndUpdateStartTime(bool sync_in_progress); |
241 | 241 |
242 void set_debug_info_sent(bool value); | |
243 | |
244 bool debug_info_sent(); | |
245 | |
242 private: | 246 private: |
243 friend class ScopedModelSafeGroupRestriction; | 247 friend class ScopedModelSafeGroupRestriction; |
244 | 248 |
245 // Returns true iff the commit id projection for |group_restriction_| | 249 // Returns true iff the commit id projection for |group_restriction_| |
246 // references position |index| into the full set of commit ids in play. | 250 // references position |index| into the full set of commit ids in play. |
247 bool CurrentCommitIdProjectionHasIndex(size_t index); | 251 bool CurrentCommitIdProjectionHasIndex(size_t index); |
248 | 252 |
249 // Helper to lazily create objects for per-ModelSafeGroup state. | 253 // Helper to lazily create objects for per-ModelSafeGroup state. |
250 PerModelSafeGroupState* GetOrCreateModelSafeGroupState(bool restrict, | 254 PerModelSafeGroupState* GetOrCreateModelSafeGroupState(bool restrict, |
251 ModelSafeGroup group); | 255 ModelSafeGroup group); |
(...skipping 10 matching lines...) Expand all Loading... | |
262 | 266 |
263 // Used to fail read/write operations on state that don't obey the current | 267 // Used to fail read/write operations on state that don't obey the current |
264 // active ModelSafeWorker contract. | 268 // active ModelSafeWorker contract. |
265 bool group_restriction_in_effect_; | 269 bool group_restriction_in_effect_; |
266 ModelSafeGroup group_restriction_; | 270 ModelSafeGroup group_restriction_; |
267 | 271 |
268 const ModelSafeRoutingInfo routing_info_; | 272 const ModelSafeRoutingInfo routing_info_; |
269 | 273 |
270 base::Time sync_start_time_; | 274 base::Time sync_start_time_; |
271 | 275 |
276 // True indicates we have sent the debug info already once this session. | |
277 // False indicates we are yet to send it. | |
278 bool debug_info_sent_; | |
tim (not reviewing)
2011/10/13 16:04:14
Do not add state like this here. This belongs in
lipalani1
2011/10/13 21:39:18
Done.
| |
279 | |
272 DISALLOW_COPY_AND_ASSIGN(StatusController); | 280 DISALLOW_COPY_AND_ASSIGN(StatusController); |
273 }; | 281 }; |
274 | 282 |
275 // A utility to restrict access to only those parts of the given | 283 // A utility to restrict access to only those parts of the given |
276 // StatusController that pertain to the specified ModelSafeGroup. | 284 // StatusController that pertain to the specified ModelSafeGroup. |
277 class ScopedModelSafeGroupRestriction { | 285 class ScopedModelSafeGroupRestriction { |
278 public: | 286 public: |
279 ScopedModelSafeGroupRestriction(StatusController* to_restrict, | 287 ScopedModelSafeGroupRestriction(StatusController* to_restrict, |
280 ModelSafeGroup restriction) | 288 ModelSafeGroup restriction) |
281 : status_(to_restrict) { | 289 : status_(to_restrict) { |
282 DCHECK(!status_->group_restriction_in_effect_); | 290 DCHECK(!status_->group_restriction_in_effect_); |
283 status_->group_restriction_ = restriction; | 291 status_->group_restriction_ = restriction; |
284 status_->group_restriction_in_effect_ = true; | 292 status_->group_restriction_in_effect_ = true; |
285 } | 293 } |
286 ~ScopedModelSafeGroupRestriction() { | 294 ~ScopedModelSafeGroupRestriction() { |
287 DCHECK(status_->group_restriction_in_effect_); | 295 DCHECK(status_->group_restriction_in_effect_); |
288 status_->group_restriction_in_effect_ = false; | 296 status_->group_restriction_in_effect_ = false; |
289 } | 297 } |
290 private: | 298 private: |
291 StatusController* status_; | 299 StatusController* status_; |
292 DISALLOW_COPY_AND_ASSIGN(ScopedModelSafeGroupRestriction); | 300 DISALLOW_COPY_AND_ASSIGN(ScopedModelSafeGroupRestriction); |
293 }; | 301 }; |
294 | 302 |
295 } | 303 } |
296 } | 304 } |
297 | 305 |
298 #endif // CHROME_BROWSER_SYNC_SESSIONS_STATUS_CONTROLLER_H_ | 306 #endif // CHROME_BROWSER_SYNC_SESSIONS_STATUS_CONTROLLER_H_ |
OLD | NEW |