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