Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: sync/internal_api/public/sessions/sync_session_snapshot.cc

Issue 19982002: sync: Remove SyncSourceInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "sync/protocol/proto_enum_conversions.h"
10 11
11 namespace syncer { 12 namespace syncer {
12 namespace sessions { 13 namespace sessions {
13 14
14 SyncSessionSnapshot::SyncSessionSnapshot() 15 SyncSessionSnapshot::SyncSessionSnapshot()
15 : is_silenced_(false), 16 : is_silenced_(false),
16 num_encryption_conflicts_(0), 17 num_encryption_conflicts_(0),
17 num_hierarchy_conflicts_(0), 18 num_hierarchy_conflicts_(0),
18 num_server_conflicts_(0), 19 num_server_conflicts_(0),
19 notifications_enabled_(false), 20 notifications_enabled_(false),
20 num_entries_(0), 21 num_entries_(0),
21 num_entries_by_type_(MODEL_TYPE_COUNT, 0), 22 num_entries_by_type_(MODEL_TYPE_COUNT, 0),
22 num_to_delete_entries_by_type_(MODEL_TYPE_COUNT, 0), 23 num_to_delete_entries_by_type_(MODEL_TYPE_COUNT, 0),
23 is_initialized_(false) { 24 is_initialized_(false) {
24 } 25 }
25 26
26 SyncSessionSnapshot::SyncSessionSnapshot( 27 SyncSessionSnapshot::SyncSessionSnapshot(
27 const ModelNeutralState& model_neutral_state, 28 const ModelNeutralState& model_neutral_state,
28 const ProgressMarkerMap& download_progress_markers, 29 const ProgressMarkerMap& download_progress_markers,
29 bool is_silenced, 30 bool is_silenced,
30 int num_encryption_conflicts, 31 int num_encryption_conflicts,
31 int num_hierarchy_conflicts, 32 int num_hierarchy_conflicts,
32 int num_server_conflicts, 33 int num_server_conflicts,
33 const SyncSourceInfo& source,
34 bool notifications_enabled, 34 bool notifications_enabled,
35 size_t num_entries, 35 size_t num_entries,
36 base::Time sync_start_time, 36 base::Time sync_start_time,
37 const std::vector<int>& num_entries_by_type,
38 const std::vector<int>& num_to_delete_entries_by_type,
39 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source)
40 : model_neutral_state_(model_neutral_state),
41 download_progress_markers_(download_progress_markers),
42 is_silenced_(is_silenced),
43 num_encryption_conflicts_(num_encryption_conflicts),
44 num_hierarchy_conflicts_(num_hierarchy_conflicts),
45 num_server_conflicts_(num_server_conflicts),
46 notifications_enabled_(notifications_enabled),
47 num_entries_(num_entries),
48 sync_start_time_(sync_start_time),
49 num_entries_by_type_(num_entries_by_type),
50 num_to_delete_entries_by_type_(num_to_delete_entries_by_type),
51 legacy_updates_source_(legacy_updates_source),
52 is_initialized_(true) {
53 }
54
55 SyncSessionSnapshot::SyncSessionSnapshot(
56 const ModelNeutralState& model_neutral_state,
57 const ProgressMarkerMap& download_progress_markers,
58 bool is_silenced,
59 int num_encryption_conflicts,
60 int num_hierarchy_conflicts,
61 int num_server_conflicts,
62 bool notifications_enabled,
63 size_t num_entries,
64 base::Time sync_start_time,
37 const std::vector<int>& num_entries_by_type, 65 const std::vector<int>& num_entries_by_type,
38 const std::vector<int>& num_to_delete_entries_by_type) 66 const std::vector<int>& num_to_delete_entries_by_type)
39 : model_neutral_state_(model_neutral_state), 67 : model_neutral_state_(model_neutral_state),
40 download_progress_markers_(download_progress_markers), 68 download_progress_markers_(download_progress_markers),
41 is_silenced_(is_silenced), 69 is_silenced_(is_silenced),
42 num_encryption_conflicts_(num_encryption_conflicts), 70 num_encryption_conflicts_(num_encryption_conflicts),
43 num_hierarchy_conflicts_(num_hierarchy_conflicts), 71 num_hierarchy_conflicts_(num_hierarchy_conflicts),
44 num_server_conflicts_(num_server_conflicts), 72 num_server_conflicts_(num_server_conflicts),
45 source_(source),
46 notifications_enabled_(notifications_enabled), 73 notifications_enabled_(notifications_enabled),
47 num_entries_(num_entries), 74 num_entries_(num_entries),
48 sync_start_time_(sync_start_time), 75 sync_start_time_(sync_start_time),
49 num_entries_by_type_(num_entries_by_type), 76 num_entries_by_type_(num_entries_by_type),
50 num_to_delete_entries_by_type_(num_to_delete_entries_by_type), 77 num_to_delete_entries_by_type_(num_to_delete_entries_by_type),
78 legacy_updates_source_(sync_pb::GetUpdatesCallerInfo::UNKNOWN),
51 is_initialized_(true) { 79 is_initialized_(true) {
52 } 80 }
53 81
54 SyncSessionSnapshot::~SyncSessionSnapshot() {} 82 SyncSessionSnapshot::~SyncSessionSnapshot() {}
55 83
56 base::DictionaryValue* SyncSessionSnapshot::ToValue() const { 84 base::DictionaryValue* SyncSessionSnapshot::ToValue() const {
57 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 85 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
58 value->SetInteger("numSuccessfulCommits", 86 value->SetInteger("numSuccessfulCommits",
59 model_neutral_state_.num_successful_commits); 87 model_neutral_state_.num_successful_commits);
60 value->SetInteger("numSuccessfulBookmarkCommits", 88 value->SetInteger("numSuccessfulBookmarkCommits",
(...skipping 15 matching lines...) Expand all
76 ProgressMarkerMapToValue(download_progress_markers_).release()); 104 ProgressMarkerMapToValue(download_progress_markers_).release());
77 value->SetBoolean("isSilenced", is_silenced_); 105 value->SetBoolean("isSilenced", is_silenced_);
78 // We don't care too much if we lose precision here, also. 106 // We don't care too much if we lose precision here, also.
79 value->SetInteger("numEncryptionConflicts", 107 value->SetInteger("numEncryptionConflicts",
80 num_encryption_conflicts_); 108 num_encryption_conflicts_);
81 value->SetInteger("numHierarchyConflicts", 109 value->SetInteger("numHierarchyConflicts",
82 num_hierarchy_conflicts_); 110 num_hierarchy_conflicts_);
83 value->SetInteger("numServerConflicts", 111 value->SetInteger("numServerConflicts",
84 num_server_conflicts_); 112 num_server_conflicts_);
85 value->SetInteger("numEntries", num_entries_); 113 value->SetInteger("numEntries", num_entries_);
86 value->Set("source", source_.ToValue()); 114 value->SetString("legacySource",
115 GetUpdatesSourceString(legacy_updates_source_));
87 value->SetBoolean("notificationsEnabled", notifications_enabled_); 116 value->SetBoolean("notificationsEnabled", notifications_enabled_);
88 117
89 scoped_ptr<base::DictionaryValue> counter_entries( 118 scoped_ptr<base::DictionaryValue> counter_entries(
90 new base::DictionaryValue()); 119 new base::DictionaryValue());
91 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; i++) { 120 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; i++) {
92 scoped_ptr<base::DictionaryValue> type_entries(new base::DictionaryValue()); 121 scoped_ptr<base::DictionaryValue> type_entries(new base::DictionaryValue());
93 type_entries->SetInteger("numEntries", num_entries_by_type_[i]); 122 type_entries->SetInteger("numEntries", num_entries_by_type_[i]);
94 type_entries->SetInteger("numToDeleteEntries", 123 type_entries->SetInteger("numToDeleteEntries",
95 num_to_delete_entries_by_type_[i]); 124 num_to_delete_entries_by_type_[i]);
96 125
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 157 }
129 158
130 int SyncSessionSnapshot::num_hierarchy_conflicts() const { 159 int SyncSessionSnapshot::num_hierarchy_conflicts() const {
131 return num_hierarchy_conflicts_; 160 return num_hierarchy_conflicts_;
132 } 161 }
133 162
134 int SyncSessionSnapshot::num_server_conflicts() const { 163 int SyncSessionSnapshot::num_server_conflicts() const {
135 return num_server_conflicts_; 164 return num_server_conflicts_;
136 } 165 }
137 166
138 SyncSourceInfo SyncSessionSnapshot::source() const {
139 return source_;
140 }
141
142 bool SyncSessionSnapshot::notifications_enabled() const { 167 bool SyncSessionSnapshot::notifications_enabled() const {
143 return notifications_enabled_; 168 return notifications_enabled_;
144 } 169 }
145 170
146 size_t SyncSessionSnapshot::num_entries() const { 171 size_t SyncSessionSnapshot::num_entries() const {
147 return num_entries_; 172 return num_entries_;
148 } 173 }
149 174
150 base::Time SyncSessionSnapshot::sync_start_time() const { 175 base::Time SyncSessionSnapshot::sync_start_time() const {
151 return sync_start_time_; 176 return sync_start_time_;
152 } 177 }
153 178
154 bool SyncSessionSnapshot::is_initialized() const { 179 bool SyncSessionSnapshot::is_initialized() const {
155 return is_initialized_; 180 return is_initialized_;
156 } 181 }
157 182
158 const std::vector<int>& SyncSessionSnapshot::num_entries_by_type() const { 183 const std::vector<int>& SyncSessionSnapshot::num_entries_by_type() const {
159 return num_entries_by_type_; 184 return num_entries_by_type_;
160 } 185 }
161 186
162 const std::vector<int>& 187 const std::vector<int>&
163 SyncSessionSnapshot::num_to_delete_entries_by_type() const { 188 SyncSessionSnapshot::num_to_delete_entries_by_type() const {
164 return num_to_delete_entries_by_type_; 189 return num_to_delete_entries_by_type_;
165 } 190 }
166 191
192 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource
193 SyncSessionSnapshot::legacy_updates_source() const {
194 return legacy_updates_source_;
195 }
196
167 } // namespace sessions 197 } // namespace sessions
168 } // namespace syncer 198 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698