| Index: sync/sessions/status_controller.cc
|
| diff --git a/sync/sessions/status_controller.cc b/sync/sessions/status_controller.cc
|
| index 61b1094857c8d2f848b992f0c52e44e9cce540d0..2287a517570cbe5bdddf0870ee6573bd7753de7b 100644
|
| --- a/sync/sessions/status_controller.cc
|
| +++ b/sync/sessions/status_controller.cc
|
| @@ -14,82 +14,13 @@ namespace syncer {
|
| namespace sessions {
|
|
|
| StatusController::StatusController(const ModelSafeRoutingInfo& routes)
|
| - : per_model_group_deleter_(&per_model_group_),
|
| - group_restriction_in_effect_(false),
|
| + : group_restriction_in_effect_(false),
|
| group_restriction_(GROUP_PASSIVE),
|
| routing_info_(routes) {
|
| }
|
|
|
| StatusController::~StatusController() {}
|
|
|
| -const UpdateProgress* StatusController::update_progress() const {
|
| - const PerModelSafeGroupState* state =
|
| - GetModelSafeGroupState(true, group_restriction_);
|
| - return state ? &state->update_progress : NULL;
|
| -}
|
| -
|
| -UpdateProgress* StatusController::mutable_update_progress() {
|
| - return &GetOrCreateModelSafeGroupState(
|
| - true, group_restriction_)->update_progress;
|
| -}
|
| -
|
| -const ConflictProgress* StatusController::conflict_progress() const {
|
| - const PerModelSafeGroupState* state =
|
| - GetModelSafeGroupState(true, group_restriction_);
|
| - return state ? &state->conflict_progress : NULL;
|
| -}
|
| -
|
| -ConflictProgress* StatusController::mutable_conflict_progress() {
|
| - return &GetOrCreateModelSafeGroupState(
|
| - true, group_restriction_)->conflict_progress;
|
| -}
|
| -
|
| -const ConflictProgress* StatusController::GetUnrestrictedConflictProgress(
|
| - ModelSafeGroup group) const {
|
| - const PerModelSafeGroupState* state =
|
| - GetModelSafeGroupState(false, group);
|
| - return state ? &state->conflict_progress : NULL;
|
| -}
|
| -
|
| -ConflictProgress*
|
| - StatusController::GetUnrestrictedMutableConflictProgressForTest(
|
| - ModelSafeGroup group) {
|
| - return &GetOrCreateModelSafeGroupState(false, group)->conflict_progress;
|
| -}
|
| -
|
| -const UpdateProgress* StatusController::GetUnrestrictedUpdateProgress(
|
| - ModelSafeGroup group) const {
|
| - const PerModelSafeGroupState* state =
|
| - GetModelSafeGroupState(false, group);
|
| - return state ? &state->update_progress : NULL;
|
| -}
|
| -
|
| -UpdateProgress*
|
| - StatusController::GetUnrestrictedMutableUpdateProgressForTest(
|
| - ModelSafeGroup group) {
|
| - return &GetOrCreateModelSafeGroupState(false, group)->update_progress;
|
| -}
|
| -
|
| -const PerModelSafeGroupState* StatusController::GetModelSafeGroupState(
|
| - bool restrict, ModelSafeGroup group) const {
|
| - DCHECK_EQ(restrict, group_restriction_in_effect_);
|
| - std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it =
|
| - per_model_group_.find(group);
|
| - return (it == per_model_group_.end()) ? NULL : it->second;
|
| -}
|
| -
|
| -PerModelSafeGroupState* StatusController::GetOrCreateModelSafeGroupState(
|
| - bool restrict, ModelSafeGroup group) {
|
| - DCHECK_EQ(restrict, group_restriction_in_effect_);
|
| - std::map<ModelSafeGroup, PerModelSafeGroupState*>::iterator it =
|
| - per_model_group_.find(group);
|
| - if (it == per_model_group_.end()) {
|
| - PerModelSafeGroupState* state = new PerModelSafeGroupState();
|
| - it = per_model_group_.insert(std::make_pair(group, state)).first;
|
| - }
|
| - return it->second;
|
| -}
|
| -
|
| void StatusController::increment_num_updates_downloaded_by(int value) {
|
| model_neutral_.num_updates_downloaded_total += value;
|
| }
|
| @@ -129,6 +60,22 @@ void StatusController::increment_num_successful_commits() {
|
| model_neutral_.num_successful_commits++;
|
| }
|
|
|
| +void StatusController::increment_num_updates_applied_by(int value) {
|
| + model_neutral_.num_updates_applied += value;
|
| +}
|
| +
|
| +void StatusController::increment_num_encryption_conflicts_by(int value) {
|
| + model_neutral_.num_encryption_conflicts += value;
|
| +}
|
| +
|
| +void StatusController::increment_num_hierarchy_conflicts_by(int value) {
|
| + model_neutral_.num_hierarchy_conflicts += value;
|
| +}
|
| +
|
| +void StatusController::increment_num_server_conflicts() {
|
| + model_neutral_.num_server_conflicts++;
|
| +}
|
| +
|
| void StatusController::increment_num_local_overwrites() {
|
| model_neutral_.num_local_overwrites++;
|
| }
|
| @@ -159,13 +106,6 @@ SyncerError StatusController::last_get_key_result() const {
|
| return model_neutral_.last_get_key_result;
|
| }
|
|
|
| -void StatusController::update_conflicts_resolved(bool resolved) {
|
| - model_neutral_.conflicts_resolved |= resolved;
|
| -}
|
| -void StatusController::reset_conflicts_resolved() {
|
| - model_neutral_.conflicts_resolved = false;
|
| -}
|
| -
|
| // Returns the number of updates received from the sync server.
|
| int64 StatusController::CountUpdates() const {
|
| const sync_pb::ClientToServerResponse& updates =
|
| @@ -177,78 +117,37 @@ int64 StatusController::CountUpdates() const {
|
| }
|
| }
|
|
|
| -bool StatusController::HasConflictingUpdates() const {
|
| - DCHECK(!group_restriction_in_effect_)
|
| - << "HasConflictingUpdates applies to all ModelSafeGroups";
|
| - std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it =
|
| - per_model_group_.begin();
|
| - for (; it != per_model_group_.end(); ++it) {
|
| - if (it->second->update_progress.HasConflictingUpdates())
|
| - return true;
|
| - }
|
| - return false;
|
| +int StatusController::num_updates_applied() const {
|
| + return model_neutral_.num_updates_applied;
|
| }
|
|
|
| -int StatusController::TotalNumEncryptionConflictingItems() const {
|
| - DCHECK(!group_restriction_in_effect_)
|
| - << "TotalNumEncryptionConflictingItems applies to all ModelSafeGroups";
|
| - std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it =
|
| - per_model_group_.begin();
|
| - int sum = 0;
|
| - for (; it != per_model_group_.end(); ++it) {
|
| - sum += it->second->conflict_progress.EncryptionConflictingItemsSize();
|
| - }
|
| - return sum;
|
| +int StatusController::num_server_overwrites() const {
|
| + return model_neutral_.num_server_overwrites;
|
| }
|
|
|
| -int StatusController::TotalNumHierarchyConflictingItems() const {
|
| - DCHECK(!group_restriction_in_effect_)
|
| - << "TotalNumHierarchyConflictingItems applies to all ModelSafeGroups";
|
| - std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it =
|
| - per_model_group_.begin();
|
| - int sum = 0;
|
| - for (; it != per_model_group_.end(); ++it) {
|
| - sum += it->second->conflict_progress.HierarchyConflictingItemsSize();
|
| - }
|
| - return sum;
|
| +int StatusController::num_encryption_conflicts() const {
|
| + return model_neutral_.num_encryption_conflicts;
|
| }
|
|
|
| -int StatusController::TotalNumSimpleConflictingItems() const {
|
| +int StatusController::num_hierarchy_conflicts() const {
|
| DCHECK(!group_restriction_in_effect_)
|
| - << "TotalNumSimpleConflictingItems applies to all ModelSafeGroups";
|
| - std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it =
|
| - per_model_group_.begin();
|
| - int sum = 0;
|
| - for (; it != per_model_group_.end(); ++it) {
|
| - sum += it->second->conflict_progress.SimpleConflictingItemsSize();
|
| - }
|
| - return sum;
|
| + << "num_hierarchy_conflicts applies to all ModelSafeGroups";
|
| + return model_neutral_.num_hierarchy_conflicts;
|
| }
|
|
|
| -int StatusController::TotalNumServerConflictingItems() const {
|
| +int StatusController::num_server_conflicts() const {
|
| DCHECK(!group_restriction_in_effect_)
|
| - << "TotalNumServerConflictingItems applies to all ModelSafeGroups";
|
| - std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it =
|
| - per_model_group_.begin();
|
| - int sum = 0;
|
| - for (; it != per_model_group_.end(); ++it) {
|
| - sum += it->second->conflict_progress.ServerConflictingItemsSize();
|
| - }
|
| - return sum;
|
| + << "num_server_conflicts applies to all ModelSafeGroups";
|
| + return model_neutral_.num_server_conflicts;
|
| }
|
|
|
| int StatusController::TotalNumConflictingItems() const {
|
| DCHECK(!group_restriction_in_effect_)
|
| << "TotalNumConflictingItems applies to all ModelSafeGroups";
|
| - std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it =
|
| - per_model_group_.begin();
|
| int sum = 0;
|
| - for (; it != per_model_group_.end(); ++it) {
|
| - sum += it->second->conflict_progress.SimpleConflictingItemsSize();
|
| - sum += it->second->conflict_progress.EncryptionConflictingItemsSize();
|
| - sum += it->second->conflict_progress.HierarchyConflictingItemsSize();
|
| - sum += it->second->conflict_progress.ServerConflictingItemsSize();
|
| - }
|
| + sum += num_encryption_conflicts();
|
| + sum += num_hierarchy_conflicts();
|
| + sum += num_server_conflicts();
|
| return sum;
|
| }
|
|
|
|
|