| 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/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 #include "sync/internal_api/public/engine/polling_constants.h" | 8 #include "sync/internal_api/public/engine/polling_constants.h" |
| 9 #include "sync/internal_api/public/sessions/model_neutral_state.h" | 9 #include "sync/internal_api/public/sessions/model_neutral_state.h" |
| 10 #include "sync/internal_api/public/util/syncer_error.h" | 10 #include "sync/internal_api/public/util/syncer_error.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // Note: If we received a MIGRATION_DONE on download updates, then commit | 90 // Note: If we received a MIGRATION_DONE on download updates, then commit |
| 91 // should not have taken place. Moreover, if we receive a MIGRATION_DONE | 91 // should not have taken place. Moreover, if we receive a MIGRATION_DONE |
| 92 // on commit, it means that download updates succeeded. Therefore, we only | 92 // on commit, it means that download updates succeeded. Therefore, we only |
| 93 // need to check if either code is equal to SERVER_RETURN_MIGRATION_DONE, | 93 // need to check if either code is equal to SERVER_RETURN_MIGRATION_DONE, |
| 94 // and not if there were any more serious errors requiring the long retry. | 94 // and not if there were any more serious errors requiring the long retry. |
| 95 if (state.last_download_updates_result == SERVER_RETURN_MIGRATION_DONE || | 95 if (state.last_download_updates_result == SERVER_RETURN_MIGRATION_DONE || |
| 96 state.commit_result == SERVER_RETURN_MIGRATION_DONE) { | 96 state.commit_result == SERVER_RETURN_MIGRATION_DONE) { |
| 97 return short_initial_backoff_; | 97 return short_initial_backoff_; |
| 98 } | 98 } |
| 99 | 99 |
| 100 // If a datatype decides the GetUpdates must be retried (e.g. because the |
| 101 // context has been updated since the request), use the short delay. |
| 102 if (state.last_download_updates_result == DATATYPE_TRIGGERED_RETRY) |
| 103 return short_initial_backoff_; |
| 104 |
| 100 // When the server tells us we have a conflict, then we should download the | 105 // When the server tells us we have a conflict, then we should download the |
| 101 // latest updates so we can see the conflict ourselves, resolve it locally, | 106 // latest updates so we can see the conflict ourselves, resolve it locally, |
| 102 // then try again to commit. Running another sync cycle will do all these | 107 // then try again to commit. Running another sync cycle will do all these |
| 103 // things. There's no need to back off, we can do this immediately. | 108 // things. There's no need to back off, we can do this immediately. |
| 104 // | 109 // |
| 105 // TODO(sync): We shouldn't need to handle this in BackoffDelayProvider. | 110 // TODO(sync): We shouldn't need to handle this in BackoffDelayProvider. |
| 106 // There should be a way to deal with protocol errors before we get to this | 111 // There should be a way to deal with protocol errors before we get to this |
| 107 // point. | 112 // point. |
| 108 if (state.commit_result == SERVER_RETURN_CONFLICT) { | 113 if (state.commit_result == SERVER_RETURN_CONFLICT) |
| 109 return short_initial_backoff_; | 114 return short_initial_backoff_; |
| 110 } | |
| 111 | 115 |
| 112 return default_initial_backoff_; | 116 return default_initial_backoff_; |
| 113 } | 117 } |
| 114 | 118 |
| 115 } // namespace syncer | 119 } // namespace syncer |
| OLD | NEW |