| 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 #include "sync/sessions/status_controller.h" | 5 #include "sync/sessions/status_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "sync/protocol/sync_protocol_error.h" | 10 #include "sync/protocol/sync_protocol_error.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 GetModelSafeGroupState(false, group); | 61 GetModelSafeGroupState(false, group); |
| 62 return state ? &state->conflict_progress : NULL; | 62 return state ? &state->conflict_progress : NULL; |
| 63 } | 63 } |
| 64 | 64 |
| 65 ConflictProgress* | 65 ConflictProgress* |
| 66 StatusController::GetUnrestrictedMutableConflictProgressForTest( | 66 StatusController::GetUnrestrictedMutableConflictProgressForTest( |
| 67 ModelSafeGroup group) { | 67 ModelSafeGroup group) { |
| 68 return &GetOrCreateModelSafeGroupState(false, group)->conflict_progress; | 68 return &GetOrCreateModelSafeGroupState(false, group)->conflict_progress; |
| 69 } | 69 } |
| 70 | 70 |
| 71 std::set<ModelSafeGroup> |
| 72 StatusController::GetModelSafeGroupsWithUnappliedUpdates() const { |
| 73 std::set<ModelSafeGroup> result; |
| 74 std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it = |
| 75 per_model_group_.begin(); |
| 76 for (; it != per_model_group_.end(); ++it) { |
| 77 if (it->second->update_progress.HasUnappliedUpdates()) |
| 78 result.insert(it->first); |
| 79 } |
| 80 return result; |
| 81 } |
| 82 |
| 71 const UpdateProgress* StatusController::GetUnrestrictedUpdateProgress( | 83 const UpdateProgress* StatusController::GetUnrestrictedUpdateProgress( |
| 72 ModelSafeGroup group) const { | 84 ModelSafeGroup group) const { |
| 73 const PerModelSafeGroupState* state = | 85 const PerModelSafeGroupState* state = |
| 74 GetModelSafeGroupState(false, group); | 86 GetModelSafeGroupState(false, group); |
| 75 return state ? &state->update_progress : NULL; | 87 return state ? &state->update_progress : NULL; |
| 76 } | 88 } |
| 77 | 89 |
| 78 UpdateProgress* | 90 UpdateProgress* |
| 79 StatusController::GetUnrestrictedMutableUpdateProgressForTest( | 91 StatusController::GetUnrestrictedMutableUpdateProgressForTest( |
| 80 ModelSafeGroup group) { | 92 ModelSafeGroup group) { |
| 81 return &GetOrCreateModelSafeGroupState(false, group)->update_progress; | 93 return &GetOrCreateModelSafeGroupState(false, group)->update_progress; |
| 82 } | 94 } |
| 83 | 95 |
| 84 const PerModelSafeGroupState* StatusController::GetModelSafeGroupState( | 96 const PerModelSafeGroupState* StatusController::GetModelSafeGroupState( |
| 85 bool restrict, ModelSafeGroup group) const { | 97 bool restrict, ModelSafeGroup group) const { |
| 86 DCHECK_EQ(restrict, group_restriction_in_effect_); | 98 DCHECK_EQ(restrict, group_restriction_in_effect_); |
| 87 std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it = | 99 std::map<ModelSafeGroup, PerModelSafeGroupState*>::const_iterator it = |
| 88 per_model_group_.find(group); | 100 per_model_group_.find(group); |
| 89 return (it == per_model_group_.end()) ? NULL : it->second; | 101 return (it == per_model_group_.end()) ? NULL : it->second; |
| 90 } | 102 } |
| 91 | 103 |
| 92 PerModelSafeGroupState* StatusController::GetOrCreateModelSafeGroupState( | 104 PerModelSafeGroupState* StatusController::GetOrCreateModelSafeGroupState( |
| 93 bool restrict, ModelSafeGroup group) { | 105 bool restrict, ModelSafeGroup group) { |
| 94 DCHECK_EQ(restrict, group_restriction_in_effect_); | 106 DCHECK_EQ(restrict, group_restriction_in_effect_); |
| 95 std::map<ModelSafeGroup, PerModelSafeGroupState*>::iterator it = | 107 std::map<ModelSafeGroup, PerModelSafeGroupState*>::iterator it = |
| 96 per_model_group_.find(group); | 108 per_model_group_.find(group); |
| 97 if (it == per_model_group_.end()) { | 109 if (it == per_model_group_.end()) { |
| 98 PerModelSafeGroupState* state = new PerModelSafeGroupState(&is_dirty_); | 110 PerModelSafeGroupState* state = |
| 111 new PerModelSafeGroupState(&is_dirty_, group, routing_info_); |
| 99 it = per_model_group_.insert(std::make_pair(group, state)).first; | 112 it = per_model_group_.insert(std::make_pair(group, state)).first; |
| 100 } | 113 } |
| 101 return it->second; | 114 return it->second; |
| 102 } | 115 } |
| 103 | 116 |
| 104 void StatusController::increment_num_updates_downloaded_by(int value) { | 117 void StatusController::increment_num_updates_downloaded_by(int value) { |
| 105 shared_.syncer_status.mutate()->num_updates_downloaded_total += value; | 118 shared_.syncer_status.mutate()->num_updates_downloaded_total += value; |
| 106 } | 119 } |
| 107 | 120 |
| 108 void StatusController::set_types_needing_local_migration( | 121 void StatusController::set_types_needing_local_migration( |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 void StatusController::set_debug_info_sent() { | 320 void StatusController::set_debug_info_sent() { |
| 308 shared_.control_params.debug_info_sent = true; | 321 shared_.control_params.debug_info_sent = true; |
| 309 } | 322 } |
| 310 | 323 |
| 311 bool StatusController::debug_info_sent() const { | 324 bool StatusController::debug_info_sent() const { |
| 312 return shared_.control_params.debug_info_sent; | 325 return shared_.control_params.debug_info_sent; |
| 313 } | 326 } |
| 314 | 327 |
| 315 } // namespace sessions | 328 } // namespace sessions |
| 316 } // namespace browser_sync | 329 } // namespace browser_sync |
| OLD | NEW |