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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 356 } |
357 break; | 357 break; |
358 } | 358 } |
359 case WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION: { | 359 case WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION: { |
360 VLOG(1) << GetClientInfoString( | 360 VLOG(1) << GetClientInfoString( |
361 "WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION"); | 361 "WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION"); |
362 const browser_sync::sessions::SyncSessionSnapshot *snap = | 362 const browser_sync::sessions::SyncSessionSnapshot *snap = |
363 GetLastSessionSnapshot(); | 363 GetLastSessionSnapshot(); |
364 CHECK(snap); | 364 CHECK(snap); |
365 retry_verifier_.VerifyRetryInterval(*snap); | 365 retry_verifier_.VerifyRetryInterval(*snap); |
366 if (retry_verifier_.done()) | 366 if (retry_verifier_.done()) { |
| 367 // Retry verifier is done verifying exponential backoff. |
367 SignalStateCompleteWithNextState(WAITING_FOR_NOTHING); | 368 SignalStateCompleteWithNextState(WAITING_FOR_NOTHING); |
| 369 } |
368 break; | 370 break; |
369 } | 371 } |
370 case WAITING_FOR_MIGRATION_TO_START: { | 372 case WAITING_FOR_MIGRATION_TO_START: { |
371 VLOG(1) << GetClientInfoString("WAITING_FOR_MIGRATION_TO_START"); | 373 VLOG(1) << GetClientInfoString("WAITING_FOR_MIGRATION_TO_START"); |
372 if (HasPendingBackendMigration()) { | 374 if (HasPendingBackendMigration()) { |
| 375 // There are pending migrations. Wait for them. |
373 SignalStateCompleteWithNextState(WAITING_FOR_MIGRATION_TO_FINISH); | 376 SignalStateCompleteWithNextState(WAITING_FOR_MIGRATION_TO_FINISH); |
374 } | 377 } |
375 break; | 378 break; |
376 } | 379 } |
377 case WAITING_FOR_MIGRATION_TO_FINISH: { | 380 case WAITING_FOR_MIGRATION_TO_FINISH: { |
378 VLOG(1) << GetClientInfoString("WAITING_FOR_MIGRATION_TO_FINISH"); | 381 VLOG(1) << GetClientInfoString("WAITING_FOR_MIGRATION_TO_FINISH"); |
379 if (!HasPendingBackendMigration()) { | 382 if (!HasPendingBackendMigration()) { |
| 383 // Done migrating. |
380 SignalStateCompleteWithNextState(WAITING_FOR_NOTHING); | 384 SignalStateCompleteWithNextState(WAITING_FOR_NOTHING); |
381 } | 385 } |
382 break; | 386 break; |
| 387 } |
| 388 case WAITING_FOR_ACTIONABLE_ERROR: { |
| 389 VLOG(1) << GetClientInfoString("WAITING_FOR_ACTIONABLE_ERROR"); |
| 390 ProfileSyncService::Status status = GetStatus(); |
| 391 if (status.sync_protocol_error.action != browser_sync::UNKNOWN_ACTION && |
| 392 service_->unrecoverable_error_detected() == true) { |
| 393 // An actionable error has been detected. |
| 394 SignalStateCompleteWithNextState(WAITING_FOR_NOTHING); |
| 395 } |
| 396 break; |
383 } | 397 } |
384 case SERVER_UNREACHABLE: { | 398 case SERVER_UNREACHABLE: { |
385 VLOG(1) << GetClientInfoString("SERVER_UNREACHABLE"); | 399 VLOG(1) << GetClientInfoString("SERVER_UNREACHABLE"); |
386 if (GetStatus().server_reachable) { | 400 if (GetStatus().server_reachable) { |
387 // The client was offline due to the network being disabled, but is now | 401 // The client was offline due to the network being disabled, but is now |
388 // back online. Wait for the pending sync cycle to complete. | 402 // back online. Wait for the pending sync cycle to complete. |
389 SignalStateCompleteWithNextState(WAITING_FOR_SYNC_TO_FINISH); | 403 SignalStateCompleteWithNextState(WAITING_FOR_SYNC_TO_FINISH); |
390 } | 404 } |
391 break; | 405 break; |
392 } | 406 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 const browser_sync::sessions::SyncSessionSnapshot *snap = | 589 const browser_sync::sessions::SyncSessionSnapshot *snap = |
576 GetLastSessionSnapshot(); | 590 GetLastSessionSnapshot(); |
577 CHECK(snap); | 591 CHECK(snap); |
578 retry_verifier_.Initialize(*snap); | 592 retry_verifier_.Initialize(*snap); |
579 wait_state_ = WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION; | 593 wait_state_ = WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION; |
580 AwaitStatusChangeWithTimeout(kExponentialBackoffVerificationTimeoutMs, | 594 AwaitStatusChangeWithTimeout(kExponentialBackoffVerificationTimeoutMs, |
581 "Verify Exponential backoff"); | 595 "Verify Exponential backoff"); |
582 return (retry_verifier_.Succeeded()); | 596 return (retry_verifier_.Succeeded()); |
583 } | 597 } |
584 | 598 |
| 599 bool ProfileSyncServiceHarness::AwaitActionableError() { |
| 600 ProfileSyncService::Status status = GetStatus(); |
| 601 CHECK(status.sync_protocol_error.action == browser_sync::UNKNOWN_ACTION); |
| 602 wait_state_ = WAITING_FOR_ACTIONABLE_ERROR; |
| 603 AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, |
| 604 "Waiting for actionable error"); |
| 605 status = GetStatus(); |
| 606 return (status.sync_protocol_error.action != browser_sync::UNKNOWN_ACTION && |
| 607 service_->unrecoverable_error_detected()); |
| 608 } |
| 609 |
585 bool ProfileSyncServiceHarness::AwaitMigration( | 610 bool ProfileSyncServiceHarness::AwaitMigration( |
586 const syncable::ModelTypeSet& expected_migrated_types) { | 611 const syncable::ModelTypeSet& expected_migrated_types) { |
587 VLOG(1) << GetClientInfoString("AwaitMigration"); | 612 VLOG(1) << GetClientInfoString("AwaitMigration"); |
588 VLOG(1) << profile_debug_name_ << ": waiting until migration is done for " | 613 VLOG(1) << profile_debug_name_ << ": waiting until migration is done for " |
589 << syncable::ModelTypeSetToString(expected_migrated_types); | 614 << syncable::ModelTypeSetToString(expected_migrated_types); |
590 while (true) { | 615 while (true) { |
591 bool migration_finished = | 616 bool migration_finished = |
592 std::includes(migrated_types_.begin(), migrated_types_.end(), | 617 std::includes(migrated_types_.begin(), migrated_types_.end(), |
593 expected_migrated_types.begin(), | 618 expected_migrated_types.begin(), |
594 expected_migrated_types.end()); | 619 expected_migrated_types.end()); |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 return (synced_types.count(type) != 0); | 1065 return (synced_types.count(type) != 0); |
1041 } | 1066 } |
1042 | 1067 |
1043 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 1068 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
1044 DictionaryValue value; | 1069 DictionaryValue value; |
1045 sync_ui_util::ConstructAboutInformation(service_, &value); | 1070 sync_ui_util::ConstructAboutInformation(service_, &value); |
1046 std::string service_status; | 1071 std::string service_status; |
1047 base::JSONWriter::Write(&value, true, &service_status); | 1072 base::JSONWriter::Write(&value, true, &service_status); |
1048 return service_status; | 1073 return service_status; |
1049 } | 1074 } |
OLD | NEW |