| 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 #include "chrome/browser/sync/sessions/status_controller.h" | 5 #include "chrome/browser/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 "chrome/browser/sync/protocol/sync_protocol_error.h" |
| 10 #include "chrome/browser/sync/syncable/model_type.h" | 11 #include "chrome/browser/sync/syncable/model_type.h" |
| 11 | 12 |
| 12 namespace browser_sync { | 13 namespace browser_sync { |
| 13 namespace sessions { | 14 namespace sessions { |
| 14 | 15 |
| 15 using syncable::FIRST_REAL_MODEL_TYPE; | 16 using syncable::FIRST_REAL_MODEL_TYPE; |
| 16 using syncable::MODEL_TYPE_COUNT; | 17 using syncable::MODEL_TYPE_COUNT; |
| 17 | 18 |
| 18 StatusController::StatusController(const ModelSafeRoutingInfo& routes) | 19 StatusController::StatusController(const ModelSafeRoutingInfo& routes) |
| 19 : shared_(&is_dirty_), | 20 : shared_(&is_dirty_), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 39 PerModelSafeGroupState* state = new PerModelSafeGroupState(&is_dirty_); | 40 PerModelSafeGroupState* state = new PerModelSafeGroupState(&is_dirty_); |
| 40 per_model_group_[group] = state; | 41 per_model_group_[group] = state; |
| 41 return state; | 42 return state; |
| 42 } | 43 } |
| 43 return per_model_group_[group]; | 44 return per_model_group_[group]; |
| 44 } | 45 } |
| 45 | 46 |
| 46 void StatusController::increment_num_conflicting_commits_by(int value) { | 47 void StatusController::increment_num_conflicting_commits_by(int value) { |
| 47 if (value == 0) | 48 if (value == 0) |
| 48 return; | 49 return; |
| 49 shared_.error_counters.mutate()->num_conflicting_commits += value; | 50 shared_.error.mutate()->num_conflicting_commits += value; |
| 50 } | 51 } |
| 51 | 52 |
| 52 void StatusController::increment_num_updates_downloaded_by(int value) { | 53 void StatusController::increment_num_updates_downloaded_by(int value) { |
| 53 shared_.syncer_status.mutate()->num_updates_downloaded_total += value; | 54 shared_.syncer_status.mutate()->num_updates_downloaded_total += value; |
| 54 } | 55 } |
| 55 | 56 |
| 56 void StatusController::set_types_needing_local_migration( | 57 void StatusController::set_types_needing_local_migration( |
| 57 const syncable::ModelTypeSet& types) { | 58 const syncable::ModelTypeSet& types) { |
| 58 shared_.syncer_status.mutate()->types_needing_local_migration = types; | 59 shared_.syncer_status.mutate()->types_needing_local_migration = types; |
| 59 } | 60 } |
| 60 | 61 |
| 61 void StatusController::increment_num_tombstone_updates_downloaded_by( | 62 void StatusController::increment_num_tombstone_updates_downloaded_by( |
| 62 int value) { | 63 int value) { |
| 63 shared_.syncer_status.mutate()->num_tombstone_updates_downloaded_total += | 64 shared_.syncer_status.mutate()->num_tombstone_updates_downloaded_total += |
| 64 value; | 65 value; |
| 65 } | 66 } |
| 66 | 67 |
| 67 void StatusController::reset_num_conflicting_commits() { | 68 void StatusController::reset_num_conflicting_commits() { |
| 68 if (shared_.error_counters.value().num_conflicting_commits != 0) | 69 if (shared_.error.value().num_conflicting_commits != 0) |
| 69 shared_.error_counters.mutate()->num_conflicting_commits = 0; | 70 shared_.error.mutate()->num_conflicting_commits = 0; |
| 70 } | 71 } |
| 71 | 72 |
| 72 void StatusController::set_num_consecutive_transient_error_commits(int value) { | 73 void StatusController::set_num_consecutive_transient_error_commits(int value) { |
| 73 if (shared_.error_counters.value().consecutive_transient_error_commits != | 74 if (shared_.error.value().consecutive_transient_error_commits != |
| 74 value) { | 75 value) { |
| 75 shared_.error_counters.mutate()->consecutive_transient_error_commits = | 76 shared_.error.mutate()->consecutive_transient_error_commits = |
| 76 value; | 77 value; |
| 77 } | 78 } |
| 78 } | 79 } |
| 79 | 80 |
| 80 void StatusController::increment_num_consecutive_transient_error_commits_by( | 81 void StatusController::increment_num_consecutive_transient_error_commits_by( |
| 81 int value) { | 82 int value) { |
| 82 set_num_consecutive_transient_error_commits( | 83 set_num_consecutive_transient_error_commits( |
| 83 shared_.error_counters.value().consecutive_transient_error_commits + | 84 shared_.error.value().consecutive_transient_error_commits + |
| 84 value); | 85 value); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void StatusController::set_num_consecutive_errors(int value) { | 88 void StatusController::set_num_consecutive_errors(int value) { |
| 88 if (shared_.error_counters.value().consecutive_errors != value) | 89 if (shared_.error.value().consecutive_errors != value) |
| 89 shared_.error_counters.mutate()->consecutive_errors = value; | 90 shared_.error.mutate()->consecutive_errors = value; |
| 90 } | 91 } |
| 91 | 92 |
| 92 void StatusController::set_num_server_changes_remaining( | 93 void StatusController::set_num_server_changes_remaining( |
| 93 int64 changes_remaining) { | 94 int64 changes_remaining) { |
| 94 if (shared_.num_server_changes_remaining.value() != changes_remaining) | 95 if (shared_.num_server_changes_remaining.value() != changes_remaining) |
| 95 *(shared_.num_server_changes_remaining.mutate()) = changes_remaining; | 96 *(shared_.num_server_changes_remaining.mutate()) = changes_remaining; |
| 96 } | 97 } |
| 97 | 98 |
| 98 void StatusController::set_invalid_store(bool invalid_store) { | 99 void StatusController::set_invalid_store(bool invalid_store) { |
| 99 if (shared_.syncer_status.value().invalid_store != invalid_store) | 100 if (shared_.syncer_status.value().invalid_store != invalid_store) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 120 | 121 |
| 121 void StatusController::set_unsynced_handles( | 122 void StatusController::set_unsynced_handles( |
| 122 const std::vector<int64>& unsynced_handles) { | 123 const std::vector<int64>& unsynced_handles) { |
| 123 if (!operator==(unsynced_handles, shared_.unsynced_handles.value())) { | 124 if (!operator==(unsynced_handles, shared_.unsynced_handles.value())) { |
| 124 *(shared_.unsynced_handles.mutate()) = unsynced_handles; | 125 *(shared_.unsynced_handles.mutate()) = unsynced_handles; |
| 125 } | 126 } |
| 126 } | 127 } |
| 127 | 128 |
| 128 void StatusController::increment_num_consecutive_errors() { | 129 void StatusController::increment_num_consecutive_errors() { |
| 129 set_num_consecutive_errors( | 130 set_num_consecutive_errors( |
| 130 shared_.error_counters.value().consecutive_errors + 1); | 131 shared_.error.value().consecutive_errors + 1); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void StatusController::increment_num_consecutive_errors_by(int value) { | 134 void StatusController::increment_num_consecutive_errors_by(int value) { |
| 134 set_num_consecutive_errors( | 135 set_num_consecutive_errors( |
| 135 shared_.error_counters.value().consecutive_errors + value); | 136 shared_.error.value().consecutive_errors + value); |
| 136 } | 137 } |
| 137 | 138 |
| 138 void StatusController::increment_num_successful_bookmark_commits() { | 139 void StatusController::increment_num_successful_bookmark_commits() { |
| 139 set_num_successful_bookmark_commits( | 140 set_num_successful_bookmark_commits( |
| 140 shared_.syncer_status.value().num_successful_bookmark_commits + 1); | 141 shared_.syncer_status.value().num_successful_bookmark_commits + 1); |
| 141 } | 142 } |
| 142 | 143 |
| 143 void StatusController::increment_num_successful_commits() { | 144 void StatusController::increment_num_successful_commits() { |
| 144 shared_.syncer_status.mutate()->num_successful_commits++; | 145 shared_.syncer_status.mutate()->num_successful_commits++; |
| 145 } | 146 } |
| 146 | 147 |
| 147 void StatusController::increment_num_local_overwrites() { | 148 void StatusController::increment_num_local_overwrites() { |
| 148 shared_.syncer_status.mutate()->num_local_overwrites++; | 149 shared_.syncer_status.mutate()->num_local_overwrites++; |
| 149 } | 150 } |
| 150 | 151 |
| 151 void StatusController::increment_num_server_overwrites() { | 152 void StatusController::increment_num_server_overwrites() { |
| 152 shared_.syncer_status.mutate()->num_server_overwrites++; | 153 shared_.syncer_status.mutate()->num_server_overwrites++; |
| 153 } | 154 } |
| 154 | 155 |
| 156 void StatusController::set_sync_protocol_error( |
| 157 const SyncProtocolError& error) { |
| 158 shared_.error.mutate()->sync_protocol_error = error; |
| 159 } |
| 160 |
| 155 void StatusController::set_commit_set(const OrderedCommitSet& commit_set) { | 161 void StatusController::set_commit_set(const OrderedCommitSet& commit_set) { |
| 156 DCHECK(!group_restriction_in_effect_); | 162 DCHECK(!group_restriction_in_effect_); |
| 157 shared_.commit_set = commit_set; | 163 shared_.commit_set = commit_set; |
| 158 } | 164 } |
| 159 | 165 |
| 160 void StatusController::update_conflict_sets_built(bool built) { | 166 void StatusController::update_conflict_sets_built(bool built) { |
| 161 shared_.control_params.conflict_sets_built |= built; | 167 shared_.control_params.conflict_sets_built |= built; |
| 162 } | 168 } |
| 163 void StatusController::update_conflicts_resolved(bool resolved) { | 169 void StatusController::update_conflicts_resolved(bool resolved) { |
| 164 shared_.control_params.conflict_sets_built |= resolved; | 170 shared_.control_params.conflict_sets_built |= resolved; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 NOTREACHED(); // Server should always send changes remaining. | 237 NOTREACHED(); // Server should always send changes remaining. |
| 232 return false; // Avoid looping forever. | 238 return false; // Avoid looping forever. |
| 233 } | 239 } |
| 234 // Changes remaining is an estimate, but if it's estimated to be | 240 // Changes remaining is an estimate, but if it's estimated to be |
| 235 // zero, that's firm and we don't have to ask again. | 241 // zero, that's firm and we don't have to ask again. |
| 236 return updates_response().get_updates().changes_remaining() == 0; | 242 return updates_response().get_updates().changes_remaining() == 0; |
| 237 } | 243 } |
| 238 | 244 |
| 239 } // namespace sessions | 245 } // namespace sessions |
| 240 } // namespace browser_sync | 246 } // namespace browser_sync |
| OLD | NEW |