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