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

Side by Side Diff: components/sync/core_impl/debug_info_event_listener.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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 "sync/internal_api/debug_info_event_listener.h" 5 #include "components/sync/core_impl/debug_info_event_listener.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "sync/util/cryptographer.h" 9 #include "components/sync/base/cryptographer.h"
10 10
11 namespace syncer { 11 namespace syncer {
12 12
13 using sessions::SyncSessionSnapshot; 13 using sessions::SyncSessionSnapshot;
14 14
15 DebugInfoEventListener::DebugInfoEventListener() 15 DebugInfoEventListener::DebugInfoEventListener()
16 : events_dropped_(false), 16 : events_dropped_(false),
17 cryptographer_has_pending_keys_(false), 17 cryptographer_has_pending_keys_(false),
18 cryptographer_ready_(false), 18 cryptographer_ready_(false),
19 weak_ptr_factory_(this) { 19 weak_ptr_factory_(this) {}
20 }
21 20
22 DebugInfoEventListener::~DebugInfoEventListener() { 21 DebugInfoEventListener::~DebugInfoEventListener() {}
23 }
24 22
25 void DebugInfoEventListener::OnSyncCycleCompleted( 23 void DebugInfoEventListener::OnSyncCycleCompleted(
26 const SyncSessionSnapshot& snapshot) { 24 const SyncSessionSnapshot& snapshot) {
27 DCHECK(thread_checker_.CalledOnValidThread()); 25 DCHECK(thread_checker_.CalledOnValidThread());
28 sync_pb::DebugEventInfo event_info; 26 sync_pb::DebugEventInfo event_info;
29 sync_pb::SyncCycleCompletedEventInfo* sync_completed_event_info = 27 sync_pb::SyncCycleCompletedEventInfo* sync_completed_event_info =
30 event_info.mutable_sync_cycle_completed_event_info(); 28 event_info.mutable_sync_cycle_completed_event_info();
31 29
32 sync_completed_event_info->set_num_encryption_conflicts( 30 sync_completed_event_info->set_num_encryption_conflicts(
33 snapshot.num_encryption_conflicts()); 31 snapshot.num_encryption_conflicts());
(...skipping 10 matching lines...) Expand all
44 snapshot.legacy_updates_source()); 42 snapshot.legacy_updates_source());
45 sync_completed_event_info->mutable_caller_info()->set_notifications_enabled( 43 sync_completed_event_info->mutable_caller_info()->set_notifications_enabled(
46 snapshot.notifications_enabled()); 44 snapshot.notifications_enabled());
47 45
48 AddEventToQueue(event_info); 46 AddEventToQueue(event_info);
49 } 47 }
50 48
51 void DebugInfoEventListener::OnInitializationComplete( 49 void DebugInfoEventListener::OnInitializationComplete(
52 const WeakHandle<JsBackend>& js_backend, 50 const WeakHandle<JsBackend>& js_backend,
53 const WeakHandle<DataTypeDebugInfoListener>& debug_listener, 51 const WeakHandle<DataTypeDebugInfoListener>& debug_listener,
54 bool success, ModelTypeSet restored_types) { 52 bool success,
53 ModelTypeSet restored_types) {
55 DCHECK(thread_checker_.CalledOnValidThread()); 54 DCHECK(thread_checker_.CalledOnValidThread());
56 CreateAndAddEvent(sync_pb::SyncEnums::INITIALIZATION_COMPLETE); 55 CreateAndAddEvent(sync_pb::SyncEnums::INITIALIZATION_COMPLETE);
57 } 56 }
58 57
59 void DebugInfoEventListener::OnConnectionStatusChange( 58 void DebugInfoEventListener::OnConnectionStatusChange(ConnectionStatus status) {
60 ConnectionStatus status) {
61 DCHECK(thread_checker_.CalledOnValidThread()); 59 DCHECK(thread_checker_.CalledOnValidThread());
62 CreateAndAddEvent(sync_pb::SyncEnums::CONNECTION_STATUS_CHANGE); 60 CreateAndAddEvent(sync_pb::SyncEnums::CONNECTION_STATUS_CHANGE);
63 } 61 }
64 62
65 void DebugInfoEventListener::OnPassphraseRequired( 63 void DebugInfoEventListener::OnPassphraseRequired(
66 PassphraseRequiredReason reason, 64 PassphraseRequiredReason reason,
67 const sync_pb::EncryptedData& pending_keys) { 65 const sync_pb::EncryptedData& pending_keys) {
68 DCHECK(thread_checker_.CalledOnValidThread()); 66 DCHECK(thread_checker_.CalledOnValidThread());
69 CreateAndAddEvent(sync_pb::SyncEnums::PASSPHRASE_REQUIRED); 67 CreateAndAddEvent(sync_pb::SyncEnums::PASSPHRASE_REQUIRED);
70 } 68 }
71 69
72 void DebugInfoEventListener::OnPassphraseAccepted() { 70 void DebugInfoEventListener::OnPassphraseAccepted() {
73 DCHECK(thread_checker_.CalledOnValidThread()); 71 DCHECK(thread_checker_.CalledOnValidThread());
74 CreateAndAddEvent(sync_pb::SyncEnums::PASSPHRASE_ACCEPTED); 72 CreateAndAddEvent(sync_pb::SyncEnums::PASSPHRASE_ACCEPTED);
75 } 73 }
76 74
77 void DebugInfoEventListener::OnBootstrapTokenUpdated( 75 void DebugInfoEventListener::OnBootstrapTokenUpdated(
78 const std::string& bootstrap_token, BootstrapTokenType type) { 76 const std::string& bootstrap_token,
77 BootstrapTokenType type) {
79 DCHECK(thread_checker_.CalledOnValidThread()); 78 DCHECK(thread_checker_.CalledOnValidThread());
80 if (type == PASSPHRASE_BOOTSTRAP_TOKEN) { 79 if (type == PASSPHRASE_BOOTSTRAP_TOKEN) {
81 CreateAndAddEvent(sync_pb::SyncEnums::BOOTSTRAP_TOKEN_UPDATED); 80 CreateAndAddEvent(sync_pb::SyncEnums::BOOTSTRAP_TOKEN_UPDATED);
82 return; 81 return;
83 } 82 }
84 DCHECK_EQ(type, KEYSTORE_BOOTSTRAP_TOKEN); 83 DCHECK_EQ(type, KEYSTORE_BOOTSTRAP_TOKEN);
85 CreateAndAddEvent(sync_pb::SyncEnums::KEYSTORE_TOKEN_UPDATED); 84 CreateAndAddEvent(sync_pb::SyncEnums::KEYSTORE_TOKEN_UPDATED);
86 } 85 }
87 86
88 void DebugInfoEventListener::OnEncryptedTypesChanged( 87 void DebugInfoEventListener::OnEncryptedTypesChanged(
(...skipping 16 matching lines...) Expand all
105 } 104 }
106 105
107 void DebugInfoEventListener::OnPassphraseTypeChanged( 106 void DebugInfoEventListener::OnPassphraseTypeChanged(
108 PassphraseType type, 107 PassphraseType type,
109 base::Time explicit_passphrase_time) { 108 base::Time explicit_passphrase_time) {
110 DCHECK(thread_checker_.CalledOnValidThread()); 109 DCHECK(thread_checker_.CalledOnValidThread());
111 CreateAndAddEvent(sync_pb::SyncEnums::PASSPHRASE_TYPE_CHANGED); 110 CreateAndAddEvent(sync_pb::SyncEnums::PASSPHRASE_TYPE_CHANGED);
112 } 111 }
113 112
114 void DebugInfoEventListener::OnLocalSetPassphraseEncryption( 113 void DebugInfoEventListener::OnLocalSetPassphraseEncryption(
115 const SyncEncryptionHandler::NigoriState& nigori_state) { 114 const SyncEncryptionHandler::NigoriState& nigori_state) {}
116 }
117 115
118 void DebugInfoEventListener::OnActionableError( 116 void DebugInfoEventListener::OnActionableError(
119 const SyncProtocolError& sync_error) { 117 const SyncProtocolError& sync_error) {
120 DCHECK(thread_checker_.CalledOnValidThread()); 118 DCHECK(thread_checker_.CalledOnValidThread());
121 CreateAndAddEvent(sync_pb::SyncEnums::ACTIONABLE_ERROR); 119 CreateAndAddEvent(sync_pb::SyncEnums::ACTIONABLE_ERROR);
122 } 120 }
123 121
124 void DebugInfoEventListener::OnMigrationRequested(ModelTypeSet types) {} 122 void DebugInfoEventListener::OnMigrationRequested(ModelTypeSet types) {}
125 123
126 void DebugInfoEventListener::OnProtocolEvent(const ProtocolEvent& event) {} 124 void DebugInfoEventListener::OnProtocolEvent(const ProtocolEvent& event) {}
127 125
128 void DebugInfoEventListener::OnNudgeFromDatatype(ModelType datatype) { 126 void DebugInfoEventListener::OnNudgeFromDatatype(ModelType datatype) {
129 DCHECK(thread_checker_.CalledOnValidThread()); 127 DCHECK(thread_checker_.CalledOnValidThread());
130 sync_pb::DebugEventInfo event_info; 128 sync_pb::DebugEventInfo event_info;
131 event_info.set_nudging_datatype( 129 event_info.set_nudging_datatype(
132 GetSpecificsFieldNumberFromModelType(datatype)); 130 GetSpecificsFieldNumberFromModelType(datatype));
133 AddEventToQueue(event_info); 131 AddEventToQueue(event_info);
134 } 132 }
135 133
136 void DebugInfoEventListener::GetDebugInfo(sync_pb::DebugInfo* debug_info) { 134 void DebugInfoEventListener::GetDebugInfo(sync_pb::DebugInfo* debug_info) {
137 DCHECK(thread_checker_.CalledOnValidThread()); 135 DCHECK(thread_checker_.CalledOnValidThread());
138 DCHECK_LE(events_.size(), kMaxEntries); 136 DCHECK_LE(events_.size(), kMaxEntries);
139 137
140 for (DebugEventInfoQueue::const_iterator iter = events_.begin(); 138 for (DebugEventInfoQueue::const_iterator iter = events_.begin();
141 iter != events_.end(); 139 iter != events_.end(); ++iter) {
142 ++iter) {
143 sync_pb::DebugEventInfo* event_info = debug_info->add_events(); 140 sync_pb::DebugEventInfo* event_info = debug_info->add_events();
144 event_info->CopyFrom(*iter); 141 event_info->CopyFrom(*iter);
145 } 142 }
146 143
147 debug_info->set_events_dropped(events_dropped_); 144 debug_info->set_events_dropped(events_dropped_);
148 debug_info->set_cryptographer_ready(cryptographer_ready_); 145 debug_info->set_cryptographer_ready(cryptographer_ready_);
149 debug_info->set_cryptographer_has_pending_keys( 146 debug_info->set_cryptographer_has_pending_keys(
150 cryptographer_has_pending_keys_); 147 cryptographer_has_pending_keys_);
151 } 148 }
152 149
(...skipping 15 matching lines...) Expand all
168 DCHECK(thread_checker_.CalledOnValidThread()); 165 DCHECK(thread_checker_.CalledOnValidThread());
169 166
170 for (size_t i = 0; i < configuration_stats.size(); ++i) { 167 for (size_t i = 0; i < configuration_stats.size(); ++i) {
171 DCHECK(ProtocolTypes().Has(configuration_stats[i].model_type)); 168 DCHECK(ProtocolTypes().Has(configuration_stats[i].model_type));
172 const DataTypeAssociationStats& association_stats = 169 const DataTypeAssociationStats& association_stats =
173 configuration_stats[i].association_stats; 170 configuration_stats[i].association_stats;
174 171
175 sync_pb::DebugEventInfo association_event; 172 sync_pb::DebugEventInfo association_event;
176 sync_pb::DatatypeAssociationStats* datatype_stats = 173 sync_pb::DatatypeAssociationStats* datatype_stats =
177 association_event.mutable_datatype_association_stats(); 174 association_event.mutable_datatype_association_stats();
178 datatype_stats->set_data_type_id( 175 datatype_stats->set_data_type_id(GetSpecificsFieldNumberFromModelType(
179 GetSpecificsFieldNumberFromModelType( 176 configuration_stats[i].model_type));
180 configuration_stats[i].model_type));
181 datatype_stats->set_num_local_items_before_association( 177 datatype_stats->set_num_local_items_before_association(
182 association_stats.num_local_items_before_association); 178 association_stats.num_local_items_before_association);
183 datatype_stats->set_num_sync_items_before_association( 179 datatype_stats->set_num_sync_items_before_association(
184 association_stats.num_sync_items_before_association); 180 association_stats.num_sync_items_before_association);
185 datatype_stats->set_num_local_items_after_association( 181 datatype_stats->set_num_local_items_after_association(
186 association_stats.num_local_items_after_association); 182 association_stats.num_local_items_after_association);
187 datatype_stats->set_num_sync_items_after_association( 183 datatype_stats->set_num_sync_items_after_association(
188 association_stats.num_sync_items_after_association); 184 association_stats.num_sync_items_after_association);
189 datatype_stats->set_num_local_items_added( 185 datatype_stats->set_num_local_items_added(
190 association_stats.num_local_items_added); 186 association_stats.num_local_items_added);
191 datatype_stats->set_num_local_items_deleted( 187 datatype_stats->set_num_local_items_deleted(
192 association_stats.num_local_items_deleted); 188 association_stats.num_local_items_deleted);
193 datatype_stats->set_num_local_items_modified( 189 datatype_stats->set_num_local_items_modified(
194 association_stats.num_local_items_modified); 190 association_stats.num_local_items_modified);
195 datatype_stats->set_num_sync_items_added( 191 datatype_stats->set_num_sync_items_added(
196 association_stats.num_sync_items_added); 192 association_stats.num_sync_items_added);
197 datatype_stats->set_num_sync_items_deleted( 193 datatype_stats->set_num_sync_items_deleted(
198 association_stats.num_sync_items_deleted); 194 association_stats.num_sync_items_deleted);
199 datatype_stats->set_num_sync_items_modified( 195 datatype_stats->set_num_sync_items_modified(
200 association_stats.num_sync_items_modified); 196 association_stats.num_sync_items_modified);
201 datatype_stats->set_local_version_pre_association( 197 datatype_stats->set_local_version_pre_association(
202 association_stats.local_version_pre_association); 198 association_stats.local_version_pre_association);
203 datatype_stats->set_sync_version_pre_association( 199 datatype_stats->set_sync_version_pre_association(
204 association_stats.sync_version_pre_association); 200 association_stats.sync_version_pre_association);
205 datatype_stats->set_had_error(association_stats.had_error); 201 datatype_stats->set_had_error(association_stats.had_error);
206 datatype_stats->set_association_wait_time_for_same_priority_us( 202 datatype_stats->set_association_wait_time_for_same_priority_us(
207 association_stats.association_wait_time.InMicroseconds()); 203 association_stats.association_wait_time.InMicroseconds());
208 datatype_stats->set_association_time_us( 204 datatype_stats->set_association_time_us(
209 association_stats.association_time.InMicroseconds()); 205 association_stats.association_time.InMicroseconds());
210 datatype_stats->set_download_wait_time_us( 206 datatype_stats->set_download_wait_time_us(
211 configuration_stats[i].download_wait_time.InMicroseconds()); 207 configuration_stats[i].download_wait_time.InMicroseconds());
212 datatype_stats->set_download_time_us( 208 datatype_stats->set_download_time_us(
213 configuration_stats[i].download_time.InMicroseconds()); 209 configuration_stats[i].download_time.InMicroseconds());
214 datatype_stats->set_association_wait_time_for_high_priority_us( 210 datatype_stats->set_association_wait_time_for_high_priority_us(
215 configuration_stats[i].association_wait_time_for_high_priority 211 configuration_stats[i]
216 .InMicroseconds()); 212 .association_wait_time_for_high_priority.InMicroseconds());
217 213
218 for (ModelTypeSet::Iterator it = 214 for (ModelTypeSet::Iterator it =
219 configuration_stats[i].high_priority_types_configured_before 215 configuration_stats[i]
220 .First(); 216 .high_priority_types_configured_before.First();
221 it.Good(); it.Inc()) { 217 it.Good(); it.Inc()) {
222 datatype_stats->add_high_priority_type_configured_before( 218 datatype_stats->add_high_priority_type_configured_before(
223 GetSpecificsFieldNumberFromModelType(it.Get())); 219 GetSpecificsFieldNumberFromModelType(it.Get()));
224 } 220 }
225 221
226 for (ModelTypeSet::Iterator it = 222 for (ModelTypeSet::Iterator it =
227 configuration_stats[i].same_priority_types_configured_before 223 configuration_stats[i]
228 .First(); 224 .same_priority_types_configured_before.First();
229 it.Good(); it.Inc()) { 225 it.Good(); it.Inc()) {
230 datatype_stats->add_same_priority_type_configured_before( 226 datatype_stats->add_same_priority_type_configured_before(
231 GetSpecificsFieldNumberFromModelType(it.Get())); 227 GetSpecificsFieldNumberFromModelType(it.Get()));
232 } 228 }
233 229
234 AddEventToQueue(association_event); 230 AddEventToQueue(association_event);
235 } 231 }
236 } 232 }
237 233
238 void DebugInfoEventListener::CreateAndAddEvent( 234 void DebugInfoEventListener::CreateAndAddEvent(
239 sync_pb::SyncEnums::SingletonDebugEventType type) { 235 sync_pb::SyncEnums::SingletonDebugEventType type) {
240 DCHECK(thread_checker_.CalledOnValidThread()); 236 DCHECK(thread_checker_.CalledOnValidThread());
241 sync_pb::DebugEventInfo event_info; 237 sync_pb::DebugEventInfo event_info;
242 event_info.set_singleton_event(type); 238 event_info.set_singleton_event(type);
243 AddEventToQueue(event_info); 239 AddEventToQueue(event_info);
244 } 240 }
245 241
246 void DebugInfoEventListener::AddEventToQueue( 242 void DebugInfoEventListener::AddEventToQueue(
247 const sync_pb::DebugEventInfo& event_info) { 243 const sync_pb::DebugEventInfo& event_info) {
248 DCHECK(thread_checker_.CalledOnValidThread()); 244 DCHECK(thread_checker_.CalledOnValidThread());
249 if (events_.size() >= kMaxEntries) { 245 if (events_.size() >= kMaxEntries) {
250 DVLOG(1) << "DebugInfoEventListener::AddEventToQueue Dropping an old event " 246 DVLOG(1) << "DebugInfoEventListener::AddEventToQueue Dropping an old event "
251 << "because of full queue"; 247 << "because of full queue";
252 248
253 events_.pop_front(); 249 events_.pop_front();
254 events_dropped_ = true; 250 events_dropped_ = true;
255 } 251 }
256 events_.push_back(event_info); 252 events_.push_back(event_info);
257 } 253 }
258 254
259 } // namespace syncer 255 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/core_impl/debug_info_event_listener.h ('k') | components/sync/core_impl/debug_info_event_listener_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698