| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sync/engine/backoff_delay_provider.h" | 5 #include "sync/engine/backoff_delay_provider.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "sync/internal_api/public/engine/polling_constants.h" | 9 #include "sync/internal_api/public/engine/polling_constants.h" |
| 10 #include "sync/internal_api/public/sessions/model_neutral_state.h" | 10 #include "sync/internal_api/public/sessions/model_neutral_state.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 delay->GetInitialDelay(state).InSeconds()); | 50 delay->GetInitialDelay(state).InSeconds()); |
| 51 | 51 |
| 52 state.last_download_updates_result = SERVER_RETURN_TRANSIENT_ERROR; | 52 state.last_download_updates_result = SERVER_RETURN_TRANSIENT_ERROR; |
| 53 EXPECT_EQ(kInitialBackoffRetrySeconds, | 53 EXPECT_EQ(kInitialBackoffRetrySeconds, |
| 54 delay->GetInitialDelay(state).InSeconds()); | 54 delay->GetInitialDelay(state).InSeconds()); |
| 55 | 55 |
| 56 state.last_download_updates_result = SERVER_RESPONSE_VALIDATION_FAILED; | 56 state.last_download_updates_result = SERVER_RESPONSE_VALIDATION_FAILED; |
| 57 EXPECT_EQ(kInitialBackoffRetrySeconds, | 57 EXPECT_EQ(kInitialBackoffRetrySeconds, |
| 58 delay->GetInitialDelay(state).InSeconds()); | 58 delay->GetInitialDelay(state).InSeconds()); |
| 59 | 59 |
| 60 state.last_download_updates_result = DATATYPE_TRIGGERED_RETRY; |
| 61 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, |
| 62 delay->GetInitialDelay(state).InSeconds()); |
| 63 |
| 60 state.last_download_updates_result = SYNCER_OK; | 64 state.last_download_updates_result = SYNCER_OK; |
| 61 // Note that updating credentials triggers a canary job, trumping | 65 // Note that updating credentials triggers a canary job, trumping |
| 62 // the initial delay, but in theory we still expect this function to treat | 66 // the initial delay, but in theory we still expect this function to treat |
| 63 // it like any other error in the system (except migration). | 67 // it like any other error in the system (except migration). |
| 64 state.commit_result = SERVER_RETURN_INVALID_CREDENTIAL; | 68 state.commit_result = SERVER_RETURN_INVALID_CREDENTIAL; |
| 65 EXPECT_EQ(kInitialBackoffRetrySeconds, | 69 EXPECT_EQ(kInitialBackoffRetrySeconds, |
| 66 delay->GetInitialDelay(state).InSeconds()); | 70 delay->GetInitialDelay(state).InSeconds()); |
| 67 | 71 |
| 68 state.commit_result = SERVER_RETURN_MIGRATION_DONE; | 72 state.commit_result = SERVER_RETURN_MIGRATION_DONE; |
| 69 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, | 73 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 92 delay->GetInitialDelay(state).InSeconds()); | 96 delay->GetInitialDelay(state).InSeconds()); |
| 93 | 97 |
| 94 state.last_download_updates_result = SERVER_RETURN_TRANSIENT_ERROR; | 98 state.last_download_updates_result = SERVER_RETURN_TRANSIENT_ERROR; |
| 95 EXPECT_EQ(kInitialBackoffShortRetrySeconds, | 99 EXPECT_EQ(kInitialBackoffShortRetrySeconds, |
| 96 delay->GetInitialDelay(state).InSeconds()); | 100 delay->GetInitialDelay(state).InSeconds()); |
| 97 | 101 |
| 98 state.last_download_updates_result = SERVER_RESPONSE_VALIDATION_FAILED; | 102 state.last_download_updates_result = SERVER_RESPONSE_VALIDATION_FAILED; |
| 99 EXPECT_EQ(kInitialBackoffShortRetrySeconds, | 103 EXPECT_EQ(kInitialBackoffShortRetrySeconds, |
| 100 delay->GetInitialDelay(state).InSeconds()); | 104 delay->GetInitialDelay(state).InSeconds()); |
| 101 | 105 |
| 106 state.last_download_updates_result = DATATYPE_TRIGGERED_RETRY; |
| 107 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, |
| 108 delay->GetInitialDelay(state).InSeconds()); |
| 109 |
| 102 state.last_download_updates_result = SYNCER_OK; | 110 state.last_download_updates_result = SYNCER_OK; |
| 103 // Note that updating credentials triggers a canary job, trumping | 111 // Note that updating credentials triggers a canary job, trumping |
| 104 // the initial delay, but in theory we still expect this function to treat | 112 // the initial delay, but in theory we still expect this function to treat |
| 105 // it like any other error in the system (except migration). | 113 // it like any other error in the system (except migration). |
| 106 state.commit_result = SERVER_RETURN_INVALID_CREDENTIAL; | 114 state.commit_result = SERVER_RETURN_INVALID_CREDENTIAL; |
| 107 EXPECT_EQ(kInitialBackoffShortRetrySeconds, | 115 EXPECT_EQ(kInitialBackoffShortRetrySeconds, |
| 108 delay->GetInitialDelay(state).InSeconds()); | 116 delay->GetInitialDelay(state).InSeconds()); |
| 109 | 117 |
| 110 state.commit_result = SERVER_RETURN_MIGRATION_DONE; | 118 state.commit_result = SERVER_RETURN_MIGRATION_DONE; |
| 111 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, | 119 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, |
| 112 delay->GetInitialDelay(state).InSeconds()); | 120 delay->GetInitialDelay(state).InSeconds()); |
| 113 | 121 |
| 114 state.commit_result = SERVER_RETURN_CONFLICT; | 122 state.commit_result = SERVER_RETURN_CONFLICT; |
| 115 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, | 123 EXPECT_EQ(kInitialBackoffImmediateRetrySeconds, |
| 116 delay->GetInitialDelay(state).InSeconds()); | 124 delay->GetInitialDelay(state).InSeconds()); |
| 117 } | 125 } |
| 118 | 126 |
| 119 } // namespace syncer | 127 } // namespace syncer |
| OLD | NEW |