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 |
11 namespace syncer { | 11 namespace syncer { |
12 namespace sessions { | 12 namespace sessions { |
13 | 13 |
14 SyncSessionSnapshot::SyncSessionSnapshot() | 14 SyncSessionSnapshot::SyncSessionSnapshot() |
15 : is_share_usable_(false), | 15 : is_share_usable_(false), |
16 has_more_to_sync_(false), | |
17 is_silenced_(false), | 16 is_silenced_(false), |
18 num_encryption_conflicts_(0), | 17 num_encryption_conflicts_(0), |
19 num_hierarchy_conflicts_(0), | 18 num_hierarchy_conflicts_(0), |
20 num_simple_conflicts_(0), | |
21 num_server_conflicts_(0), | 19 num_server_conflicts_(0), |
22 notifications_enabled_(false), | 20 notifications_enabled_(false), |
23 num_entries_(0), | 21 num_entries_(0), |
24 is_initialized_(false) { | 22 is_initialized_(false) { |
25 } | 23 } |
26 | 24 |
27 SyncSessionSnapshot::SyncSessionSnapshot( | 25 SyncSessionSnapshot::SyncSessionSnapshot( |
28 const ModelNeutralState& model_neutral_state, | 26 const ModelNeutralState& model_neutral_state, |
29 bool is_share_usable, | 27 bool is_share_usable, |
30 ModelTypeSet initial_sync_ended, | 28 ModelTypeSet initial_sync_ended, |
31 const ProgressMarkerMap& download_progress_markers, | 29 const ProgressMarkerMap& download_progress_markers, |
32 bool more_to_sync, | |
33 bool is_silenced, | 30 bool is_silenced, |
34 int num_encryption_conflicts, | 31 int num_encryption_conflicts, |
35 int num_hierarchy_conflicts, | 32 int num_hierarchy_conflicts, |
36 int num_simple_conflicts, | |
37 int num_server_conflicts, | 33 int num_server_conflicts, |
38 const SyncSourceInfo& source, | 34 const SyncSourceInfo& source, |
39 bool notifications_enabled, | 35 bool notifications_enabled, |
40 size_t num_entries, | 36 size_t num_entries, |
41 base::Time sync_start_time) | 37 base::Time sync_start_time) |
42 : model_neutral_state_(model_neutral_state), | 38 : model_neutral_state_(model_neutral_state), |
43 is_share_usable_(is_share_usable), | 39 is_share_usable_(is_share_usable), |
44 initial_sync_ended_(initial_sync_ended), | 40 initial_sync_ended_(initial_sync_ended), |
45 download_progress_markers_(download_progress_markers), | 41 download_progress_markers_(download_progress_markers), |
46 has_more_to_sync_(more_to_sync), | |
47 is_silenced_(is_silenced), | 42 is_silenced_(is_silenced), |
48 num_encryption_conflicts_(num_encryption_conflicts), | 43 num_encryption_conflicts_(num_encryption_conflicts), |
49 num_hierarchy_conflicts_(num_hierarchy_conflicts), | 44 num_hierarchy_conflicts_(num_hierarchy_conflicts), |
50 num_simple_conflicts_(num_simple_conflicts), | |
51 num_server_conflicts_(num_server_conflicts), | 45 num_server_conflicts_(num_server_conflicts), |
52 source_(source), | 46 source_(source), |
53 notifications_enabled_(notifications_enabled), | 47 notifications_enabled_(notifications_enabled), |
54 num_entries_(num_entries), | 48 num_entries_(num_entries), |
55 sync_start_time_(sync_start_time), | 49 sync_start_time_(sync_start_time), |
56 is_initialized_(true) { | 50 is_initialized_(true) { |
57 } | 51 } |
58 | 52 |
59 SyncSessionSnapshot::~SyncSessionSnapshot() {} | 53 SyncSessionSnapshot::~SyncSessionSnapshot() {} |
60 | 54 |
(...skipping 14 matching lines...) Expand all Loading... |
75 value->SetInteger("numServerOverwrites", | 69 value->SetInteger("numServerOverwrites", |
76 model_neutral_state_.num_server_overwrites); | 70 model_neutral_state_.num_server_overwrites); |
77 value->SetInteger( | 71 value->SetInteger( |
78 "numServerChangesRemaining", | 72 "numServerChangesRemaining", |
79 static_cast<int>(model_neutral_state_.num_server_changes_remaining)); | 73 static_cast<int>(model_neutral_state_.num_server_changes_remaining)); |
80 value->SetBoolean("isShareUsable", is_share_usable_); | 74 value->SetBoolean("isShareUsable", is_share_usable_); |
81 value->Set("initialSyncEnded", | 75 value->Set("initialSyncEnded", |
82 ModelTypeSetToValue(initial_sync_ended_)); | 76 ModelTypeSetToValue(initial_sync_ended_)); |
83 value->Set("downloadProgressMarkers", | 77 value->Set("downloadProgressMarkers", |
84 ProgressMarkerMapToValue(download_progress_markers_).release()); | 78 ProgressMarkerMapToValue(download_progress_markers_).release()); |
85 value->SetBoolean("hasMoreToSync", has_more_to_sync_); | |
86 value->SetBoolean("isSilenced", is_silenced_); | 79 value->SetBoolean("isSilenced", is_silenced_); |
87 // We don't care too much if we lose precision here, also. | 80 // We don't care too much if we lose precision here, also. |
88 value->SetInteger("numEncryptionConflicts", | 81 value->SetInteger("numEncryptionConflicts", |
89 num_encryption_conflicts_); | 82 num_encryption_conflicts_); |
90 value->SetInteger("numHierarchyConflicts", | 83 value->SetInteger("numHierarchyConflicts", |
91 num_hierarchy_conflicts_); | 84 num_hierarchy_conflicts_); |
92 value->SetInteger("numSimpleConflicts", | |
93 num_simple_conflicts_); | |
94 value->SetInteger("numServerConflicts", | 85 value->SetInteger("numServerConflicts", |
95 num_server_conflicts_); | 86 num_server_conflicts_); |
96 value->SetInteger("numEntries", num_entries_); | 87 value->SetInteger("numEntries", num_entries_); |
97 value->Set("source", source_.ToValue()); | 88 value->Set("source", source_.ToValue()); |
98 value->SetBoolean("notificationsEnabled", notifications_enabled_); | 89 value->SetBoolean("notificationsEnabled", notifications_enabled_); |
99 return value; | 90 return value; |
100 } | 91 } |
101 | 92 |
102 std::string SyncSessionSnapshot::ToString() const { | 93 std::string SyncSessionSnapshot::ToString() const { |
103 scoped_ptr<DictionaryValue> value(ToValue()); | 94 scoped_ptr<DictionaryValue> value(ToValue()); |
(...skipping 14 matching lines...) Expand all Loading... |
118 | 109 |
119 ModelTypeSet SyncSessionSnapshot::initial_sync_ended() const { | 110 ModelTypeSet SyncSessionSnapshot::initial_sync_ended() const { |
120 return initial_sync_ended_; | 111 return initial_sync_ended_; |
121 } | 112 } |
122 | 113 |
123 const ProgressMarkerMap& | 114 const ProgressMarkerMap& |
124 SyncSessionSnapshot::download_progress_markers() const { | 115 SyncSessionSnapshot::download_progress_markers() const { |
125 return download_progress_markers_; | 116 return download_progress_markers_; |
126 } | 117 } |
127 | 118 |
128 bool SyncSessionSnapshot::has_more_to_sync() const { | |
129 return has_more_to_sync_; | |
130 } | |
131 | |
132 bool SyncSessionSnapshot::is_silenced() const { | 119 bool SyncSessionSnapshot::is_silenced() const { |
133 return is_silenced_; | 120 return is_silenced_; |
134 } | 121 } |
135 | 122 |
136 int SyncSessionSnapshot::num_encryption_conflicts() const { | 123 int SyncSessionSnapshot::num_encryption_conflicts() const { |
137 return num_encryption_conflicts_; | 124 return num_encryption_conflicts_; |
138 } | 125 } |
139 | 126 |
140 int SyncSessionSnapshot::num_hierarchy_conflicts() const { | 127 int SyncSessionSnapshot::num_hierarchy_conflicts() const { |
141 return num_hierarchy_conflicts_; | 128 return num_hierarchy_conflicts_; |
142 } | 129 } |
143 | 130 |
144 int SyncSessionSnapshot::num_simple_conflicts() const { | |
145 return num_simple_conflicts_; | |
146 } | |
147 | |
148 int SyncSessionSnapshot::num_server_conflicts() const { | 131 int SyncSessionSnapshot::num_server_conflicts() const { |
149 return num_server_conflicts_; | 132 return num_server_conflicts_; |
150 } | 133 } |
151 | 134 |
152 SyncSourceInfo SyncSessionSnapshot::source() const { | 135 SyncSourceInfo SyncSessionSnapshot::source() const { |
153 return source_; | 136 return source_; |
154 } | 137 } |
155 | 138 |
156 bool SyncSessionSnapshot::notifications_enabled() const { | 139 bool SyncSessionSnapshot::notifications_enabled() const { |
157 return notifications_enabled_; | 140 return notifications_enabled_; |
158 } | 141 } |
159 | 142 |
160 size_t SyncSessionSnapshot::num_entries() const { | 143 size_t SyncSessionSnapshot::num_entries() const { |
161 return num_entries_; | 144 return num_entries_; |
162 } | 145 } |
163 | 146 |
164 base::Time SyncSessionSnapshot::sync_start_time() const { | 147 base::Time SyncSessionSnapshot::sync_start_time() const { |
165 return sync_start_time_; | 148 return sync_start_time_; |
166 } | 149 } |
167 | 150 |
168 bool SyncSessionSnapshot::is_initialized() const { | 151 bool SyncSessionSnapshot::is_initialized() const { |
169 return is_initialized_; | 152 return is_initialized_; |
170 } | 153 } |
171 | 154 |
172 } // namespace sessions | 155 } // namespace sessions |
173 } // namespace syncer | 156 } // namespace syncer |
OLD | NEW |