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

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: Convert SyncShareRecords to typedef Created 7 years, 4 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, 37 const std::vector<int>& num_entries_by_type,
38 const std::vector<int>& num_to_delete_entries_by_type) 38 const std::vector<int>& num_to_delete_entries_by_type,
39 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source)
39 : model_neutral_state_(model_neutral_state), 40 : model_neutral_state_(model_neutral_state),
40 download_progress_markers_(download_progress_markers), 41 download_progress_markers_(download_progress_markers),
41 is_silenced_(is_silenced), 42 is_silenced_(is_silenced),
42 num_encryption_conflicts_(num_encryption_conflicts), 43 num_encryption_conflicts_(num_encryption_conflicts),
43 num_hierarchy_conflicts_(num_hierarchy_conflicts), 44 num_hierarchy_conflicts_(num_hierarchy_conflicts),
44 num_server_conflicts_(num_server_conflicts), 45 num_server_conflicts_(num_server_conflicts),
45 source_(source),
46 notifications_enabled_(notifications_enabled), 46 notifications_enabled_(notifications_enabled),
47 num_entries_(num_entries), 47 num_entries_(num_entries),
48 sync_start_time_(sync_start_time), 48 sync_start_time_(sync_start_time),
49 num_entries_by_type_(num_entries_by_type), 49 num_entries_by_type_(num_entries_by_type),
50 num_to_delete_entries_by_type_(num_to_delete_entries_by_type), 50 num_to_delete_entries_by_type_(num_to_delete_entries_by_type),
51 legacy_updates_source_(legacy_updates_source),
51 is_initialized_(true) { 52 is_initialized_(true) {
52 } 53 }
53 54
54 SyncSessionSnapshot::~SyncSessionSnapshot() {} 55 SyncSessionSnapshot::~SyncSessionSnapshot() {}
55 56
56 base::DictionaryValue* SyncSessionSnapshot::ToValue() const { 57 base::DictionaryValue* SyncSessionSnapshot::ToValue() const {
57 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 58 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
58 value->SetInteger("numSuccessfulCommits", 59 value->SetInteger("numSuccessfulCommits",
59 model_neutral_state_.num_successful_commits); 60 model_neutral_state_.num_successful_commits);
60 value->SetInteger("numSuccessfulBookmarkCommits", 61 value->SetInteger("numSuccessfulBookmarkCommits",
(...skipping 15 matching lines...) Expand all
76 ProgressMarkerMapToValue(download_progress_markers_).release()); 77 ProgressMarkerMapToValue(download_progress_markers_).release());
77 value->SetBoolean("isSilenced", is_silenced_); 78 value->SetBoolean("isSilenced", is_silenced_);
78 // We don't care too much if we lose precision here, also. 79 // We don't care too much if we lose precision here, also.
79 value->SetInteger("numEncryptionConflicts", 80 value->SetInteger("numEncryptionConflicts",
80 num_encryption_conflicts_); 81 num_encryption_conflicts_);
81 value->SetInteger("numHierarchyConflicts", 82 value->SetInteger("numHierarchyConflicts",
82 num_hierarchy_conflicts_); 83 num_hierarchy_conflicts_);
83 value->SetInteger("numServerConflicts", 84 value->SetInteger("numServerConflicts",
84 num_server_conflicts_); 85 num_server_conflicts_);
85 value->SetInteger("numEntries", num_entries_); 86 value->SetInteger("numEntries", num_entries_);
86 value->Set("source", source_.ToValue()); 87 value->SetString("legacySource",
88 GetUpdatesSourceString(legacy_updates_source_));
87 value->SetBoolean("notificationsEnabled", notifications_enabled_); 89 value->SetBoolean("notificationsEnabled", notifications_enabled_);
88 90
89 scoped_ptr<base::DictionaryValue> counter_entries( 91 scoped_ptr<base::DictionaryValue> counter_entries(
90 new base::DictionaryValue()); 92 new base::DictionaryValue());
91 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; i++) { 93 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; i++) {
92 scoped_ptr<base::DictionaryValue> type_entries(new base::DictionaryValue()); 94 scoped_ptr<base::DictionaryValue> type_entries(new base::DictionaryValue());
93 type_entries->SetInteger("numEntries", num_entries_by_type_[i]); 95 type_entries->SetInteger("numEntries", num_entries_by_type_[i]);
94 type_entries->SetInteger("numToDeleteEntries", 96 type_entries->SetInteger("numToDeleteEntries",
95 num_to_delete_entries_by_type_[i]); 97 num_to_delete_entries_by_type_[i]);
96 98
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 130 }
129 131
130 int SyncSessionSnapshot::num_hierarchy_conflicts() const { 132 int SyncSessionSnapshot::num_hierarchy_conflicts() const {
131 return num_hierarchy_conflicts_; 133 return num_hierarchy_conflicts_;
132 } 134 }
133 135
134 int SyncSessionSnapshot::num_server_conflicts() const { 136 int SyncSessionSnapshot::num_server_conflicts() const {
135 return num_server_conflicts_; 137 return num_server_conflicts_;
136 } 138 }
137 139
138 SyncSourceInfo SyncSessionSnapshot::source() const {
139 return source_;
140 }
141
142 bool SyncSessionSnapshot::notifications_enabled() const { 140 bool SyncSessionSnapshot::notifications_enabled() const {
143 return notifications_enabled_; 141 return notifications_enabled_;
144 } 142 }
145 143
146 size_t SyncSessionSnapshot::num_entries() const { 144 size_t SyncSessionSnapshot::num_entries() const {
147 return num_entries_; 145 return num_entries_;
148 } 146 }
149 147
150 base::Time SyncSessionSnapshot::sync_start_time() const { 148 base::Time SyncSessionSnapshot::sync_start_time() const {
151 return sync_start_time_; 149 return sync_start_time_;
152 } 150 }
153 151
154 bool SyncSessionSnapshot::is_initialized() const { 152 bool SyncSessionSnapshot::is_initialized() const {
155 return is_initialized_; 153 return is_initialized_;
156 } 154 }
157 155
158 const std::vector<int>& SyncSessionSnapshot::num_entries_by_type() const { 156 const std::vector<int>& SyncSessionSnapshot::num_entries_by_type() const {
159 return num_entries_by_type_; 157 return num_entries_by_type_;
160 } 158 }
161 159
162 const std::vector<int>& 160 const std::vector<int>&
163 SyncSessionSnapshot::num_to_delete_entries_by_type() const { 161 SyncSessionSnapshot::num_to_delete_entries_by_type() const {
164 return num_to_delete_entries_by_type_; 162 return num_to_delete_entries_by_type_;
165 } 163 }
166 164
165 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource
166 SyncSessionSnapshot::legacy_updates_source() const {
167 return legacy_updates_source_;
168 }
169
167 } // namespace sessions 170 } // namespace sessions
168 } // namespace syncer 171 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698