| 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/session_state.h" | 5 #include "sync/sessions/session_state.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 : last_download_updates_result(UNSET), | 79 : last_download_updates_result(UNSET), |
| 80 last_post_commit_result(UNSET), | 80 last_post_commit_result(UNSET), |
| 81 last_process_commit_response_result(UNSET) { | 81 last_process_commit_response_result(UNSET) { |
| 82 } | 82 } |
| 83 | 83 |
| 84 SyncSessionSnapshot::SyncSessionSnapshot() | 84 SyncSessionSnapshot::SyncSessionSnapshot() |
| 85 : num_server_changes_remaining_(0), | 85 : num_server_changes_remaining_(0), |
| 86 is_share_usable_(false), | 86 is_share_usable_(false), |
| 87 has_more_to_sync_(false), | 87 has_more_to_sync_(false), |
| 88 is_silenced_(false), | 88 is_silenced_(false), |
| 89 unsynced_count_(0), | |
| 90 num_encryption_conflicts_(0), | 89 num_encryption_conflicts_(0), |
| 91 num_hierarchy_conflicts_(0), | 90 num_hierarchy_conflicts_(0), |
| 92 num_simple_conflicts_(0), | 91 num_simple_conflicts_(0), |
| 93 num_server_conflicts_(0), | 92 num_server_conflicts_(0), |
| 94 did_commit_items_(false), | |
| 95 notifications_enabled_(false), | 93 notifications_enabled_(false), |
| 96 num_entries_(0), | 94 num_entries_(0), |
| 97 retry_scheduled_(false) { | 95 retry_scheduled_(false) { |
| 98 } | 96 } |
| 99 | 97 |
| 100 SyncSessionSnapshot::SyncSessionSnapshot( | 98 SyncSessionSnapshot::SyncSessionSnapshot( |
| 101 const SyncerStatus& syncer_status, | 99 const SyncerStatus& syncer_status, |
| 102 const ErrorCounters& errors, | 100 const ErrorCounters& errors, |
| 103 int64 num_server_changes_remaining, | 101 int64 num_server_changes_remaining, |
| 104 bool is_share_usable, | 102 bool is_share_usable, |
| 105 syncable::ModelTypeSet initial_sync_ended, | 103 syncable::ModelTypeSet initial_sync_ended, |
| 106 const syncable::ModelTypePayloadMap& download_progress_markers, | 104 const syncable::ModelTypePayloadMap& download_progress_markers, |
| 107 bool more_to_sync, | 105 bool more_to_sync, |
| 108 bool is_silenced, | 106 bool is_silenced, |
| 109 int64 unsynced_count, | |
| 110 int num_encryption_conflicts, | 107 int num_encryption_conflicts, |
| 111 int num_hierarchy_conflicts, | 108 int num_hierarchy_conflicts, |
| 112 int num_simple_conflicts, | 109 int num_simple_conflicts, |
| 113 int num_server_conflicts, | 110 int num_server_conflicts, |
| 114 bool did_commit_items, | |
| 115 const SyncSourceInfo& source, | 111 const SyncSourceInfo& source, |
| 116 bool notifications_enabled, | 112 bool notifications_enabled, |
| 117 size_t num_entries, | 113 size_t num_entries, |
| 118 base::Time sync_start_time, | 114 base::Time sync_start_time, |
| 119 bool retry_scheduled) | 115 bool retry_scheduled) |
| 120 : syncer_status_(syncer_status), | 116 : syncer_status_(syncer_status), |
| 121 errors_(errors), | 117 errors_(errors), |
| 122 num_server_changes_remaining_(num_server_changes_remaining), | 118 num_server_changes_remaining_(num_server_changes_remaining), |
| 123 is_share_usable_(is_share_usable), | 119 is_share_usable_(is_share_usable), |
| 124 initial_sync_ended_(initial_sync_ended), | 120 initial_sync_ended_(initial_sync_ended), |
| 125 download_progress_markers_(download_progress_markers), | 121 download_progress_markers_(download_progress_markers), |
| 126 has_more_to_sync_(more_to_sync), | 122 has_more_to_sync_(more_to_sync), |
| 127 is_silenced_(is_silenced), | 123 is_silenced_(is_silenced), |
| 128 unsynced_count_(unsynced_count), | |
| 129 num_encryption_conflicts_(num_encryption_conflicts), | 124 num_encryption_conflicts_(num_encryption_conflicts), |
| 130 num_hierarchy_conflicts_(num_hierarchy_conflicts), | 125 num_hierarchy_conflicts_(num_hierarchy_conflicts), |
| 131 num_simple_conflicts_(num_simple_conflicts), | 126 num_simple_conflicts_(num_simple_conflicts), |
| 132 num_server_conflicts_(num_server_conflicts), | 127 num_server_conflicts_(num_server_conflicts), |
| 133 did_commit_items_(did_commit_items), | |
| 134 source_(source), | 128 source_(source), |
| 135 notifications_enabled_(notifications_enabled), | 129 notifications_enabled_(notifications_enabled), |
| 136 num_entries_(num_entries), | 130 num_entries_(num_entries), |
| 137 sync_start_time_(sync_start_time), | 131 sync_start_time_(sync_start_time), |
| 138 retry_scheduled_(retry_scheduled) { | 132 retry_scheduled_(retry_scheduled) { |
| 139 } | 133 } |
| 140 | 134 |
| 141 SyncSessionSnapshot::~SyncSessionSnapshot() {} | 135 SyncSessionSnapshot::~SyncSessionSnapshot() {} |
| 142 | 136 |
| 143 DictionaryValue* SyncSessionSnapshot::ToValue() const { | 137 DictionaryValue* SyncSessionSnapshot::ToValue() const { |
| 144 DictionaryValue* value = new DictionaryValue(); | 138 DictionaryValue* value = new DictionaryValue(); |
| 145 value->Set("syncerStatus", syncer_status_.ToValue()); | 139 value->Set("syncerStatus", syncer_status_.ToValue()); |
| 146 // We don't care too much if we lose precision here. | 140 // We don't care too much if we lose precision here. |
| 147 value->SetInteger("numServerChangesRemaining", | 141 value->SetInteger("numServerChangesRemaining", |
| 148 static_cast<int>(num_server_changes_remaining_)); | 142 static_cast<int>(num_server_changes_remaining_)); |
| 149 value->SetBoolean("isShareUsable", is_share_usable_); | 143 value->SetBoolean("isShareUsable", is_share_usable_); |
| 150 value->Set("initialSyncEnded", | 144 value->Set("initialSyncEnded", |
| 151 syncable::ModelTypeSetToValue(initial_sync_ended_)); | 145 syncable::ModelTypeSetToValue(initial_sync_ended_)); |
| 152 value->Set("downloadProgressMarkers", | 146 value->Set("downloadProgressMarkers", |
| 153 syncable::ModelTypePayloadMapToValue(download_progress_markers_)); | 147 syncable::ModelTypePayloadMapToValue(download_progress_markers_)); |
| 154 value->SetBoolean("hasMoreToSync", has_more_to_sync_); | 148 value->SetBoolean("hasMoreToSync", has_more_to_sync_); |
| 155 value->SetBoolean("isSilenced", is_silenced_); | 149 value->SetBoolean("isSilenced", is_silenced_); |
| 156 // We don't care too much if we lose precision here, also. | 150 // We don't care too much if we lose precision here, also. |
| 157 value->SetInteger("unsyncedCount", | |
| 158 static_cast<int>(unsynced_count_)); | |
| 159 value->SetInteger("numEncryptionConflicts", | 151 value->SetInteger("numEncryptionConflicts", |
| 160 num_encryption_conflicts_); | 152 num_encryption_conflicts_); |
| 161 value->SetInteger("numHierarchyConflicts", | 153 value->SetInteger("numHierarchyConflicts", |
| 162 num_hierarchy_conflicts_); | 154 num_hierarchy_conflicts_); |
| 163 value->SetInteger("numSimpleConflicts", | 155 value->SetInteger("numSimpleConflicts", |
| 164 num_simple_conflicts_); | 156 num_simple_conflicts_); |
| 165 value->SetInteger("numServerConflicts", | 157 value->SetInteger("numServerConflicts", |
| 166 num_server_conflicts_); | 158 num_server_conflicts_); |
| 167 value->SetBoolean("didCommitItems", did_commit_items_); | |
| 168 value->SetInteger("numEntries", num_entries_); | 159 value->SetInteger("numEntries", num_entries_); |
| 169 value->Set("source", source_.ToValue()); | 160 value->Set("source", source_.ToValue()); |
| 170 value->SetBoolean("notificationsEnabled", notifications_enabled_); | 161 value->SetBoolean("notificationsEnabled", notifications_enabled_); |
| 171 return value; | 162 return value; |
| 172 } | 163 } |
| 173 | 164 |
| 174 std::string SyncSessionSnapshot::ToString() const { | 165 std::string SyncSessionSnapshot::ToString() const { |
| 175 scoped_ptr<DictionaryValue> value(ToValue()); | 166 scoped_ptr<DictionaryValue> value(ToValue()); |
| 176 std::string json; | 167 std::string json; |
| 177 base::JSONWriter::WriteWithOptions(value.get(), | 168 base::JSONWriter::WriteWithOptions(value.get(), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 206 } | 197 } |
| 207 | 198 |
| 208 bool SyncSessionSnapshot::has_more_to_sync() const { | 199 bool SyncSessionSnapshot::has_more_to_sync() const { |
| 209 return has_more_to_sync_; | 200 return has_more_to_sync_; |
| 210 } | 201 } |
| 211 | 202 |
| 212 bool SyncSessionSnapshot::is_silenced() const { | 203 bool SyncSessionSnapshot::is_silenced() const { |
| 213 return is_silenced_; | 204 return is_silenced_; |
| 214 } | 205 } |
| 215 | 206 |
| 216 int64 SyncSessionSnapshot::unsynced_count() const { | |
| 217 return unsynced_count_; | |
| 218 } | |
| 219 | |
| 220 int SyncSessionSnapshot::num_encryption_conflicts() const { | 207 int SyncSessionSnapshot::num_encryption_conflicts() const { |
| 221 return num_encryption_conflicts_; | 208 return num_encryption_conflicts_; |
| 222 } | 209 } |
| 223 | 210 |
| 224 int SyncSessionSnapshot::num_hierarchy_conflicts() const { | 211 int SyncSessionSnapshot::num_hierarchy_conflicts() const { |
| 225 return num_hierarchy_conflicts_; | 212 return num_hierarchy_conflicts_; |
| 226 } | 213 } |
| 227 | 214 |
| 228 int SyncSessionSnapshot::num_simple_conflicts() const { | 215 int SyncSessionSnapshot::num_simple_conflicts() const { |
| 229 return num_simple_conflicts_; | 216 return num_simple_conflicts_; |
| 230 } | 217 } |
| 231 | 218 |
| 232 int SyncSessionSnapshot::num_server_conflicts() const { | 219 int SyncSessionSnapshot::num_server_conflicts() const { |
| 233 return num_server_conflicts_; | 220 return num_server_conflicts_; |
| 234 } | 221 } |
| 235 | 222 |
| 236 bool SyncSessionSnapshot::did_commit_items() const { | |
| 237 return did_commit_items_; | |
| 238 } | |
| 239 | |
| 240 SyncSourceInfo SyncSessionSnapshot::source() const { | 223 SyncSourceInfo SyncSessionSnapshot::source() const { |
| 241 return source_; | 224 return source_; |
| 242 } | 225 } |
| 243 | 226 |
| 244 bool SyncSessionSnapshot::notifications_enabled() const { | 227 bool SyncSessionSnapshot::notifications_enabled() const { |
| 245 return notifications_enabled_; | 228 return notifications_enabled_; |
| 246 } | 229 } |
| 247 | 230 |
| 248 size_t SyncSessionSnapshot::num_entries() const { | 231 size_t SyncSessionSnapshot::num_entries() const { |
| 249 return num_entries_; | 232 return num_entries_; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 std::vector<AppliedUpdate>::const_iterator it; | 357 std::vector<AppliedUpdate>::const_iterator it; |
| 375 for (it = applied_updates_.begin(); it != applied_updates_.end(); ++it) { | 358 for (it = applied_updates_.begin(); it != applied_updates_.end(); ++it) { |
| 376 if (it->first != SUCCESS) { | 359 if (it->first != SUCCESS) { |
| 377 return true; | 360 return true; |
| 378 } | 361 } |
| 379 } | 362 } |
| 380 return false; | 363 return false; |
| 381 } | 364 } |
| 382 | 365 |
| 383 AllModelTypeState::AllModelTypeState(bool* dirty_flag) | 366 AllModelTypeState::AllModelTypeState(bool* dirty_flag) |
| 384 : unsynced_handles(dirty_flag), | 367 : syncer_status(dirty_flag), |
| 385 syncer_status(dirty_flag), | |
| 386 error(dirty_flag), | 368 error(dirty_flag), |
| 387 num_server_changes_remaining(dirty_flag, 0), | 369 num_server_changes_remaining(dirty_flag, 0) { |
| 388 commit_set(ModelSafeRoutingInfo()) { | |
| 389 } | 370 } |
| 390 | 371 |
| 391 AllModelTypeState::~AllModelTypeState() {} | 372 AllModelTypeState::~AllModelTypeState() {} |
| 392 | 373 |
| 393 PerModelSafeGroupState::PerModelSafeGroupState(bool* dirty_flag) | 374 PerModelSafeGroupState::PerModelSafeGroupState(bool* dirty_flag) |
| 394 : conflict_progress(dirty_flag) { | 375 : conflict_progress(dirty_flag) { |
| 395 } | 376 } |
| 396 | 377 |
| 397 PerModelSafeGroupState::~PerModelSafeGroupState() { | 378 PerModelSafeGroupState::~PerModelSafeGroupState() { |
| 398 } | 379 } |
| 399 | 380 |
| 400 } // namespace sessions | 381 } // namespace sessions |
| 401 } // namespace browser_sync | 382 } // namespace browser_sync |
| OLD | NEW |