diff options
Diffstat (limited to 'sync/sessions/session_state.cc')
-rw-r--r-- | sync/sessions/session_state.cc | 189 |
1 files changed, 129 insertions, 60 deletions
diff --git a/sync/sessions/session_state.cc b/sync/sessions/session_state.cc index f49c41d..d0d23fa 100644 --- a/sync/sessions/session_state.cc +++ b/sync/sessions/session_state.cc @@ -75,38 +75,35 @@ DictionaryValue* SyncerStatus::ToValue() const { return value; } -DictionaryValue* DownloadProgressMarkersToValue( - const std::string - (&download_progress_markers)[syncable::MODEL_TYPE_COUNT]) { - DictionaryValue* value = new DictionaryValue(); - for (int i = syncable::FIRST_REAL_MODEL_TYPE; - i < syncable::MODEL_TYPE_COUNT; ++i) { - // TODO(akalin): Unpack the value into a protobuf. - std::string base64_marker; - bool encoded = - base::Base64Encode(download_progress_markers[i], &base64_marker); - DCHECK(encoded); - value->SetString( - syncable::ModelTypeToString(syncable::ModelTypeFromInt(i)), - base64_marker); - } - return value; -} - ErrorCounters::ErrorCounters() : last_download_updates_result(UNSET), last_post_commit_result(UNSET), last_process_commit_response_result(UNSET) { } +SyncSessionSnapshot::SyncSessionSnapshot() + : num_server_changes_remaining_(0), + is_share_usable_(false), + has_more_to_sync_(false), + is_silenced_(false), + unsynced_count_(0), + num_encryption_conflicts_(0), + num_hierarchy_conflicts_(0), + num_simple_conflicts_(0), + num_server_conflicts_(0), + did_commit_items_(false), + notifications_enabled_(false), + num_entries_(0), + retry_scheduled_(false) { +} + SyncSessionSnapshot::SyncSessionSnapshot( const SyncerStatus& syncer_status, const ErrorCounters& errors, int64 num_server_changes_remaining, bool is_share_usable, syncable::ModelTypeSet initial_sync_ended, - const std::string - (&download_progress_markers)[syncable::MODEL_TYPE_COUNT], + const syncable::ModelTypePayloadMap& download_progress_markers, bool more_to_sync, bool is_silenced, int64 unsynced_count, @@ -120,62 +117,57 @@ SyncSessionSnapshot::SyncSessionSnapshot( size_t num_entries, base::Time sync_start_time, bool retry_scheduled) - : syncer_status(syncer_status), - errors(errors), - num_server_changes_remaining(num_server_changes_remaining), - is_share_usable(is_share_usable), - initial_sync_ended(initial_sync_ended), - download_progress_markers(), - has_more_to_sync(more_to_sync), - is_silenced(is_silenced), - unsynced_count(unsynced_count), - num_encryption_conflicts(num_encryption_conflicts), - num_hierarchy_conflicts(num_hierarchy_conflicts), - num_simple_conflicts(num_simple_conflicts), - num_server_conflicts(num_server_conflicts), - did_commit_items(did_commit_items), - source(source), - notifications_enabled(notifications_enabled), - num_entries(num_entries), - sync_start_time(sync_start_time), - retry_scheduled(retry_scheduled) { - for (int i = syncable::FIRST_REAL_MODEL_TYPE; - i < syncable::MODEL_TYPE_COUNT; ++i) { - const_cast<std::string&>(this->download_progress_markers[i]).assign( - download_progress_markers[i]); - } + : syncer_status_(syncer_status), + errors_(errors), + num_server_changes_remaining_(num_server_changes_remaining), + is_share_usable_(is_share_usable), + initial_sync_ended_(initial_sync_ended), + download_progress_markers_(download_progress_markers), + has_more_to_sync_(more_to_sync), + is_silenced_(is_silenced), + unsynced_count_(unsynced_count), + num_encryption_conflicts_(num_encryption_conflicts), + num_hierarchy_conflicts_(num_hierarchy_conflicts), + num_simple_conflicts_(num_simple_conflicts), + num_server_conflicts_(num_server_conflicts), + did_commit_items_(did_commit_items), + source_(source), + notifications_enabled_(notifications_enabled), + num_entries_(num_entries), + sync_start_time_(sync_start_time), + retry_scheduled_(retry_scheduled) { } SyncSessionSnapshot::~SyncSessionSnapshot() {} DictionaryValue* SyncSessionSnapshot::ToValue() const { DictionaryValue* value = new DictionaryValue(); - value->Set("syncerStatus", syncer_status.ToValue()); + value->Set("syncerStatus", syncer_status_.ToValue()); // We don't care too much if we lose precision here. value->SetInteger("numServerChangesRemaining", - static_cast<int>(num_server_changes_remaining)); - value->SetBoolean("isShareUsable", is_share_usable); + static_cast<int>(num_server_changes_remaining_)); + value->SetBoolean("isShareUsable", is_share_usable_); value->Set("initialSyncEnded", - syncable::ModelTypeSetToValue(initial_sync_ended)); + syncable::ModelTypeSetToValue(initial_sync_ended_)); value->Set("downloadProgressMarkers", - DownloadProgressMarkersToValue(download_progress_markers)); - value->SetBoolean("hasMoreToSync", has_more_to_sync); - value->SetBoolean("isSilenced", is_silenced); + syncable::ModelTypePayloadMapToValue(download_progress_markers_)); + value->SetBoolean("hasMoreToSync", has_more_to_sync_); + value->SetBoolean("isSilenced", is_silenced_); // We don't care too much if we lose precision here, also. value->SetInteger("unsyncedCount", - static_cast<int>(unsynced_count)); + static_cast<int>(unsynced_count_)); value->SetInteger("numEncryptionConflicts", - num_encryption_conflicts); + num_encryption_conflicts_); value->SetInteger("numHierarchyConflicts", - num_hierarchy_conflicts); + num_hierarchy_conflicts_); value->SetInteger("numSimpleConflicts", - num_simple_conflicts); + num_simple_conflicts_); value->SetInteger("numServerConflicts", - num_server_conflicts); - value->SetBoolean("didCommitItems", did_commit_items); - value->SetInteger("numEntries", num_entries); - value->Set("source", source.ToValue()); - value->SetBoolean("notificationsEnabled", notifications_enabled); + num_server_conflicts_); + value->SetBoolean("didCommitItems", did_commit_items_); + value->SetInteger("numEntries", num_entries_); + value->Set("source", source_.ToValue()); + value->SetBoolean("notificationsEnabled", notifications_enabled_); return value; } @@ -188,6 +180,83 @@ std::string SyncSessionSnapshot::ToString() const { return json; } +SyncerStatus SyncSessionSnapshot::syncer_status() const { + return syncer_status_; +} + +ErrorCounters SyncSessionSnapshot::errors() const { + return errors_; +} + +int64 SyncSessionSnapshot::num_server_changes_remaining() const { + return num_server_changes_remaining_; +} + +bool SyncSessionSnapshot::is_share_usable() const { + return is_share_usable_; +} + +syncable::ModelTypeSet SyncSessionSnapshot::initial_sync_ended() const { + return initial_sync_ended_; +} + +syncable::ModelTypePayloadMap + SyncSessionSnapshot::download_progress_markers() const { + return download_progress_markers_; +} + +bool SyncSessionSnapshot::has_more_to_sync() const { + return has_more_to_sync_; +} + +bool SyncSessionSnapshot::is_silenced() const { + return is_silenced_; +} + +int64 SyncSessionSnapshot::unsynced_count() const { + return unsynced_count_; +} + +int SyncSessionSnapshot::num_encryption_conflicts() const { + return num_encryption_conflicts_; +} + +int SyncSessionSnapshot::num_hierarchy_conflicts() const { + return num_hierarchy_conflicts_; +} + +int SyncSessionSnapshot::num_simple_conflicts() const { + return num_simple_conflicts_; +} + +int SyncSessionSnapshot::num_server_conflicts() const { + return num_server_conflicts_; +} + +bool SyncSessionSnapshot::did_commit_items() const { + return did_commit_items_; +} + +SyncSourceInfo SyncSessionSnapshot::source() const { + return source_; +} + +bool SyncSessionSnapshot::notifications_enabled() const { + return notifications_enabled_; +} + +size_t SyncSessionSnapshot::num_entries() const { + return num_entries_; +} + +base::Time SyncSessionSnapshot::sync_start_time() const { + return sync_start_time_; +} + +bool SyncSessionSnapshot::retry_scheduled() const { + return retry_scheduled_; +} + ConflictProgress::ConflictProgress(bool* dirty_flag) : num_server_conflicting_items(0), num_hierarchy_conflicting_items(0), num_encryption_conflicting_items(0), dirty_(dirty_flag) { |