| 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/internal_api/public/sessions/sync_session_snapshot.h" | 5 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 SyncSessionSnapshot::SyncSessionSnapshot( | 27 SyncSessionSnapshot::SyncSessionSnapshot( |
| 28 const ModelNeutralState& model_neutral_state, | 28 const ModelNeutralState& model_neutral_state, |
| 29 bool is_share_usable, | 29 bool is_share_usable, |
| 30 ModelTypeSet initial_sync_ended, | 30 ModelTypeSet initial_sync_ended, |
| 31 const ProgressMarkerMap& download_progress_markers, | 31 const ProgressMarkerMap& download_progress_markers, |
| 32 bool is_silenced, | 32 bool is_silenced, |
| 33 int num_encryption_conflicts, | 33 int num_encryption_conflicts, |
| 34 int num_hierarchy_conflicts, | 34 int num_hierarchy_conflicts, |
| 35 int num_server_conflicts, | 35 int num_server_conflicts, |
| 36 const SyncSourceInfo& source, | 36 const SyncSourceInfo& source, |
| 37 const std::vector<SyncSourceInfo>& debug_info_sources_list, |
| 37 bool notifications_enabled, | 38 bool notifications_enabled, |
| 38 size_t num_entries, | 39 size_t num_entries, |
| 39 base::Time sync_start_time, | 40 base::Time sync_start_time, |
| 40 const std::vector<int>& num_entries_by_type, | 41 const std::vector<int>& num_entries_by_type, |
| 41 const std::vector<int>& num_to_delete_entries_by_type) | 42 const std::vector<int>& num_to_delete_entries_by_type) |
| 42 : model_neutral_state_(model_neutral_state), | 43 : model_neutral_state_(model_neutral_state), |
| 43 is_share_usable_(is_share_usable), | 44 is_share_usable_(is_share_usable), |
| 44 initial_sync_ended_(initial_sync_ended), | 45 initial_sync_ended_(initial_sync_ended), |
| 45 download_progress_markers_(download_progress_markers), | 46 download_progress_markers_(download_progress_markers), |
| 46 is_silenced_(is_silenced), | 47 is_silenced_(is_silenced), |
| 47 num_encryption_conflicts_(num_encryption_conflicts), | 48 num_encryption_conflicts_(num_encryption_conflicts), |
| 48 num_hierarchy_conflicts_(num_hierarchy_conflicts), | 49 num_hierarchy_conflicts_(num_hierarchy_conflicts), |
| 49 num_server_conflicts_(num_server_conflicts), | 50 num_server_conflicts_(num_server_conflicts), |
| 50 source_(source), | 51 source_(source), |
| 52 debug_info_sources_list_(debug_info_sources_list), |
| 51 notifications_enabled_(notifications_enabled), | 53 notifications_enabled_(notifications_enabled), |
| 52 num_entries_(num_entries), | 54 num_entries_(num_entries), |
| 53 sync_start_time_(sync_start_time), | 55 sync_start_time_(sync_start_time), |
| 54 num_entries_by_type_(num_entries_by_type), | 56 num_entries_by_type_(num_entries_by_type), |
| 55 num_to_delete_entries_by_type_(num_to_delete_entries_by_type), | 57 num_to_delete_entries_by_type_(num_to_delete_entries_by_type), |
| 56 is_initialized_(true) { | 58 is_initialized_(true) { |
| 57 } | 59 } |
| 58 | 60 |
| 59 SyncSessionSnapshot::~SyncSessionSnapshot() {} | 61 SyncSessionSnapshot::~SyncSessionSnapshot() {} |
| 60 | 62 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 85 value->SetBoolean("isSilenced", is_silenced_); | 87 value->SetBoolean("isSilenced", is_silenced_); |
| 86 // We don't care too much if we lose precision here, also. | 88 // We don't care too much if we lose precision here, also. |
| 87 value->SetInteger("numEncryptionConflicts", | 89 value->SetInteger("numEncryptionConflicts", |
| 88 num_encryption_conflicts_); | 90 num_encryption_conflicts_); |
| 89 value->SetInteger("numHierarchyConflicts", | 91 value->SetInteger("numHierarchyConflicts", |
| 90 num_hierarchy_conflicts_); | 92 num_hierarchy_conflicts_); |
| 91 value->SetInteger("numServerConflicts", | 93 value->SetInteger("numServerConflicts", |
| 92 num_server_conflicts_); | 94 num_server_conflicts_); |
| 93 value->SetInteger("numEntries", num_entries_); | 95 value->SetInteger("numEntries", num_entries_); |
| 94 value->Set("source", source_.ToValue()); | 96 value->Set("source", source_.ToValue()); |
| 97 scoped_ptr<ListValue> sources_list(new ListValue()); |
| 98 for (std::vector<SyncSourceInfo>::const_iterator i = |
| 99 debug_info_sources_list_.begin(); |
| 100 i != debug_info_sources_list_.end(); ++i) { |
| 101 sources_list->Append(i->ToValue()); |
| 102 } |
| 103 value->Set("sourcesList", sources_list.release()); |
| 95 value->SetBoolean("notificationsEnabled", notifications_enabled_); | 104 value->SetBoolean("notificationsEnabled", notifications_enabled_); |
| 96 | 105 |
| 97 | |
| 98 scoped_ptr<DictionaryValue> counter_entries(new DictionaryValue()); | 106 scoped_ptr<DictionaryValue> counter_entries(new DictionaryValue()); |
| 99 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; i++) { | 107 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; i++) { |
| 100 scoped_ptr<DictionaryValue> type_entries(new DictionaryValue()); | 108 scoped_ptr<DictionaryValue> type_entries(new DictionaryValue()); |
| 101 type_entries->SetInteger("numEntries", num_entries_by_type_[i]); | 109 type_entries->SetInteger("numEntries", num_entries_by_type_[i]); |
| 102 type_entries->SetInteger("numToDeleteEntries", | 110 type_entries->SetInteger("numToDeleteEntries", |
| 103 num_to_delete_entries_by_type_[i]); | 111 num_to_delete_entries_by_type_[i]); |
| 104 | 112 |
| 105 const std::string model_type = ModelTypeToString(static_cast<ModelType>(i)); | 113 const std::string model_type = ModelTypeToString(static_cast<ModelType>(i)); |
| 106 counter_entries->Set(model_type, type_entries.release()); | 114 counter_entries->Set(model_type, type_entries.release()); |
| 107 } | 115 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 156 } |
| 149 | 157 |
| 150 int SyncSessionSnapshot::num_server_conflicts() const { | 158 int SyncSessionSnapshot::num_server_conflicts() const { |
| 151 return num_server_conflicts_; | 159 return num_server_conflicts_; |
| 152 } | 160 } |
| 153 | 161 |
| 154 SyncSourceInfo SyncSessionSnapshot::source() const { | 162 SyncSourceInfo SyncSessionSnapshot::source() const { |
| 155 return source_; | 163 return source_; |
| 156 } | 164 } |
| 157 | 165 |
| 166 const std::vector<SyncSourceInfo>& |
| 167 SyncSessionSnapshot::debug_info_sources_list() const { |
| 168 return debug_info_sources_list_; |
| 169 } |
| 170 |
| 158 bool SyncSessionSnapshot::notifications_enabled() const { | 171 bool SyncSessionSnapshot::notifications_enabled() const { |
| 159 return notifications_enabled_; | 172 return notifications_enabled_; |
| 160 } | 173 } |
| 161 | 174 |
| 162 size_t SyncSessionSnapshot::num_entries() const { | 175 size_t SyncSessionSnapshot::num_entries() const { |
| 163 return num_entries_; | 176 return num_entries_; |
| 164 } | 177 } |
| 165 | 178 |
| 166 base::Time SyncSessionSnapshot::sync_start_time() const { | 179 base::Time SyncSessionSnapshot::sync_start_time() const { |
| 167 return sync_start_time_; | 180 return sync_start_time_; |
| 168 } | 181 } |
| 169 | 182 |
| 170 bool SyncSessionSnapshot::is_initialized() const { | 183 bool SyncSessionSnapshot::is_initialized() const { |
| 171 return is_initialized_; | 184 return is_initialized_; |
| 172 } | 185 } |
| 173 | 186 |
| 174 const std::vector<int>& SyncSessionSnapshot::num_entries_by_type() const { | 187 const std::vector<int>& SyncSessionSnapshot::num_entries_by_type() const { |
| 175 return num_entries_by_type_; | 188 return num_entries_by_type_; |
| 176 } | 189 } |
| 177 | 190 |
| 178 const std::vector<int>& | 191 const std::vector<int>& |
| 179 SyncSessionSnapshot::num_to_delete_entries_by_type() const { | 192 SyncSessionSnapshot::num_to_delete_entries_by_type() const { |
| 180 return num_to_delete_entries_by_type_; | 193 return num_to_delete_entries_by_type_; |
| 181 } | 194 } |
| 182 | 195 |
| 183 } // namespace sessions | 196 } // namespace sessions |
| 184 } // namespace syncer | 197 } // namespace syncer |
| OLD | NEW |