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

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: Upload before commit. 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
« no previous file with comments | « chrome/browser/sync/profile_sync_service_harness.h ('k') | chrome/browser/sync/retry_verifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 914dcd0ab0d9aaf18f2b845e5ea392e51864f378..20a75efc9ec90a0505f19225f1ba5dd67913410b 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.
@@ -107,6 +111,8 @@ ProfileSyncServiceHarness::ProfileSyncServiceHarness(
}
}
+ProfileSyncServiceHarness::~ProfileSyncServiceHarness() {}
+
// static
ProfileSyncServiceHarness* ProfileSyncServiceHarness::CreateAndAttach(
Profile* profile) {
@@ -327,6 +333,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 +369,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("WAITING_FOR_NOTHING");
+ 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 +500,17 @@ bool ProfileSyncServiceHarness::AwaitSyncDisabled(const std::string& reason) {
return wait_state_ == SYNC_DISABLED;
}
+bool ProfileSyncServiceHarness::AwaitExponentialBackoffVerification() {
+ const browser_sync::sessions::SyncSessionSnapshot *snap =
+ GetLastSessionSnapshot();
+ CHECK(snap);
+ retry_verifier_.Initialize(*snap);
+ wait_state_ = WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION;
+ AwaitStatusChangeWithTimeout(kExponentialBackoffVerificationTimeoutMs,
+ "Verify Exponential backoff");
+ return (retry_verifier_.Succeeded());
+}
+
bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion(
ProfileSyncServiceHarness* partner) {
VLOG(1) << GetClientInfoString("AwaitMutualSyncCycleCompletion");
« no previous file with comments | « chrome/browser/sync/profile_sync_service_harness.h ('k') | chrome/browser/sync/retry_verifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698