| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 SyncSessionSnapshot::SyncSessionSnapshot( | 102 SyncSessionSnapshot::SyncSessionSnapshot( |
| 103 const SyncerStatus& syncer_status, | 103 const SyncerStatus& syncer_status, |
| 104 const ErrorCounters& errors, | 104 const ErrorCounters& errors, |
| 105 int64 num_server_changes_remaining, | 105 int64 num_server_changes_remaining, |
| 106 bool is_share_usable, | 106 bool is_share_usable, |
| 107 syncable::ModelTypeSet initial_sync_ended, | 107 syncable::ModelTypeSet initial_sync_ended, |
| 108 const std::string | 108 const std::string |
| 109 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT], | 109 (&download_progress_markers)[syncable::MODEL_TYPE_COUNT], |
| 110 bool more_to_sync, | 110 bool more_to_sync, |
| 111 bool is_silenced, | 111 bool is_silenced, |
| 112 int64 unsynced_count, | |
| 113 int num_encryption_conflicts, | 112 int num_encryption_conflicts, |
| 114 int num_hierarchy_conflicts, | 113 int num_hierarchy_conflicts, |
| 115 int num_simple_conflicts, | 114 int num_simple_conflicts, |
| 116 int num_server_conflicts, | 115 int num_server_conflicts, |
| 117 bool did_commit_items, | |
| 118 const SyncSourceInfo& source, | 116 const SyncSourceInfo& source, |
| 119 bool notifications_enabled, | 117 bool notifications_enabled, |
| 120 size_t num_entries, | 118 size_t num_entries, |
| 121 base::Time sync_start_time, | 119 base::Time sync_start_time, |
| 122 bool retry_scheduled) | 120 bool retry_scheduled) |
| 123 : syncer_status(syncer_status), | 121 : syncer_status(syncer_status), |
| 124 errors(errors), | 122 errors(errors), |
| 125 num_server_changes_remaining(num_server_changes_remaining), | 123 num_server_changes_remaining(num_server_changes_remaining), |
| 126 is_share_usable(is_share_usable), | 124 is_share_usable(is_share_usable), |
| 127 initial_sync_ended(initial_sync_ended), | 125 initial_sync_ended(initial_sync_ended), |
| 128 download_progress_markers(), | 126 download_progress_markers(), |
| 129 has_more_to_sync(more_to_sync), | 127 has_more_to_sync(more_to_sync), |
| 130 is_silenced(is_silenced), | 128 is_silenced(is_silenced), |
| 131 unsynced_count(unsynced_count), | |
| 132 num_encryption_conflicts(num_encryption_conflicts), | 129 num_encryption_conflicts(num_encryption_conflicts), |
| 133 num_hierarchy_conflicts(num_hierarchy_conflicts), | 130 num_hierarchy_conflicts(num_hierarchy_conflicts), |
| 134 num_simple_conflicts(num_simple_conflicts), | 131 num_simple_conflicts(num_simple_conflicts), |
| 135 num_server_conflicts(num_server_conflicts), | 132 num_server_conflicts(num_server_conflicts), |
| 136 did_commit_items(did_commit_items), | |
| 137 source(source), | 133 source(source), |
| 138 notifications_enabled(notifications_enabled), | 134 notifications_enabled(notifications_enabled), |
| 139 num_entries(num_entries), | 135 num_entries(num_entries), |
| 140 sync_start_time(sync_start_time), | 136 sync_start_time(sync_start_time), |
| 141 retry_scheduled(retry_scheduled) { | 137 retry_scheduled(retry_scheduled) { |
| 142 for (int i = syncable::FIRST_REAL_MODEL_TYPE; | 138 for (int i = syncable::FIRST_REAL_MODEL_TYPE; |
| 143 i < syncable::MODEL_TYPE_COUNT; ++i) { | 139 i < syncable::MODEL_TYPE_COUNT; ++i) { |
| 144 const_cast<std::string&>(this->download_progress_markers[i]).assign( | 140 const_cast<std::string&>(this->download_progress_markers[i]).assign( |
| 145 download_progress_markers[i]); | 141 download_progress_markers[i]); |
| 146 } | 142 } |
| 147 } | 143 } |
| 148 | 144 |
| 149 SyncSessionSnapshot::~SyncSessionSnapshot() {} | 145 SyncSessionSnapshot::~SyncSessionSnapshot() {} |
| 150 | 146 |
| 151 DictionaryValue* SyncSessionSnapshot::ToValue() const { | 147 DictionaryValue* SyncSessionSnapshot::ToValue() const { |
| 152 DictionaryValue* value = new DictionaryValue(); | 148 DictionaryValue* value = new DictionaryValue(); |
| 153 value->Set("syncerStatus", syncer_status.ToValue()); | 149 value->Set("syncerStatus", syncer_status.ToValue()); |
| 154 // We don't care too much if we lose precision here. | 150 // We don't care too much if we lose precision here. |
| 155 value->SetInteger("numServerChangesRemaining", | 151 value->SetInteger("numServerChangesRemaining", |
| 156 static_cast<int>(num_server_changes_remaining)); | 152 static_cast<int>(num_server_changes_remaining)); |
| 157 value->SetBoolean("isShareUsable", is_share_usable); | 153 value->SetBoolean("isShareUsable", is_share_usable); |
| 158 value->Set("initialSyncEnded", | 154 value->Set("initialSyncEnded", |
| 159 syncable::ModelTypeSetToValue(initial_sync_ended)); | 155 syncable::ModelTypeSetToValue(initial_sync_ended)); |
| 160 value->Set("downloadProgressMarkers", | 156 value->Set("downloadProgressMarkers", |
| 161 DownloadProgressMarkersToValue(download_progress_markers)); | 157 DownloadProgressMarkersToValue(download_progress_markers)); |
| 162 value->SetBoolean("hasMoreToSync", has_more_to_sync); | 158 value->SetBoolean("hasMoreToSync", has_more_to_sync); |
| 163 value->SetBoolean("isSilenced", is_silenced); | 159 value->SetBoolean("isSilenced", is_silenced); |
| 164 // We don't care too much if we lose precision here, also. | 160 // We don't care too much if we lose precision here, also. |
| 165 value->SetInteger("unsyncedCount", | |
| 166 static_cast<int>(unsynced_count)); | |
| 167 value->SetInteger("numEncryptionConflicts", | 161 value->SetInteger("numEncryptionConflicts", |
| 168 num_encryption_conflicts); | 162 num_encryption_conflicts); |
| 169 value->SetInteger("numHierarchyConflicts", | 163 value->SetInteger("numHierarchyConflicts", |
| 170 num_hierarchy_conflicts); | 164 num_hierarchy_conflicts); |
| 171 value->SetInteger("numSimpleConflicts", | 165 value->SetInteger("numSimpleConflicts", |
| 172 num_simple_conflicts); | 166 num_simple_conflicts); |
| 173 value->SetInteger("numServerConflicts", | 167 value->SetInteger("numServerConflicts", |
| 174 num_server_conflicts); | 168 num_server_conflicts); |
| 175 value->SetBoolean("didCommitItems", did_commit_items); | |
| 176 value->SetInteger("numEntries", num_entries); | 169 value->SetInteger("numEntries", num_entries); |
| 177 value->Set("source", source.ToValue()); | 170 value->Set("source", source.ToValue()); |
| 178 value->SetBoolean("notificationsEnabled", notifications_enabled); | 171 value->SetBoolean("notificationsEnabled", notifications_enabled); |
| 179 return value; | 172 return value; |
| 180 } | 173 } |
| 181 | 174 |
| 182 std::string SyncSessionSnapshot::ToString() const { | 175 std::string SyncSessionSnapshot::ToString() const { |
| 183 scoped_ptr<DictionaryValue> value(ToValue()); | 176 scoped_ptr<DictionaryValue> value(ToValue()); |
| 184 std::string json; | 177 std::string json; |
| 185 base::JSONWriter::WriteWithOptions(value.get(), | 178 base::JSONWriter::WriteWithOptions(value.get(), |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 std::vector<AppliedUpdate>::const_iterator it; | 298 std::vector<AppliedUpdate>::const_iterator it; |
| 306 for (it = applied_updates_.begin(); it != applied_updates_.end(); ++it) { | 299 for (it = applied_updates_.begin(); it != applied_updates_.end(); ++it) { |
| 307 if (it->first != SUCCESS) { | 300 if (it->first != SUCCESS) { |
| 308 return true; | 301 return true; |
| 309 } | 302 } |
| 310 } | 303 } |
| 311 return false; | 304 return false; |
| 312 } | 305 } |
| 313 | 306 |
| 314 AllModelTypeState::AllModelTypeState(bool* dirty_flag) | 307 AllModelTypeState::AllModelTypeState(bool* dirty_flag) |
| 315 : unsynced_handles(dirty_flag), | 308 : syncer_status(dirty_flag), |
| 316 syncer_status(dirty_flag), | |
| 317 error(dirty_flag), | 309 error(dirty_flag), |
| 318 num_server_changes_remaining(dirty_flag, 0), | 310 num_server_changes_remaining(dirty_flag, 0) { |
| 319 commit_set(ModelSafeRoutingInfo()) { | |
| 320 } | 311 } |
| 321 | 312 |
| 322 AllModelTypeState::~AllModelTypeState() {} | 313 AllModelTypeState::~AllModelTypeState() {} |
| 323 | 314 |
| 324 PerModelSafeGroupState::PerModelSafeGroupState(bool* dirty_flag) | 315 PerModelSafeGroupState::PerModelSafeGroupState(bool* dirty_flag) |
| 325 : conflict_progress(dirty_flag) { | 316 : conflict_progress(dirty_flag) { |
| 326 } | 317 } |
| 327 | 318 |
| 328 PerModelSafeGroupState::~PerModelSafeGroupState() { | 319 PerModelSafeGroupState::~PerModelSafeGroupState() { |
| 329 } | 320 } |
| 330 | 321 |
| 331 } // namespace sessions | 322 } // namespace sessions |
| 332 } // namespace browser_sync | 323 } // namespace browser_sync |
| OLD | NEW |