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

Side by Side Diff: components/sync/driver/about_sync_util.cc

Issue 2203673002: [Sync] Move //components/sync_driver to //components/sync/driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sd-a
Patch Set: Full change rebased on static lib. 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_driver/about_sync_util.h" 5 #include "components/sync/driver/about_sync_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "components/signin/core/browser/signin_manager_base.h" 14 #include "components/signin/core/browser/signin_manager_base.h"
15 #include "components/sync/api/time.h" 15 #include "components/sync/api/time.h"
16 #include "components/sync/base/sync_string_conversions.h" 16 #include "components/sync/base/sync_string_conversions.h"
17 #include "components/sync/driver/sync_service.h"
17 #include "components/sync/engine/sync_status.h" 18 #include "components/sync/engine/sync_status.h"
18 #include "components/sync/protocol/proto_enum_conversions.h" 19 #include "components/sync/protocol/proto_enum_conversions.h"
19 #include "components/sync/sessions/sync_session_snapshot.h" 20 #include "components/sync/sessions/sync_session_snapshot.h"
20 #include "components/sync_driver/sync_service.h"
21 #include "components/version_info/version_info.h" 21 #include "components/version_info/version_info.h"
22 22
23 using base::DictionaryValue; 23 using base::DictionaryValue;
24 using base::ListValue; 24 using base::ListValue;
25 25
26 namespace sync_driver { 26 namespace sync_driver {
27 27
28 namespace sync_ui_util { 28 namespace sync_ui_util {
29 29
30 const char kIdentityTitle[] = "Identity"; 30 const char kIdentityTitle[] = "Identity";
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 AddSensitiveSection(stats_list, kIdentityTitle); 267 AddSensitiveSection(stats_list, kIdentityTitle);
268 StringSyncStat sync_id(section_identity, "Sync Client ID"); 268 StringSyncStat sync_id(section_identity, "Sync Client ID");
269 StringSyncStat invalidator_id(section_identity, "Invalidator Client ID"); 269 StringSyncStat invalidator_id(section_identity, "Invalidator Client ID");
270 StringSyncStat username(section_identity, "Username"); 270 StringSyncStat username(section_identity, "Username");
271 271
272 base::ListValue* section_credentials = AddSection(stats_list, "Credentials"); 272 base::ListValue* section_credentials = AddSection(stats_list, "Credentials");
273 StringSyncStat request_token_time(section_credentials, "Requested Token"); 273 StringSyncStat request_token_time(section_credentials, "Requested Token");
274 StringSyncStat receive_token_time(section_credentials, "Received Token"); 274 StringSyncStat receive_token_time(section_credentials, "Received Token");
275 StringSyncStat token_request_status(section_credentials, 275 StringSyncStat token_request_status(section_credentials,
276 "Token Request Status"); 276 "Token Request Status");
277 StringSyncStat next_token_request(section_credentials, 277 StringSyncStat next_token_request(section_credentials, "Next Token Request");
278 "Next Token Request");
279 278
280 base::ListValue* section_local = AddSection(stats_list, "Local State"); 279 base::ListValue* section_local = AddSection(stats_list, "Local State");
281 StringSyncStat server_connection(section_local, 280 StringSyncStat server_connection(section_local, "Server Connection");
282 "Server Connection");
283 StringSyncStat last_synced(section_local, "Last Synced"); 281 StringSyncStat last_synced(section_local, "Last Synced");
284 BoolSyncStat is_setup_complete(section_local, 282 BoolSyncStat is_setup_complete(section_local,
285 "Sync First-Time Setup Complete"); 283 "Sync First-Time Setup Complete");
286 StringSyncStat backend_initialization(section_local, 284 StringSyncStat backend_initialization(section_local,
287 "Sync Backend Initialization"); 285 "Sync Backend Initialization");
288 BoolSyncStat is_syncing(section_local, "Syncing"); 286 BoolSyncStat is_syncing(section_local, "Syncing");
289 287
290 base::ListValue* section_network = AddSection(stats_list, "Network"); 288 base::ListValue* section_network = AddSection(stats_list, "Network");
291 BoolSyncStat is_throttled(section_network, "Throttled"); 289 BoolSyncStat is_throttled(section_network, "Throttled");
292 StringSyncStat retry_time(section_network, "Retry time (maybe stale)"); 290 StringSyncStat retry_time(section_network, "Retry time (maybe stale)");
293 BoolSyncStat are_notifications_enabled(section_network, 291 BoolSyncStat are_notifications_enabled(section_network,
294 "Notifications Enabled"); 292 "Notifications Enabled");
295 293
296 base::ListValue* section_encryption = AddSection(stats_list, "Encryption"); 294 base::ListValue* section_encryption = AddSection(stats_list, "Encryption");
297 BoolSyncStat is_using_explicit_passphrase(section_encryption, 295 BoolSyncStat is_using_explicit_passphrase(section_encryption,
298 "Explicit Passphrase"); 296 "Explicit Passphrase");
299 BoolSyncStat is_passphrase_required(section_encryption, 297 BoolSyncStat is_passphrase_required(section_encryption,
300 "Passphrase Required"); 298 "Passphrase Required");
301 BoolSyncStat is_cryptographer_ready(section_encryption, 299 BoolSyncStat is_cryptographer_ready(section_encryption,
302 "Cryptographer Ready"); 300 "Cryptographer Ready");
303 BoolSyncStat has_pending_keys(section_encryption, 301 BoolSyncStat has_pending_keys(section_encryption,
304 "Cryptographer Has Pending Keys"); 302 "Cryptographer Has Pending Keys");
305 StringSyncStat encrypted_types(section_encryption, "Encrypted Types"); 303 StringSyncStat encrypted_types(section_encryption, "Encrypted Types");
306 BoolSyncStat has_keystore_key(section_encryption, "Has Keystore Key"); 304 BoolSyncStat has_keystore_key(section_encryption, "Has Keystore Key");
307 StringSyncStat keystore_migration_time(section_encryption, 305 StringSyncStat keystore_migration_time(section_encryption,
308 "Keystore Migration Time"); 306 "Keystore Migration Time");
309 StringSyncStat passphrase_type(section_encryption, 307 StringSyncStat passphrase_type(section_encryption, "Passphrase Type");
310 "Passphrase Type"); 308 StringSyncStat passphrase_time(section_encryption, "Passphrase Time");
311 StringSyncStat passphrase_time(section_encryption,
312 "Passphrase Time");
313 309
314 base::ListValue* section_last_session = AddSection( 310 base::ListValue* section_last_session =
315 stats_list, "Status from Last Completed Session"); 311 AddSection(stats_list, "Status from Last Completed Session");
316 StringSyncStat session_source(section_last_session, "Sync Source"); 312 StringSyncStat session_source(section_last_session, "Sync Source");
317 StringSyncStat get_key_result(section_last_session, "GetKey Step Result"); 313 StringSyncStat get_key_result(section_last_session, "GetKey Step Result");
318 StringSyncStat download_result(section_last_session, "Download Step Result"); 314 StringSyncStat download_result(section_last_session, "Download Step Result");
319 StringSyncStat commit_result(section_last_session, "Commit Step Result"); 315 StringSyncStat commit_result(section_last_session, "Commit Step Result");
320 316
321 base::ListValue* section_counters = AddSection(stats_list, "Running Totals"); 317 base::ListValue* section_counters = AddSection(stats_list, "Running Totals");
322 IntSyncStat notifications_received(section_counters, 318 IntSyncStat notifications_received(section_counters,
323 "Notifications Received"); 319 "Notifications Received");
324 IntSyncStat updates_received(section_counters, "Updates Downloaded"); 320 IntSyncStat updates_received(section_counters, "Updates Downloaded");
325 IntSyncStat tombstone_updates(section_counters, "Tombstone Updates"); 321 IntSyncStat tombstone_updates(section_counters, "Tombstone Updates");
326 IntSyncStat reflected_updates(section_counters, "Reflected Updates"); 322 IntSyncStat reflected_updates(section_counters, "Reflected Updates");
327 IntSyncStat successful_commits(section_counters, "Successful Commits"); 323 IntSyncStat successful_commits(section_counters, "Successful Commits");
328 IntSyncStat conflicts_resolved_local_wins(section_counters, 324 IntSyncStat conflicts_resolved_local_wins(section_counters,
329 "Conflicts Resolved: Client Wins"); 325 "Conflicts Resolved: Client Wins");
330 IntSyncStat conflicts_resolved_server_wins(section_counters, 326 IntSyncStat conflicts_resolved_server_wins(section_counters,
331 "Conflicts Resolved: Server Wins"); 327 "Conflicts Resolved: Server Wins");
332 328
333 base::ListValue *section_this_cycle = AddSection(stats_list, 329 base::ListValue* section_this_cycle =
334 "Transient Counters (this cycle)"); 330 AddSection(stats_list, "Transient Counters (this cycle)");
335 IntSyncStat encryption_conflicts(section_this_cycle, "Encryption Conflicts"); 331 IntSyncStat encryption_conflicts(section_this_cycle, "Encryption Conflicts");
336 IntSyncStat hierarchy_conflicts(section_this_cycle, "Hierarchy Conflicts"); 332 IntSyncStat hierarchy_conflicts(section_this_cycle, "Hierarchy Conflicts");
337 IntSyncStat server_conflicts(section_this_cycle, "Server Conflicts"); 333 IntSyncStat server_conflicts(section_this_cycle, "Server Conflicts");
338 IntSyncStat committed_items(section_this_cycle, "Committed Items"); 334 IntSyncStat committed_items(section_this_cycle, "Committed Items");
339 335
340 base::ListValue* section_that_cycle = AddSection( 336 base::ListValue* section_that_cycle = AddSection(
341 stats_list, "Transient Counters (last cycle of last completed session)"); 337 stats_list, "Transient Counters (last cycle of last completed session)");
342 IntSyncStat updates_downloaded(section_that_cycle, "Updates Downloaded"); 338 IntSyncStat updates_downloaded(section_that_cycle, "Updates Downloaded");
343 IntSyncStat committed_count(section_that_cycle, "Committed Count"); 339 IntSyncStat committed_count(section_that_cycle, "Committed Count");
344 IntSyncStat entries(section_that_cycle, "Entries"); 340 IntSyncStat entries(section_that_cycle, "Entries");
345 341
346 base::ListValue* section_nudge_info = AddSection( 342 base::ListValue* section_nudge_info =
347 stats_list, "Nudge Source Counters"); 343 AddSection(stats_list, "Nudge Source Counters");
348 IntSyncStat nudge_source_notification( 344 IntSyncStat nudge_source_notification(section_nudge_info,
349 section_nudge_info, "Server Invalidations"); 345 "Server Invalidations");
350 IntSyncStat nudge_source_local(section_nudge_info, "Local Changes"); 346 IntSyncStat nudge_source_local(section_nudge_info, "Local Changes");
351 IntSyncStat nudge_source_local_refresh(section_nudge_info, "Local Refreshes"); 347 IntSyncStat nudge_source_local_refresh(section_nudge_info, "Local Refreshes");
352 348
353 // This list of sections belongs in the 'details' field of the returned 349 // This list of sections belongs in the 'details' field of the returned
354 // message. 350 // message.
355 about_info->Set(kDetailsKey, stats_list); 351 about_info->Set(kDetailsKey, stats_list);
356 352
357 // Populate all the fields we declared above. 353 // Populate all the fields we declared above.
358 client_version.SetValue(GetVersionString(channel)); 354 client_version.SetValue(GetVersionString(channel));
359 355
(...skipping 16 matching lines...) Expand all
376 if (is_status_valid && !full_status.sync_id.empty()) 372 if (is_status_valid && !full_status.sync_id.empty())
377 sync_id.SetValue(full_status.sync_id); 373 sync_id.SetValue(full_status.sync_id);
378 if (is_status_valid && !full_status.invalidator_client_id.empty()) 374 if (is_status_valid && !full_status.invalidator_client_id.empty())
379 invalidator_id.SetValue(full_status.invalidator_client_id); 375 invalidator_id.SetValue(full_status.invalidator_client_id);
380 if (signin) 376 if (signin)
381 username.SetValue(signin->GetAuthenticatedAccountInfo().email); 377 username.SetValue(signin->GetAuthenticatedAccountInfo().email);
382 378
383 const sync_driver::SyncService::SyncTokenStatus& token_status = 379 const sync_driver::SyncService::SyncTokenStatus& token_status =
384 service->GetSyncTokenStatus(); 380 service->GetSyncTokenStatus();
385 server_connection.SetValue(GetConnectionStatus(token_status)); 381 server_connection.SetValue(GetConnectionStatus(token_status));
386 request_token_time.SetValue(GetTimeStr(token_status.token_request_time, 382 request_token_time.SetValue(
387 "n/a")); 383 GetTimeStr(token_status.token_request_time, "n/a"));
388 receive_token_time.SetValue(GetTimeStr(token_status.token_receive_time, 384 receive_token_time.SetValue(
389 "n/a")); 385 GetTimeStr(token_status.token_receive_time, "n/a"));
390 std::string err = token_status.last_get_token_error.error_message(); 386 std::string err = token_status.last_get_token_error.error_message();
391 token_request_status.SetValue(err.empty() ? "OK" : err); 387 token_request_status.SetValue(err.empty() ? "OK" : err);
392 next_token_request.SetValue( 388 next_token_request.SetValue(
393 GetTimeStr(token_status.next_token_request_time, "not scheduled")); 389 GetTimeStr(token_status.next_token_request_time, "not scheduled"));
394 390
395 last_synced.SetValue(service->GetLastSyncedTimeString()); 391 last_synced.SetValue(service->GetLastSyncedTimeString());
396 is_setup_complete.SetValue(service->IsFirstSetupComplete()); 392 is_setup_complete.SetValue(service->IsFirstSetupComplete());
397 backend_initialization.SetValue( 393 backend_initialization.SetValue(
398 service->GetBackendInitializationStateString()); 394 service->GetBackendInitializationStateString());
399 if (is_status_valid) { 395 if (is_status_valid) {
400 is_syncing.SetValue(full_status.syncing); 396 is_syncing.SetValue(full_status.syncing);
401 retry_time.SetValue(GetTimeStr(full_status.retry_time, 397 retry_time.SetValue(GetTimeStr(full_status.retry_time,
402 "Scheduler is not in backoff or throttled")); 398 "Scheduler is not in backoff or throttled"));
403 } 399 }
404 400
405 if (snapshot.is_initialized()) 401 if (snapshot.is_initialized())
406 is_throttled.SetValue(snapshot.is_silenced()); 402 is_throttled.SetValue(snapshot.is_silenced());
407 if (is_status_valid) { 403 if (is_status_valid) {
408 are_notifications_enabled.SetValue( 404 are_notifications_enabled.SetValue(full_status.notifications_enabled);
409 full_status.notifications_enabled);
410 } 405 }
411 406
412 if (sync_active) { 407 if (sync_active) {
413 is_using_explicit_passphrase.SetValue( 408 is_using_explicit_passphrase.SetValue(
414 service->IsUsingSecondaryPassphrase()); 409 service->IsUsingSecondaryPassphrase());
415 is_passphrase_required.SetValue(service->IsPassphraseRequired()); 410 is_passphrase_required.SetValue(service->IsPassphraseRequired());
416 passphrase_time.SetValue( 411 passphrase_time.SetValue(
417 GetTimeStr(service->GetExplicitPassphraseTime(), "No Passphrase Time")); 412 GetTimeStr(service->GetExplicitPassphraseTime(), "No Passphrase Time"));
418 } 413 }
419 if (is_status_valid) { 414 if (is_status_valid) {
420 is_cryptographer_ready.SetValue(full_status.cryptographer_ready); 415 is_cryptographer_ready.SetValue(full_status.cryptographer_ready);
421 has_pending_keys.SetValue(full_status.crypto_has_pending_keys); 416 has_pending_keys.SetValue(full_status.crypto_has_pending_keys);
422 encrypted_types.SetValue( 417 encrypted_types.SetValue(ModelTypeSetToString(full_status.encrypted_types));
423 ModelTypeSetToString(full_status.encrypted_types));
424 has_keystore_key.SetValue(full_status.has_keystore_key); 418 has_keystore_key.SetValue(full_status.has_keystore_key);
425 keystore_migration_time.SetValue( 419 keystore_migration_time.SetValue(
426 GetTimeStr(full_status.keystore_migration_time, "Not Migrated")); 420 GetTimeStr(full_status.keystore_migration_time, "Not Migrated"));
427 passphrase_type.SetValue( 421 passphrase_type.SetValue(
428 PassphraseTypeToString(full_status.passphrase_type)); 422 PassphraseTypeToString(full_status.passphrase_type));
429 } 423 }
430 424
431 if (snapshot.is_initialized()) { 425 if (snapshot.is_initialized()) {
432 if (snapshot.legacy_updates_source() != 426 if (snapshot.legacy_updates_source() !=
433 sync_pb::GetUpdatesCallerInfo::UNKNOWN) { 427 sync_pb::GetUpdatesCallerInfo::UNKNOWN) {
434 session_source.SetValue( 428 session_source.SetValue(
435 syncer::GetUpdatesSourceString(snapshot.legacy_updates_source())); 429 syncer::GetUpdatesSourceString(snapshot.legacy_updates_source()));
436 } 430 }
437 get_key_result.SetValue( 431 get_key_result.SetValue(GetSyncerErrorString(
438 GetSyncerErrorString( 432 snapshot.model_neutral_state().last_get_key_result));
439 snapshot.model_neutral_state().last_get_key_result)); 433 download_result.SetValue(GetSyncerErrorString(
440 download_result.SetValue( 434 snapshot.model_neutral_state().last_download_updates_result));
441 GetSyncerErrorString(
442 snapshot.model_neutral_state().last_download_updates_result));
443 commit_result.SetValue( 435 commit_result.SetValue(
444 GetSyncerErrorString( 436 GetSyncerErrorString(snapshot.model_neutral_state().commit_result));
445 snapshot.model_neutral_state().commit_result));
446 } 437 }
447 438
448 if (is_status_valid) { 439 if (is_status_valid) {
449 notifications_received.SetValue(full_status.notifications_received); 440 notifications_received.SetValue(full_status.notifications_received);
450 updates_received.SetValue(full_status.updates_received); 441 updates_received.SetValue(full_status.updates_received);
451 tombstone_updates.SetValue(full_status.tombstone_updates_received); 442 tombstone_updates.SetValue(full_status.tombstone_updates_received);
452 reflected_updates.SetValue(full_status.reflected_updates_received); 443 reflected_updates.SetValue(full_status.reflected_updates_received);
453 successful_commits.SetValue(full_status.num_commits_total); 444 successful_commits.SetValue(full_status.num_commits_total);
454 conflicts_resolved_local_wins.SetValue( 445 conflicts_resolved_local_wins.SetValue(
455 full_status.num_local_overwrites_total); 446 full_status.num_local_overwrites_total);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 base::ListValue* actionable_error = new base::ListValue(); 488 base::ListValue* actionable_error = new base::ListValue();
498 about_info->Set("actionable_error", actionable_error); 489 about_info->Set("actionable_error", actionable_error);
499 490
500 StringSyncStat error_type(actionable_error, "Error Type"); 491 StringSyncStat error_type(actionable_error, "Error Type");
501 StringSyncStat action(actionable_error, "Action"); 492 StringSyncStat action(actionable_error, "Action");
502 StringSyncStat url(actionable_error, "URL"); 493 StringSyncStat url(actionable_error, "URL");
503 StringSyncStat description(actionable_error, "Error Description"); 494 StringSyncStat description(actionable_error, "Error Description");
504 495
505 if (actionable_error_detected) { 496 if (actionable_error_detected) {
506 error_type.SetValue(syncer::GetSyncErrorTypeString( 497 error_type.SetValue(syncer::GetSyncErrorTypeString(
507 full_status.sync_protocol_error.error_type)); 498 full_status.sync_protocol_error.error_type));
508 action.SetValue(syncer::GetClientActionString( 499 action.SetValue(
509 full_status.sync_protocol_error.action)); 500 syncer::GetClientActionString(full_status.sync_protocol_error.action));
510 url.SetValue(full_status.sync_protocol_error.url); 501 url.SetValue(full_status.sync_protocol_error.url);
511 description.SetValue(full_status.sync_protocol_error.error_description); 502 description.SetValue(full_status.sync_protocol_error.error_description);
512 } 503 }
513 504
514 about_info->SetBoolean("unrecoverable_error_detected", 505 about_info->SetBoolean("unrecoverable_error_detected",
515 service->HasUnrecoverableError()); 506 service->HasUnrecoverableError());
516 507
517 if (service->HasUnrecoverableError()) { 508 if (service->HasUnrecoverableError()) {
518 tracked_objects::Location loc(service->unrecoverable_error_location()); 509 tracked_objects::Location loc(service->unrecoverable_error_location());
519 std::string location_str; 510 std::string location_str;
520 loc.Write(true, true, &location_str); 511 loc.Write(true, true, &location_str);
521 std::string unrecoverable_error_message = 512 std::string unrecoverable_error_message =
522 "Unrecoverable error detected at " + location_str + 513 "Unrecoverable error detected at " + location_str + ": " +
523 ": " + service->unrecoverable_error_message(); 514 service->unrecoverable_error_message();
524 about_info->SetString("unrecoverable_error_message", 515 about_info->SetString("unrecoverable_error_message",
525 unrecoverable_error_message); 516 unrecoverable_error_message);
526 } 517 }
527 518
528 about_info->Set("type_status", service->GetTypeStatusMap()); 519 about_info->Set("type_status", service->GetTypeStatusMap());
529 520
530 return about_info; 521 return about_info;
531 } 522 }
532 523
533 } // namespace sync_ui_util 524 } // namespace sync_ui_util
534 525
535 } // namespace sync_driver 526 } // namespace sync_driver
OLDNEW
« no previous file with comments | « components/sync/driver/about_sync_util.h ('k') | components/sync/driver/about_sync_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698