| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "chrome/browser/sync/profile_sync_service.h" | 7 #include "chrome/browser/sync/profile_sync_service.h" |
| 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 9 #include "chrome/browser/sync/test/integration/retry_verifier.h" | 9 #include "chrome/browser/sync/test/integration/retry_verifier.h" |
| 10 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" | 10 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // Helper class that checks if a sync client has successfully gone through | 30 // Helper class that checks if a sync client has successfully gone through |
| 31 // exponential backoff after it encounters an error. | 31 // exponential backoff after it encounters an error. |
| 32 class ExponentialBackoffChecker : public SingleClientStatusChangeChecker { | 32 class ExponentialBackoffChecker : public SingleClientStatusChangeChecker { |
| 33 public: | 33 public: |
| 34 explicit ExponentialBackoffChecker(ProfileSyncService* pss) | 34 explicit ExponentialBackoffChecker(ProfileSyncService* pss) |
| 35 : SingleClientStatusChangeChecker(pss) { | 35 : SingleClientStatusChangeChecker(pss) { |
| 36 const SyncSessionSnapshot& snap = service()->GetLastSessionSnapshot(); | 36 const SyncSessionSnapshot& snap = service()->GetLastSessionSnapshot(); |
| 37 retry_verifier_.Initialize(snap); | 37 retry_verifier_.Initialize(snap); |
| 38 } | 38 } |
| 39 | 39 |
| 40 virtual ~ExponentialBackoffChecker() {} | 40 ~ExponentialBackoffChecker() override {} |
| 41 | 41 |
| 42 // Checks if backoff is complete. Called repeatedly each time PSS notifies | 42 // Checks if backoff is complete. Called repeatedly each time PSS notifies |
| 43 // observers of a state change. | 43 // observers of a state change. |
| 44 virtual bool IsExitConditionSatisfied() override { | 44 bool IsExitConditionSatisfied() override { |
| 45 const SyncSessionSnapshot& snap = service()->GetLastSessionSnapshot(); | 45 const SyncSessionSnapshot& snap = service()->GetLastSessionSnapshot(); |
| 46 retry_verifier_.VerifyRetryInterval(snap); | 46 retry_verifier_.VerifyRetryInterval(snap); |
| 47 return (retry_verifier_.done() && retry_verifier_.Succeeded()); | 47 return (retry_verifier_.done() && retry_verifier_.Succeeded()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual std::string GetDebugMessage() const override { | 50 std::string GetDebugMessage() const override { |
| 51 return base::StringPrintf("Verifying backoff intervals (%d/%d)", | 51 return base::StringPrintf("Verifying backoff intervals (%d/%d)", |
| 52 retry_verifier_.retry_count(), | 52 retry_verifier_.retry_count(), |
| 53 RetryVerifier::kMaxRetry); | 53 RetryVerifier::kMaxRetry); |
| 54 } | 54 } |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 // Keeps track of the number of attempts at exponential backoff and its | 57 // Keeps track of the number of attempts at exponential backoff and its |
| 58 // related bookkeeping information for verification. | 58 // related bookkeeping information for verification. |
| 59 RetryVerifier retry_verifier_; | 59 RetryVerifier retry_verifier_; |
| 60 | 60 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 // Verify that the client goes into exponential backoff while it is unable to | 102 // Verify that the client goes into exponential backoff while it is unable to |
| 103 // reach the sync server. | 103 // reach the sync server. |
| 104 ExponentialBackoffChecker exponential_backoff_checker( | 104 ExponentialBackoffChecker exponential_backoff_checker( |
| 105 GetSyncService((0))); | 105 GetSyncService((0))); |
| 106 exponential_backoff_checker.Wait(); | 106 exponential_backoff_checker.Wait(); |
| 107 ASSERT_FALSE(exponential_backoff_checker.TimedOut()); | 107 ASSERT_FALSE(exponential_backoff_checker.TimedOut()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 } // namespace | 110 } // namespace |
| OLD | NEW |