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