OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/sync/profile_sync_service_harness.h" | 5 #include "chrome/browser/sync/profile_sync_service_harness.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 LogClientInfo("IsSynced"); | 440 LogClientInfo("IsSynced"); |
441 if (service() == NULL) | 441 if (service() == NULL) |
442 return false; | 442 return false; |
443 const SyncSessionSnapshot* snap = GetLastSessionSnapshot(); | 443 const SyncSessionSnapshot* snap = GetLastSessionSnapshot(); |
444 // TODO(rsimha): Remove additional checks of snap->has_more_to_sync and | 444 // TODO(rsimha): Remove additional checks of snap->has_more_to_sync and |
445 // snap->unsynced_count once http://crbug.com/48989 is fixed. | 445 // snap->unsynced_count once http://crbug.com/48989 is fixed. |
446 return (snap && | 446 return (snap && |
447 snap->num_conflicting_updates == 0 && // We can decrypt everything. | 447 snap->num_conflicting_updates == 0 && // We can decrypt everything. |
448 ServiceIsPushingChanges() && | 448 ServiceIsPushingChanges() && |
449 GetStatus().notifications_enabled && | 449 GetStatus().notifications_enabled && |
450 !service()->backend()->HasUnsyncedItems() && | 450 !service()->HasUnsyncedItems() && |
451 !snap->has_more_to_sync && | 451 !snap->has_more_to_sync && |
452 snap->unsynced_count == 0); | 452 snap->unsynced_count == 0); |
453 } | 453 } |
454 | 454 |
455 bool ProfileSyncServiceHarness::MatchesOtherClient( | 455 bool ProfileSyncServiceHarness::MatchesOtherClient( |
456 ProfileSyncServiceHarness* partner) { | 456 ProfileSyncServiceHarness* partner) { |
457 if (!IsSynced()) | 457 if (!IsSynced()) |
458 return false; | 458 return false; |
459 | 459 |
460 // Only look for a match if we have at least one enabled datatype in | 460 // Only look for a match if we have at least one enabled datatype in |
(...skipping 12 matching lines...) Expand all Loading... |
473 partner->GetUpdatedTimestamp(*i) != GetUpdatedTimestamp(*i)) { | 473 partner->GetUpdatedTimestamp(*i) != GetUpdatedTimestamp(*i)) { |
474 return false; | 474 return false; |
475 } | 475 } |
476 } | 476 } |
477 return true; | 477 return true; |
478 } | 478 } |
479 | 479 |
480 const SyncSessionSnapshot* | 480 const SyncSessionSnapshot* |
481 ProfileSyncServiceHarness::GetLastSessionSnapshot() const { | 481 ProfileSyncServiceHarness::GetLastSessionSnapshot() const { |
482 DCHECK(service_ != NULL) << "Sync service has not yet been set up."; | 482 DCHECK(service_ != NULL) << "Sync service has not yet been set up."; |
483 if (service_->backend()) { | 483 if (service_->sync_initialized()) { |
484 return service_->backend()->GetLastSessionSnapshot(); | 484 return service_->GetLastSessionSnapshot(); |
485 } | 485 } |
486 return NULL; | 486 return NULL; |
487 } | 487 } |
488 | 488 |
489 void ProfileSyncServiceHarness::EnableSyncForDatatype( | 489 void ProfileSyncServiceHarness::EnableSyncForDatatype( |
490 syncable::ModelType datatype) { | 490 syncable::ModelType datatype) { |
491 LogClientInfo("EnableSyncForDatatype"); | 491 LogClientInfo("EnableSyncForDatatype"); |
492 syncable::ModelTypeSet synced_datatypes; | 492 syncable::ModelTypeSet synced_datatypes; |
493 if (wait_state_ == SYNC_DISABLED) { | 493 if (wait_state_ == SYNC_DISABLED) { |
494 wait_state_ = WAITING_FOR_ON_BACKEND_INITIALIZED; | 494 wait_state_ = WAITING_FOR_ON_BACKEND_INITIALIZED; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 if (service()) { | 575 if (service()) { |
576 const SyncSessionSnapshot* snap = GetLastSessionSnapshot(); | 576 const SyncSessionSnapshot* snap = GetLastSessionSnapshot(); |
577 if (snap) { | 577 if (snap) { |
578 VLOG(1) << "Client " << id_ << ": " << message | 578 VLOG(1) << "Client " << id_ << ": " << message |
579 << ": num_updates_downloaded : " | 579 << ": num_updates_downloaded : " |
580 << snap->syncer_status.num_updates_downloaded_total | 580 << snap->syncer_status.num_updates_downloaded_total |
581 << ", has_more_to_sync: " << snap->has_more_to_sync | 581 << ", has_more_to_sync: " << snap->has_more_to_sync |
582 << ", unsynced_count: " << snap->unsynced_count | 582 << ", unsynced_count: " << snap->unsynced_count |
583 << ", num_conflicting_updates: " << snap->num_conflicting_updates | 583 << ", num_conflicting_updates: " << snap->num_conflicting_updates |
584 << ", has_unsynced_items: " | 584 << ", has_unsynced_items: " |
585 << service()->backend()->HasUnsyncedItems() | 585 << service()->HasUnsyncedItems() |
586 << ", observed_passphrase_required: " | 586 << ", observed_passphrase_required: " |
587 << service()->observed_passphrase_required() | 587 << service()->observed_passphrase_required() |
588 << ", notifications_enabled: " | 588 << ", notifications_enabled: " |
589 << GetStatus().notifications_enabled | 589 << GetStatus().notifications_enabled |
590 << ", service_is_pushing_changes: " << ServiceIsPushingChanges(); | 590 << ", service_is_pushing_changes: " << ServiceIsPushingChanges(); |
591 } else { | 591 } else { |
592 VLOG(1) << "Client " << id_ << ": " << message | 592 VLOG(1) << "Client " << id_ << ": " << message |
593 << ": Sync session snapshot not available."; | 593 << ": Sync session snapshot not available."; |
594 } | 594 } |
595 } else { | 595 } else { |
596 VLOG(1) << "Client " << id_ << ": " << message | 596 VLOG(1) << "Client " << id_ << ": " << message |
597 << ": Sync service not available."; | 597 << ": Sync service not available."; |
598 } | 598 } |
599 } | 599 } |
OLD | NEW |