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

Unified Diff: chrome/browser/sync/profile_sync_service_harness.cc

Issue 7477004: Simulate transient error and verify exponential backoff. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/profile_sync_service_harness.cc
diff --git a/chrome/browser/sync/profile_sync_service_harness.cc b/chrome/browser/sync/profile_sync_service_harness.cc
index d2fb640cb77d0fde11ff636d7c3f41ad9ec997c6..522bd1f7cb59ca49dd947d52df41e2ef5e00dfc9 100644
--- a/chrome/browser/sync/profile_sync_service_harness.cc
+++ b/chrome/browser/sync/profile_sync_service_harness.cc
@@ -25,9 +25,13 @@
using browser_sync::sessions::SyncSessionSnapshot;
+// TODO(rsimha): Remove the following lines once crbug.com/91863 is fixed.
// The amount of time for which we wait for a live sync operation to complete.
static const int kLiveSyncOperationTimeoutMs = 45000;
+// The amount of time we wait for test cases that verify exponential backoff.
+static const int kExponentialBackoffVerificationTimeoutMs = 60000;
+
// Simple class to implement a timeout using PostDelayedTask. If it is not
// aborted before picked up by a message queue, then it asserts with the message
// provided. This class is not thread safe.
@@ -327,6 +331,17 @@ bool ProfileSyncServiceHarness::RunStateChangeMachine() {
}
break;
}
+ case WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION: {
+ VLOG(1) << GetClientInfoString(
+ "WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION");
+ const browser_sync::sessions::SyncSessionSnapshot *snap =
+ GetLastSessionSnapshot();
+ CHECK(snap);
+ retry_verifier_.VerifyRetryInterval(*snap);
+ if (retry_verifier_.Done())
+ SignalStateCompleteWithNextState(WAITING_FOR_NOTHING);
+ break;
+ }
case SERVER_UNREACHABLE: {
VLOG(1) << GetClientInfoString("SERVER_UNREACHABLE");
if (GetStatus().server_reachable) {
@@ -352,6 +367,12 @@ bool ProfileSyncServiceHarness::RunStateChangeMachine() {
VLOG(1) << GetClientInfoString("SYNC_DISABLED");
break;
}
+ case WAITING_FOR_NOTHING: {
+ // We don't care about the state of the syncer for the rest of the test
+ // case.
+ VLOG(1) << GetClientInfoString("WAIT_FOR_NOTHING");
Raghu Simha 2011/08/05 23:23:58 s/WAIT_FOR_NOTHING/WAITING_FOR_NOTHING/
lipalani1 2011/08/09 01:39:02 Done.
+ break;
+ }
default:
// Invalid state during observer callback which may be triggered by other
// classes using the the UI message loop. Defer to their handling.
@@ -477,6 +498,14 @@ bool ProfileSyncServiceHarness::AwaitSyncDisabled(const std::string& reason) {
return wait_state_ == SYNC_DISABLED;
}
+bool ProfileSyncServiceHarness::AwaitExponentialBackoffVerification() {
+ retry_verifier_.Initialize(*GetLastSessionSnapshot());
+ wait_state_ = WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION;
+ AwaitStatusChangeWithTimeout(kExponentialBackoffVerificationTimeoutMs,
+ "Verify Exponential backoff");
+ return (retry_verifier_.Success());
+}
+
bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion(
ProfileSyncServiceHarness* partner) {
VLOG(1) << GetClientInfoString("AwaitMutualSyncCycleCompletion");

Powered by Google App Engine
This is Rietveld 408576698