| 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 // 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 const ConflictProgress* GetUnrestrictedConflictProgress( | 60 const ConflictProgress* GetUnrestrictedConflictProgress( |
| 61 ModelSafeGroup group) const; | 61 ModelSafeGroup group) const; |
| 62 ConflictProgress* GetUnrestrictedMutableConflictProgressForTest( | 62 ConflictProgress* GetUnrestrictedMutableConflictProgressForTest( |
| 63 ModelSafeGroup group); | 63 ModelSafeGroup group); |
| 64 const UpdateProgress* GetUnrestrictedUpdateProgress( | 64 const UpdateProgress* GetUnrestrictedUpdateProgress( |
| 65 ModelSafeGroup group) const; | 65 ModelSafeGroup group) const; |
| 66 UpdateProgress* GetUnrestrictedMutableUpdateProgressForTest( | 66 UpdateProgress* GetUnrestrictedMutableUpdateProgressForTest( |
| 67 ModelSafeGroup group); | 67 ModelSafeGroup group); |
| 68 | 68 |
| 69 // ClientToServer messages. | 69 // ClientToServer messages. |
| 70 const syncer::ModelTypeSet updates_request_types() const { | 70 const ModelTypeSet updates_request_types() const { |
| 71 return model_neutral_.updates_request_types; | 71 return model_neutral_.updates_request_types; |
| 72 } | 72 } |
| 73 void set_updates_request_types(syncer::ModelTypeSet value) { | 73 void set_updates_request_types(ModelTypeSet value) { |
| 74 model_neutral_.updates_request_types = value; | 74 model_neutral_.updates_request_types = value; |
| 75 } | 75 } |
| 76 const sync_pb::ClientToServerResponse& updates_response() const { | 76 const sync_pb::ClientToServerResponse& updates_response() const { |
| 77 return model_neutral_.updates_response; | 77 return model_neutral_.updates_response; |
| 78 } | 78 } |
| 79 sync_pb::ClientToServerResponse* mutable_updates_response() { | 79 sync_pb::ClientToServerResponse* mutable_updates_response() { |
| 80 return &model_neutral_.updates_response; | 80 return &model_neutral_.updates_response; |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Changelog related state. | 83 // Changelog related state. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 ModelSafeGroup group_restriction() const { | 135 ModelSafeGroup group_restriction() const { |
| 136 return group_restriction_; | 136 return group_restriction_; |
| 137 } | 137 } |
| 138 | 138 |
| 139 base::Time sync_start_time() const { | 139 base::Time sync_start_time() const { |
| 140 // The time at which we sent the first GetUpdates command for this sync. | 140 // The time at which we sent the first GetUpdates command for this sync. |
| 141 return sync_start_time_; | 141 return sync_start_time_; |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool HasBookmarkCommitActivity() const { | 144 bool HasBookmarkCommitActivity() const { |
| 145 return ActiveGroupRestrictionIncludesModel(syncer::BOOKMARKS); | 145 return ActiveGroupRestrictionIncludesModel(BOOKMARKS); |
| 146 } | 146 } |
| 147 | 147 |
| 148 const ModelNeutralState& model_neutral_state() const { | 148 const ModelNeutralState& model_neutral_state() const { |
| 149 return model_neutral_; | 149 return model_neutral_; |
| 150 } | 150 } |
| 151 | 151 |
| 152 // A toolbelt full of methods for updating counters and flags. | 152 // A toolbelt full of methods for updating counters and flags. |
| 153 void set_num_server_changes_remaining(int64 changes_remaining); | 153 void set_num_server_changes_remaining(int64 changes_remaining); |
| 154 void set_num_successful_bookmark_commits(int value); | 154 void set_num_successful_bookmark_commits(int value); |
| 155 void increment_num_successful_commits(); | 155 void increment_num_successful_commits(); |
| 156 void increment_num_successful_bookmark_commits(); | 156 void increment_num_successful_bookmark_commits(); |
| 157 void increment_num_updates_downloaded_by(int value); | 157 void increment_num_updates_downloaded_by(int value); |
| 158 void increment_num_tombstone_updates_downloaded_by(int value); | 158 void increment_num_tombstone_updates_downloaded_by(int value); |
| 159 void increment_num_reflected_updates_downloaded_by(int value); | 159 void increment_num_reflected_updates_downloaded_by(int value); |
| 160 void set_types_needing_local_migration(syncer::ModelTypeSet types); | 160 void set_types_needing_local_migration(ModelTypeSet types); |
| 161 void increment_num_local_overwrites(); | 161 void increment_num_local_overwrites(); |
| 162 void increment_num_server_overwrites(); | 162 void increment_num_server_overwrites(); |
| 163 void set_sync_protocol_error(const SyncProtocolError& error); | 163 void set_sync_protocol_error(const SyncProtocolError& error); |
| 164 void set_last_download_updates_result(const SyncerError result); | 164 void set_last_download_updates_result(const SyncerError result); |
| 165 void set_commit_result(const SyncerError result); | 165 void set_commit_result(const SyncerError result); |
| 166 | 166 |
| 167 void update_conflicts_resolved(bool resolved); | 167 void update_conflicts_resolved(bool resolved); |
| 168 void reset_conflicts_resolved(); | 168 void reset_conflicts_resolved(); |
| 169 | 169 |
| 170 void UpdateStartTime(); | 170 void UpdateStartTime(); |
| 171 | 171 |
| 172 void set_debug_info_sent(); | 172 void set_debug_info_sent(); |
| 173 | 173 |
| 174 bool debug_info_sent() const; | 174 bool debug_info_sent() const; |
| 175 | 175 |
| 176 private: | 176 private: |
| 177 friend class ScopedModelSafeGroupRestriction; | 177 friend class ScopedModelSafeGroupRestriction; |
| 178 | 178 |
| 179 // Check whether a particular model is included by the active group | 179 // Check whether a particular model is included by the active group |
| 180 // restriction. | 180 // restriction. |
| 181 bool ActiveGroupRestrictionIncludesModel(syncer::ModelType model) const { | 181 bool ActiveGroupRestrictionIncludesModel(ModelType model) const { |
| 182 if (!group_restriction_in_effect_) | 182 if (!group_restriction_in_effect_) |
| 183 return true; | 183 return true; |
| 184 ModelSafeRoutingInfo::const_iterator it = routing_info_.find(model); | 184 ModelSafeRoutingInfo::const_iterator it = routing_info_.find(model); |
| 185 if (it == routing_info_.end()) | 185 if (it == routing_info_.end()) |
| 186 return false; | 186 return false; |
| 187 return group_restriction() == it->second; | 187 return group_restriction() == it->second; |
| 188 } | 188 } |
| 189 | 189 |
| 190 // Returns the state, if it exists, or NULL otherwise. | 190 // Returns the state, if it exists, or NULL otherwise. |
| 191 const PerModelSafeGroupState* GetModelSafeGroupState( | 191 const PerModelSafeGroupState* GetModelSafeGroupState( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 230 } |
| 231 private: | 231 private: |
| 232 StatusController* status_; | 232 StatusController* status_; |
| 233 DISALLOW_COPY_AND_ASSIGN(ScopedModelSafeGroupRestriction); | 233 DISALLOW_COPY_AND_ASSIGN(ScopedModelSafeGroupRestriction); |
| 234 }; | 234 }; |
| 235 | 235 |
| 236 } // namespace sessions | 236 } // namespace sessions |
| 237 } // namespace syncer | 237 } // namespace syncer |
| 238 | 238 |
| 239 #endif // SYNC_SESSIONS_STATUS_CONTROLLER_H_ | 239 #endif // SYNC_SESSIONS_STATUS_CONTROLLER_H_ |
| OLD | NEW |