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

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: Fixing a typo. Created 9 years, 5 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..1935995861704e4d2a4f5e7eea86446b6f72e98c 100644
--- a/chrome/browser/sync/profile_sync_service_harness.cc
+++ b/chrome/browser/sync/profile_sync_service_harness.cc
@@ -28,6 +28,9 @@ using browser_sync::sessions::SyncSessionSnapshot;
// 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 testcases that verify exponential backoff.
+static const int kExponentialBackoffVerificationTimeoutMs = 60000;
Raghu Simha 2011/08/05 18:04:52 Ideally, you should use the pre-defined values in
Raghu Simha 2011/08/05 18:04:52 Curious: Why 60 seconds and not 45 seconds? (or 90
lipalani1 2011/08/05 21:33:57 If you add up all the max retry values for 4 retri
lipalani1 2011/08/05 21:33:57 Added a todo here. On 2011/08/05 18:04:52, rsimha
+
// 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 +330,20 @@ bool ProfileSyncServiceHarness::RunStateChangeMachine() {
}
break;
}
+ case WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION: {
Raghu Simha 2011/08/05 18:04:52 VLOG(1) << GetClientInfoString("WAITING_FOR_EXPONE
lipalani1 2011/08/05 21:33:57 Done.
+ if (retry_verifier_.VerifyRetryInterval(*GetLastSessionSnapshot())
+ == false) {
+ SignalStateCompleteWithNextState(
+ EXPONENTIAL_BACKOFF_VERIFICATION_FAILED);
Raghu Simha 2011/08/05 18:04:52 The next state should be one of the "there is noth
lipalani1 2011/08/05 21:33:57 Done.
+ } else {
+ // We only verify the first 5 retries.
+ if (retry_verifier_.RetryCount() >= 5) {
+ SignalStateCompleteWithNextState(
+ EXPONENTIAL_BACKOFF_VERIFICATION_SUCEEDED);
Raghu Simha 2011/08/05 18:04:52 The next state should be one of the "there is noth
lipalani1 2011/08/05 21:33:57 Done.
+ }
+ }
+ }
+ break;
Raghu Simha 2011/08/05 18:04:52 The break statement goes inside the brace just abo
lipalani1 2011/08/05 21:33:57 Done.
case SERVER_UNREACHABLE: {
VLOG(1) << GetClientInfoString("SERVER_UNREACHABLE");
if (GetStatus().server_reachable) {
@@ -477,6 +494,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 (wait_state_ == EXPONENTIAL_BACKOFF_VERIFICATION_SUCEEDED);
Raghu Simha 2011/08/05 18:04:52 return (retry_verifier_.RetryCount() >= 5);
lipalani1 2011/08/05 21:33:57 Done as we discussed. On 2011/08/05 18:04:52, rsim
+}
+
bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion(
ProfileSyncServiceHarness* partner) {
VLOG(1) << GetClientInfoString("AwaitMutualSyncCycleCompletion");

Powered by Google App Engine
This is Rietveld 408576698