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 "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 file_change, local_path, url)); | 202 file_change, local_path, url)); |
203 syncer->RunPreflight(SyncTaskToken::CreateForTesting( | 203 syncer->RunPreflight(SyncTaskToken::CreateForTesting( |
204 CreateResultReceiver(&status))); | 204 CreateResultReceiver(&status))); |
205 base::RunLoop().RunUntilIdle(); | 205 base::RunLoop().RunUntilIdle(); |
206 if (status == SYNC_STATUS_OK) | 206 if (status == SYNC_STATUS_OK) |
207 remote_change_processor_->ClearLocalChanges(url); | 207 remote_change_processor_->ClearLocalChanges(url); |
208 return status; | 208 return status; |
209 } | 209 } |
210 | 210 |
211 void RunRemoteToLocalSyncerUntilIdle() { | 211 void RunRemoteToLocalSyncerUntilIdle() { |
212 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 212 const int kRetryLimit = 100; |
213 while (status != SYNC_STATUS_NO_CHANGE_TO_SYNC) | 213 SyncStatusCode status; |
| 214 int retry_count = 0; |
| 215 MetadataDatabase* metadata_database = context_->GetMetadataDatabase(); |
| 216 do { |
| 217 if (retry_count++ > kRetryLimit) |
| 218 break; |
214 status = RunRemoteToLocalSyncer(); | 219 status = RunRemoteToLocalSyncer(); |
| 220 } while (status == SYNC_STATUS_OK || |
| 221 status == SYNC_STATUS_RETRY || |
| 222 metadata_database->PromoteLowerPriorityTrackersToNormal()); |
| 223 EXPECT_EQ(SYNC_STATUS_NO_CHANGE_TO_SYNC, status); |
215 } | 224 } |
216 | 225 |
217 SyncStatusCode RunConflictResolver() { | 226 SyncStatusCode RunConflictResolver() { |
218 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 227 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
219 ConflictResolver resolver(context_.get()); | 228 ConflictResolver resolver(context_.get()); |
220 resolver.RunPreflight(SyncTaskToken::CreateForTesting( | 229 resolver.RunPreflight(SyncTaskToken::CreateForTesting( |
221 CreateResultReceiver(&status))); | 230 CreateResultReceiver(&status))); |
222 base::RunLoop().RunUntilIdle(); | 231 base::RunLoop().RunUntilIdle(); |
223 return status; | 232 return status; |
224 } | 233 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 | 522 |
514 EXPECT_EQ(4, CountParents(file)); | 523 EXPECT_EQ(4, CountParents(file)); |
515 | 524 |
516 EXPECT_EQ(SYNC_STATUS_OK, RunConflictResolver()); | 525 EXPECT_EQ(SYNC_STATUS_OK, RunConflictResolver()); |
517 | 526 |
518 EXPECT_EQ(1, CountParents(file)); | 527 EXPECT_EQ(1, CountParents(file)); |
519 } | 528 } |
520 | 529 |
521 } // namespace drive_backend | 530 } // namespace drive_backend |
522 } // namespace sync_file_system | 531 } // namespace sync_file_system |
OLD | NEW |