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_silenced_(false), |
16 is_silenced_(false), | |
17 num_encryption_conflicts_(0), | 16 num_encryption_conflicts_(0), |
18 num_hierarchy_conflicts_(0), | 17 num_hierarchy_conflicts_(0), |
19 num_server_conflicts_(0), | 18 num_server_conflicts_(0), |
20 notifications_enabled_(false), | 19 notifications_enabled_(false), |
21 num_entries_(0), | 20 num_entries_(0), |
22 num_entries_by_type_(MODEL_TYPE_COUNT, 0), | 21 num_entries_by_type_(MODEL_TYPE_COUNT, 0), |
23 num_to_delete_entries_by_type_(MODEL_TYPE_COUNT, 0), | 22 num_to_delete_entries_by_type_(MODEL_TYPE_COUNT, 0), |
24 is_initialized_(false) { | 23 is_initialized_(false) { |
25 } | 24 } |
26 | 25 |
27 SyncSessionSnapshot::SyncSessionSnapshot( | 26 SyncSessionSnapshot::SyncSessionSnapshot( |
28 const ModelNeutralState& model_neutral_state, | 27 const ModelNeutralState& model_neutral_state, |
29 bool is_share_usable, | |
30 ModelTypeSet initial_sync_ended, | |
31 const ProgressMarkerMap& download_progress_markers, | 28 const ProgressMarkerMap& download_progress_markers, |
32 bool is_silenced, | 29 bool is_silenced, |
33 int num_encryption_conflicts, | 30 int num_encryption_conflicts, |
34 int num_hierarchy_conflicts, | 31 int num_hierarchy_conflicts, |
35 int num_server_conflicts, | 32 int num_server_conflicts, |
36 const SyncSourceInfo& source, | 33 const SyncSourceInfo& source, |
37 const std::vector<SyncSourceInfo>& debug_info_sources_list, | 34 const std::vector<SyncSourceInfo>& debug_info_sources_list, |
38 bool notifications_enabled, | 35 bool notifications_enabled, |
39 size_t num_entries, | 36 size_t num_entries, |
40 base::Time sync_start_time, | 37 base::Time sync_start_time, |
41 const std::vector<int>& num_entries_by_type, | 38 const std::vector<int>& num_entries_by_type, |
42 const std::vector<int>& num_to_delete_entries_by_type) | 39 const std::vector<int>& num_to_delete_entries_by_type) |
43 : model_neutral_state_(model_neutral_state), | 40 : model_neutral_state_(model_neutral_state), |
44 is_share_usable_(is_share_usable), | |
45 initial_sync_ended_(initial_sync_ended), | |
46 download_progress_markers_(download_progress_markers), | 41 download_progress_markers_(download_progress_markers), |
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_server_conflicts_(num_server_conflicts), | 45 num_server_conflicts_(num_server_conflicts), |
51 source_(source), | 46 source_(source), |
52 debug_info_sources_list_(debug_info_sources_list), | 47 debug_info_sources_list_(debug_info_sources_list), |
53 notifications_enabled_(notifications_enabled), | 48 notifications_enabled_(notifications_enabled), |
54 num_entries_(num_entries), | 49 num_entries_(num_entries), |
55 sync_start_time_(sync_start_time), | 50 sync_start_time_(sync_start_time), |
(...skipping 16 matching lines...) Expand all Loading... |
72 model_neutral_state_.num_tombstone_updates_downloaded_total); | 67 model_neutral_state_.num_tombstone_updates_downloaded_total); |
73 value->SetInteger("numReflectedUpdatesDownloadedTotal", | 68 value->SetInteger("numReflectedUpdatesDownloadedTotal", |
74 model_neutral_state_.num_reflected_updates_downloaded_total); | 69 model_neutral_state_.num_reflected_updates_downloaded_total); |
75 value->SetInteger("numLocalOverwrites", | 70 value->SetInteger("numLocalOverwrites", |
76 model_neutral_state_.num_local_overwrites); | 71 model_neutral_state_.num_local_overwrites); |
77 value->SetInteger("numServerOverwrites", | 72 value->SetInteger("numServerOverwrites", |
78 model_neutral_state_.num_server_overwrites); | 73 model_neutral_state_.num_server_overwrites); |
79 value->SetInteger( | 74 value->SetInteger( |
80 "numServerChangesRemaining", | 75 "numServerChangesRemaining", |
81 static_cast<int>(model_neutral_state_.num_server_changes_remaining)); | 76 static_cast<int>(model_neutral_state_.num_server_changes_remaining)); |
82 value->SetBoolean("isShareUsable", is_share_usable_); | |
83 value->Set("initialSyncEnded", | |
84 ModelTypeSetToValue(initial_sync_ended_)); | |
85 value->Set("downloadProgressMarkers", | 77 value->Set("downloadProgressMarkers", |
86 ProgressMarkerMapToValue(download_progress_markers_).release()); | 78 ProgressMarkerMapToValue(download_progress_markers_).release()); |
87 value->SetBoolean("isSilenced", is_silenced_); | 79 value->SetBoolean("isSilenced", is_silenced_); |
88 // 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. |
89 value->SetInteger("numEncryptionConflicts", | 81 value->SetInteger("numEncryptionConflicts", |
90 num_encryption_conflicts_); | 82 num_encryption_conflicts_); |
91 value->SetInteger("numHierarchyConflicts", | 83 value->SetInteger("numHierarchyConflicts", |
92 num_hierarchy_conflicts_); | 84 num_hierarchy_conflicts_); |
93 value->SetInteger("numServerConflicts", | 85 value->SetInteger("numServerConflicts", |
94 num_server_conflicts_); | 86 num_server_conflicts_); |
(...skipping 28 matching lines...) Expand all Loading... |
123 base::JSONWriter::WriteWithOptions(value.get(), | 115 base::JSONWriter::WriteWithOptions(value.get(), |
124 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 116 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
125 &json); | 117 &json); |
126 return json; | 118 return json; |
127 } | 119 } |
128 | 120 |
129 int64 SyncSessionSnapshot::num_server_changes_remaining() const { | 121 int64 SyncSessionSnapshot::num_server_changes_remaining() const { |
130 return model_neutral_state().num_server_changes_remaining; | 122 return model_neutral_state().num_server_changes_remaining; |
131 } | 123 } |
132 | 124 |
133 bool SyncSessionSnapshot::is_share_usable() const { | |
134 return is_share_usable_; | |
135 } | |
136 | |
137 ModelTypeSet SyncSessionSnapshot::initial_sync_ended() const { | |
138 return initial_sync_ended_; | |
139 } | |
140 | |
141 const ProgressMarkerMap& | 125 const ProgressMarkerMap& |
142 SyncSessionSnapshot::download_progress_markers() const { | 126 SyncSessionSnapshot::download_progress_markers() const { |
143 return download_progress_markers_; | 127 return download_progress_markers_; |
144 } | 128 } |
145 | 129 |
146 bool SyncSessionSnapshot::is_silenced() const { | 130 bool SyncSessionSnapshot::is_silenced() const { |
147 return is_silenced_; | 131 return is_silenced_; |
148 } | 132 } |
149 | 133 |
150 int SyncSessionSnapshot::num_encryption_conflicts() const { | 134 int SyncSessionSnapshot::num_encryption_conflicts() const { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return num_entries_by_type_; | 172 return num_entries_by_type_; |
189 } | 173 } |
190 | 174 |
191 const std::vector<int>& | 175 const std::vector<int>& |
192 SyncSessionSnapshot::num_to_delete_entries_by_type() const { | 176 SyncSessionSnapshot::num_to_delete_entries_by_type() const { |
193 return num_to_delete_entries_by_type_; | 177 return num_to_delete_entries_by_type_; |
194 } | 178 } |
195 | 179 |
196 } // namespace sessions | 180 } // namespace sessions |
197 } // namespace syncer | 181 } // namespace syncer |
OLD | NEW |