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

Side by Side Diff: components/sync/engine/cycle/sync_cycle_snapshot.cc

Issue 2258873003: [Sync] Move sessions/ to engine/cycle/ and rename things to match. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 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
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 "components/sync/sessions/sync_session_snapshot.h" 5 #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "components/sync/protocol/proto_enum_conversions.h" 14 #include "components/sync/protocol/proto_enum_conversions.h"
15 15
16 namespace syncer { 16 namespace syncer {
17 namespace sessions {
18 17
19 SyncSessionSnapshot::SyncSessionSnapshot() 18 SyncCycleSnapshot::SyncCycleSnapshot()
20 : is_silenced_(false), 19 : is_silenced_(false),
21 num_encryption_conflicts_(0), 20 num_encryption_conflicts_(0),
22 num_hierarchy_conflicts_(0), 21 num_hierarchy_conflicts_(0),
23 num_server_conflicts_(0), 22 num_server_conflicts_(0),
24 notifications_enabled_(false), 23 notifications_enabled_(false),
25 num_entries_(0), 24 num_entries_(0),
26 num_entries_by_type_(MODEL_TYPE_COUNT, 0), 25 num_entries_by_type_(MODEL_TYPE_COUNT, 0),
27 num_to_delete_entries_by_type_(MODEL_TYPE_COUNT, 0), 26 num_to_delete_entries_by_type_(MODEL_TYPE_COUNT, 0),
28 is_initialized_(false) {} 27 is_initialized_(false) {}
29 28
30 SyncSessionSnapshot::SyncSessionSnapshot( 29 SyncCycleSnapshot::SyncCycleSnapshot(
31 const ModelNeutralState& model_neutral_state, 30 const ModelNeutralState& model_neutral_state,
32 const ProgressMarkerMap& download_progress_markers, 31 const ProgressMarkerMap& download_progress_markers,
33 bool is_silenced, 32 bool is_silenced,
34 int num_encryption_conflicts, 33 int num_encryption_conflicts,
35 int num_hierarchy_conflicts, 34 int num_hierarchy_conflicts,
36 int num_server_conflicts, 35 int num_server_conflicts,
37 bool notifications_enabled, 36 bool notifications_enabled,
38 size_t num_entries, 37 size_t num_entries,
39 base::Time sync_start_time, 38 base::Time sync_start_time,
40 base::Time poll_finish_time, 39 base::Time poll_finish_time,
41 const std::vector<int>& num_entries_by_type, 40 const std::vector<int>& num_entries_by_type,
42 const std::vector<int>& num_to_delete_entries_by_type, 41 const std::vector<int>& num_to_delete_entries_by_type,
43 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source) 42 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource legacy_updates_source)
44 : model_neutral_state_(model_neutral_state), 43 : model_neutral_state_(model_neutral_state),
45 download_progress_markers_(download_progress_markers), 44 download_progress_markers_(download_progress_markers),
46 is_silenced_(is_silenced), 45 is_silenced_(is_silenced),
47 num_encryption_conflicts_(num_encryption_conflicts), 46 num_encryption_conflicts_(num_encryption_conflicts),
48 num_hierarchy_conflicts_(num_hierarchy_conflicts), 47 num_hierarchy_conflicts_(num_hierarchy_conflicts),
49 num_server_conflicts_(num_server_conflicts), 48 num_server_conflicts_(num_server_conflicts),
50 notifications_enabled_(notifications_enabled), 49 notifications_enabled_(notifications_enabled),
51 num_entries_(num_entries), 50 num_entries_(num_entries),
52 sync_start_time_(sync_start_time), 51 sync_start_time_(sync_start_time),
53 poll_finish_time_(poll_finish_time), 52 poll_finish_time_(poll_finish_time),
54 num_entries_by_type_(num_entries_by_type), 53 num_entries_by_type_(num_entries_by_type),
55 num_to_delete_entries_by_type_(num_to_delete_entries_by_type), 54 num_to_delete_entries_by_type_(num_to_delete_entries_by_type),
56 legacy_updates_source_(legacy_updates_source), 55 legacy_updates_source_(legacy_updates_source),
57 is_initialized_(true) {} 56 is_initialized_(true) {}
58 57
59 SyncSessionSnapshot::SyncSessionSnapshot(const SyncSessionSnapshot& other) = 58 SyncCycleSnapshot::SyncCycleSnapshot(const SyncCycleSnapshot& other) = default;
60 default;
61 59
62 SyncSessionSnapshot::~SyncSessionSnapshot() {} 60 SyncCycleSnapshot::~SyncCycleSnapshot() {}
63 61
64 std::unique_ptr<base::DictionaryValue> SyncSessionSnapshot::ToValue() const { 62 std::unique_ptr<base::DictionaryValue> SyncCycleSnapshot::ToValue() const {
65 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 63 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
66 value->SetInteger("numSuccessfulCommits", 64 value->SetInteger("numSuccessfulCommits",
67 model_neutral_state_.num_successful_commits); 65 model_neutral_state_.num_successful_commits);
68 value->SetInteger("numSuccessfulBookmarkCommits", 66 value->SetInteger("numSuccessfulBookmarkCommits",
69 model_neutral_state_.num_successful_bookmark_commits); 67 model_neutral_state_.num_successful_bookmark_commits);
70 value->SetInteger("numUpdatesDownloadedTotal", 68 value->SetInteger("numUpdatesDownloadedTotal",
71 model_neutral_state_.num_updates_downloaded_total); 69 model_neutral_state_.num_updates_downloaded_total);
72 value->SetInteger( 70 value->SetInteger(
73 "numTombstoneUpdatesDownloadedTotal", 71 "numTombstoneUpdatesDownloadedTotal",
74 model_neutral_state_.num_tombstone_updates_downloaded_total); 72 model_neutral_state_.num_tombstone_updates_downloaded_total);
(...skipping 25 matching lines...) Expand all
100 type_entries->SetInteger("numToDeleteEntries", 98 type_entries->SetInteger("numToDeleteEntries",
101 num_to_delete_entries_by_type_[i]); 99 num_to_delete_entries_by_type_[i]);
102 100
103 const std::string model_type = ModelTypeToString(static_cast<ModelType>(i)); 101 const std::string model_type = ModelTypeToString(static_cast<ModelType>(i));
104 counter_entries->Set(model_type, type_entries.release()); 102 counter_entries->Set(model_type, type_entries.release());
105 } 103 }
106 value->Set("counter_entries", std::move(counter_entries)); 104 value->Set("counter_entries", std::move(counter_entries));
107 return value; 105 return value;
108 } 106 }
109 107
110 std::string SyncSessionSnapshot::ToString() const { 108 std::string SyncCycleSnapshot::ToString() const {
111 std::string json; 109 std::string json;
112 base::JSONWriter::WriteWithOptions( 110 base::JSONWriter::WriteWithOptions(
113 *ToValue(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &json); 111 *ToValue(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
114 return json; 112 return json;
115 } 113 }
116 114
117 const ProgressMarkerMap& SyncSessionSnapshot::download_progress_markers() 115 const ProgressMarkerMap& SyncCycleSnapshot::download_progress_markers() const {
118 const {
119 return download_progress_markers_; 116 return download_progress_markers_;
120 } 117 }
121 118
122 bool SyncSessionSnapshot::is_silenced() const { 119 bool SyncCycleSnapshot::is_silenced() const {
123 return is_silenced_; 120 return is_silenced_;
124 } 121 }
125 122
126 int SyncSessionSnapshot::num_encryption_conflicts() const { 123 int SyncCycleSnapshot::num_encryption_conflicts() const {
127 return num_encryption_conflicts_; 124 return num_encryption_conflicts_;
128 } 125 }
129 126
130 int SyncSessionSnapshot::num_hierarchy_conflicts() const { 127 int SyncCycleSnapshot::num_hierarchy_conflicts() const {
131 return num_hierarchy_conflicts_; 128 return num_hierarchy_conflicts_;
132 } 129 }
133 130
134 int SyncSessionSnapshot::num_server_conflicts() const { 131 int SyncCycleSnapshot::num_server_conflicts() const {
135 return num_server_conflicts_; 132 return num_server_conflicts_;
136 } 133 }
137 134
138 bool SyncSessionSnapshot::notifications_enabled() const { 135 bool SyncCycleSnapshot::notifications_enabled() const {
139 return notifications_enabled_; 136 return notifications_enabled_;
140 } 137 }
141 138
142 size_t SyncSessionSnapshot::num_entries() const { 139 size_t SyncCycleSnapshot::num_entries() const {
143 return num_entries_; 140 return num_entries_;
144 } 141 }
145 142
146 base::Time SyncSessionSnapshot::sync_start_time() const { 143 base::Time SyncCycleSnapshot::sync_start_time() const {
147 return sync_start_time_; 144 return sync_start_time_;
148 } 145 }
149 146
150 base::Time SyncSessionSnapshot::poll_finish_time() const { 147 base::Time SyncCycleSnapshot::poll_finish_time() const {
151 return poll_finish_time_; 148 return poll_finish_time_;
152 } 149 }
153 150
154 bool SyncSessionSnapshot::is_initialized() const { 151 bool SyncCycleSnapshot::is_initialized() const {
155 return is_initialized_; 152 return is_initialized_;
156 } 153 }
157 154
158 const std::vector<int>& SyncSessionSnapshot::num_entries_by_type() const { 155 const std::vector<int>& SyncCycleSnapshot::num_entries_by_type() const {
159 return num_entries_by_type_; 156 return num_entries_by_type_;
160 } 157 }
161 158
162 const std::vector<int>& SyncSessionSnapshot::num_to_delete_entries_by_type() 159 const std::vector<int>& SyncCycleSnapshot::num_to_delete_entries_by_type()
163 const { 160 const {
164 return num_to_delete_entries_by_type_; 161 return num_to_delete_entries_by_type_;
165 } 162 }
166 163
167 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource 164 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource
168 SyncSessionSnapshot::legacy_updates_source() const { 165 SyncCycleSnapshot::legacy_updates_source() const {
169 return legacy_updates_source_; 166 return legacy_updates_source_;
170 } 167 }
171 168
172 } // namespace sessions
173 } // namespace syncer 169 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine/cycle/sync_cycle_snapshot.h ('k') | components/sync/engine/cycle/sync_cycle_snapshot_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698