| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stddef.h> | 7 #include <stddef.h> | 
| 8 #include <algorithm> | 8 #include <algorithm> | 
| 9 #include <iterator> | 9 #include <iterator> | 
| 10 #include <ostream> | 10 #include <ostream> | 
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 264       } | 264       } | 
| 265       timestamp_match_partner_->service()->RemoveObserver(this); | 265       timestamp_match_partner_->service()->RemoveObserver(this); | 
| 266       timestamp_match_partner_ = NULL; | 266       timestamp_match_partner_ = NULL; | 
| 267 | 267 | 
| 268       SignalStateCompleteWithNextState(FULLY_SYNCED); | 268       SignalStateCompleteWithNextState(FULLY_SYNCED); | 
| 269       break; | 269       break; | 
| 270     } | 270     } | 
| 271     case WAITING_FOR_PASSPHRASE_ACCEPTED: { | 271     case WAITING_FOR_PASSPHRASE_ACCEPTED: { | 
| 272       LogClientInfo("WAITING_FOR_PASSPHRASE_ACCEPTED"); | 272       LogClientInfo("WAITING_FOR_PASSPHRASE_ACCEPTED"); | 
| 273       if (service()->ShouldPushChanges() && | 273       if (service()->ShouldPushChanges() && | 
| 274           !service()->ObservedPassphraseRequired()) { | 274           !service()->IsPassphraseRequired()) { | 
| 275         // The passphrase has been accepted, and sync has been restarted. | 275         // The passphrase has been accepted, and sync has been restarted. | 
| 276         SignalStateCompleteWithNextState(FULLY_SYNCED); | 276         SignalStateCompleteWithNextState(FULLY_SYNCED); | 
| 277       } | 277       } | 
| 278       break; | 278       break; | 
| 279     } | 279     } | 
| 280     case WAITING_FOR_ENCRYPTION: { | 280     case WAITING_FOR_ENCRYPTION: { | 
| 281       LogClientInfo("WAITING_FOR_ENCRYPTION"); | 281       LogClientInfo("WAITING_FOR_ENCRYPTION"); | 
| 282       if (IsTypeEncrypted(waiting_for_encryption_type_)) { | 282       if (IsTypeEncrypted(waiting_for_encryption_type_)) { | 
| 283         // Encryption is complete for the type we are waiting on. | 283         // Encryption is complete for the type we are waiting on. | 
| 284         SignalStateCompleteWithNextState(FULLY_SYNCED); | 284         SignalStateCompleteWithNextState(FULLY_SYNCED); | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 331 } | 331 } | 
| 332 | 332 | 
| 333 bool ProfileSyncServiceHarness::AwaitPassphraseAccepted() { | 333 bool ProfileSyncServiceHarness::AwaitPassphraseAccepted() { | 
| 334   LogClientInfo("AwaitPassphraseAccepted"); | 334   LogClientInfo("AwaitPassphraseAccepted"); | 
| 335   if (wait_state_ == SYNC_DISABLED) { | 335   if (wait_state_ == SYNC_DISABLED) { | 
| 336     LOG(ERROR) << "Sync disabled for Client " << id_ << "."; | 336     LOG(ERROR) << "Sync disabled for Client " << id_ << "."; | 
| 337     return false; | 337     return false; | 
| 338   } | 338   } | 
| 339 | 339 | 
| 340   if (service()->ShouldPushChanges() && | 340   if (service()->ShouldPushChanges() && | 
| 341       !service()->ObservedPassphraseRequired()) { | 341       !service()->IsPassphraseRequired()) { | 
| 342     // Passphrase is already accepted; don't wait. | 342     // Passphrase is already accepted; don't wait. | 
| 343     return true; | 343     return true; | 
| 344   } | 344   } | 
| 345 | 345 | 
| 346   wait_state_ = WAITING_FOR_PASSPHRASE_ACCEPTED; | 346   wait_state_ = WAITING_FOR_PASSPHRASE_ACCEPTED; | 
| 347   return AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, | 347   return AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, | 
| 348                                       "Waiting for passphrase accepted."); | 348                                       "Waiting for passphrase accepted."); | 
| 349 } | 349 } | 
| 350 | 350 | 
| 351 bool ProfileSyncServiceHarness::AwaitBackendInitialized() { | 351 bool ProfileSyncServiceHarness::AwaitBackendInitialized() { | 
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 517   const SyncSessionSnapshot* snap = GetLastSessionSnapshot(); | 517   const SyncSessionSnapshot* snap = GetLastSessionSnapshot(); | 
| 518   // TODO(rsimha): Remove additional checks of snap->has_more_to_sync and | 518   // TODO(rsimha): Remove additional checks of snap->has_more_to_sync and | 
| 519   // snap->unsynced_count once http://crbug.com/48989 is fixed. | 519   // snap->unsynced_count once http://crbug.com/48989 is fixed. | 
| 520   return (snap && | 520   return (snap && | 
| 521           snap->num_conflicting_updates == 0 &&  // We can decrypt everything. | 521           snap->num_conflicting_updates == 0 &&  // We can decrypt everything. | 
| 522           ServiceIsPushingChanges() && | 522           ServiceIsPushingChanges() && | 
| 523           GetStatus().notifications_enabled && | 523           GetStatus().notifications_enabled && | 
| 524           !service()->HasUnsyncedItems() && | 524           !service()->HasUnsyncedItems() && | 
| 525           !snap->has_more_to_sync && | 525           !snap->has_more_to_sync && | 
| 526           snap->unsynced_count == 0 && | 526           snap->unsynced_count == 0 && | 
| 527           !service()->HasPendingBackendMigration()); | 527           !service()->HasPendingBackendMigration() && | 
|  | 528           service()->passphrase_required_reason() != | 
|  | 529               sync_api::REASON_SET_PASSPHRASE_FAILED); | 
| 528 } | 530 } | 
| 529 | 531 | 
| 530 bool ProfileSyncServiceHarness::MatchesOtherClient( | 532 bool ProfileSyncServiceHarness::MatchesOtherClient( | 
| 531     ProfileSyncServiceHarness* partner) { | 533     ProfileSyncServiceHarness* partner) { | 
| 532   if (!IsSynced()) | 534   if (!IsSynced()) | 
| 533     return false; | 535     return false; | 
| 534 | 536 | 
| 535   // Only look for a match if we have at least one enabled datatype in | 537   // Only look for a match if we have at least one enabled datatype in | 
| 536   // common with the partner client. | 538   // common with the partner client. | 
| 537   syncable::ModelTypeSet types, other_types, intersection_types; | 539   syncable::ModelTypeSet types, other_types, intersection_types; | 
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 652     const SyncSessionSnapshot* snap = GetLastSessionSnapshot(); | 654     const SyncSessionSnapshot* snap = GetLastSessionSnapshot(); | 
| 653     if (snap) { | 655     if (snap) { | 
| 654       VLOG(0) << "Client " << id_ << ": " << message | 656       VLOG(0) << "Client " << id_ << ": " << message | 
| 655               << ": num_updates_downloaded : " | 657               << ": num_updates_downloaded : " | 
| 656               << snap->syncer_status.num_updates_downloaded_total | 658               << snap->syncer_status.num_updates_downloaded_total | 
| 657               << ", has_more_to_sync: " << snap->has_more_to_sync | 659               << ", has_more_to_sync: " << snap->has_more_to_sync | 
| 658               << ", unsynced_count: " << snap->unsynced_count | 660               << ", unsynced_count: " << snap->unsynced_count | 
| 659               << ", num_conflicting_updates: " << snap->num_conflicting_updates | 661               << ", num_conflicting_updates: " << snap->num_conflicting_updates | 
| 660               << ", has_unsynced_items: " | 662               << ", has_unsynced_items: " | 
| 661               << service()->HasUnsyncedItems() | 663               << service()->HasUnsyncedItems() | 
| 662               << ", observed_passphrase_required: " | 664               << ", passphrase_required_reason: " | 
| 663               << service()->ObservedPassphraseRequired() | 665               << sync_api::PassphraseRequiredReasonToString( | 
|  | 666                     service()->passphrase_required_reason()) | 
| 664               << ", notifications_enabled: " | 667               << ", notifications_enabled: " | 
| 665               << GetStatus().notifications_enabled | 668               << GetStatus().notifications_enabled | 
| 666               << ", service_is_pushing_changes: " << ServiceIsPushingChanges() | 669               << ", service_is_pushing_changes: " << ServiceIsPushingChanges() | 
| 667               << ", has_pending_backend_migration: " | 670               << ", has_pending_backend_migration: " | 
| 668               << service()->HasPendingBackendMigration(); | 671               << service()->HasPendingBackendMigration(); | 
| 669     } else { | 672     } else { | 
| 670       VLOG(0) << "Client " << id_ << ": " << message | 673       VLOG(0) << "Client " << id_ << ": " << message | 
| 671               << ": Sync session snapshot not available."; | 674               << ": Sync session snapshot not available."; | 
| 672     } | 675     } | 
| 673   } else { | 676   } else { | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 709   return true; | 712   return true; | 
| 710 } | 713 } | 
| 711 | 714 | 
| 712 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 715 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 
| 713   DictionaryValue value; | 716   DictionaryValue value; | 
| 714   sync_ui_util::ConstructAboutInformation(service_, &value); | 717   sync_ui_util::ConstructAboutInformation(service_, &value); | 
| 715   std::string service_status; | 718   std::string service_status; | 
| 716   base::JSONWriter::Write(&value, true, &service_status); | 719   base::JSONWriter::Write(&value, true, &service_status); | 
| 717   return service_status; | 720   return service_status; | 
| 718 } | 721 } | 
| OLD | NEW | 
|---|