Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/profile_sync_service_harness.h" | 5 #include "chrome/browser/sync/profile_sync_service_harness.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 #include <ostream> | 10 #include <ostream> |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 break; | 304 break; |
| 305 } | 305 } |
| 306 case WAITING_FOR_SYNC_CONFIGURATION: { | 306 case WAITING_FOR_SYNC_CONFIGURATION: { |
| 307 VLOG(1) << GetClientInfoString("WAITING_FOR_SYNC_CONFIGURATION"); | 307 VLOG(1) << GetClientInfoString("WAITING_FOR_SYNC_CONFIGURATION"); |
| 308 if (service()->ShouldPushChanges()) { | 308 if (service()->ShouldPushChanges()) { |
| 309 // The Datatype manager is configured and sync is fully initialized. | 309 // The Datatype manager is configured and sync is fully initialized. |
| 310 SignalStateCompleteWithNextState(FULLY_SYNCED); | 310 SignalStateCompleteWithNextState(FULLY_SYNCED); |
| 311 } | 311 } |
| 312 break; | 312 break; |
| 313 } | 313 } |
| 314 case WAITING_FOR_SYNC_DISABLED: { | |
| 315 VLOG(1) << GetClientInfoString("WAITING_FOR_SYNC_DISABLED"); | |
| 316 if (service()->HasSyncSetupCompleted() == false) { | |
| 317 // Sync has been disabled. | |
| 318 SignalStateCompleteWithNextState(SYNC_DISABLED); | |
| 319 } | |
|
tim (not reviewing)
2011/07/26 19:32:17
should have a a break; here
lipalani1
2011/07/27 01:15:22
Done.
| |
| 320 } | |
| 314 case SERVER_UNREACHABLE: { | 321 case SERVER_UNREACHABLE: { |
| 315 VLOG(1) << GetClientInfoString("SERVER_UNREACHABLE"); | 322 VLOG(1) << GetClientInfoString("SERVER_UNREACHABLE"); |
| 316 if (GetStatus().server_reachable) { | 323 if (GetStatus().server_reachable) { |
| 317 // The client was offline due to the network being disabled, but is now | 324 // The client was offline due to the network being disabled, but is now |
| 318 // back online. Wait for the pending sync cycle to complete. | 325 // back online. Wait for the pending sync cycle to complete. |
| 319 SignalStateCompleteWithNextState(WAITING_FOR_SYNC_TO_FINISH); | 326 SignalStateCompleteWithNextState(WAITING_FOR_SYNC_TO_FINISH); |
| 320 } | 327 } |
| 321 break; | 328 break; |
| 322 } | 329 } |
| 323 case SET_PASSPHRASE_FAILED: { | 330 case SET_PASSPHRASE_FAILED: { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 } else if (wait_state_ == SERVER_UNREACHABLE) { | 453 } else if (wait_state_ == SERVER_UNREACHABLE) { |
| 447 // Client is offline; sync was unsuccessful. | 454 // Client is offline; sync was unsuccessful. |
| 448 LOG(ERROR) << "Client went offline after waiting for sync to finish"; | 455 LOG(ERROR) << "Client went offline after waiting for sync to finish"; |
| 449 return false; | 456 return false; |
| 450 } else { | 457 } else { |
| 451 LOG(ERROR) << "Invalid wait state: " << wait_state_; | 458 LOG(ERROR) << "Invalid wait state: " << wait_state_; |
| 452 return false; | 459 return false; |
| 453 } | 460 } |
| 454 } | 461 } |
| 455 | 462 |
| 463 bool ProfileSyncServiceHarness::AwaitSyncDisabled(const std::string& reason) { | |
| 464 DCHECK(service()->HasSyncSetupCompleted()); | |
| 465 DCHECK(wait_state_ != SYNC_DISABLED); | |
|
tim (not reviewing)
2011/07/26 19:32:17
DCHECK_NE
lipalani1
2011/07/27 01:15:22
Done.
| |
| 466 wait_state_ = WAITING_FOR_SYNC_DISABLED; | |
| 467 AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason); | |
| 468 if (wait_state_ == SYNC_DISABLED) { | |
|
tim (not reviewing)
2011/07/26 19:32:17
this would be clearer as return wait_state_ == SYN
lipalani1
2011/07/27 01:15:22
Done.
| |
| 469 return true; | |
| 470 } else { | |
| 471 return false; | |
| 472 } | |
| 473 } | |
| 474 | |
| 456 bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion( | 475 bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion( |
| 457 ProfileSyncServiceHarness* partner) { | 476 ProfileSyncServiceHarness* partner) { |
| 458 VLOG(1) << GetClientInfoString("AwaitMutualSyncCycleCompletion"); | 477 VLOG(1) << GetClientInfoString("AwaitMutualSyncCycleCompletion"); |
| 459 if (!AwaitSyncCycleCompletion("Sync cycle completion on active client.")) | 478 if (!AwaitSyncCycleCompletion("Sync cycle completion on active client.")) |
| 460 return false; | 479 return false; |
| 461 return partner->WaitUntilTimestampMatches(this, | 480 return partner->WaitUntilTimestampMatches(this, |
| 462 "Sync cycle completion on passive client."); | 481 "Sync cycle completion on passive client."); |
| 463 } | 482 } |
| 464 | 483 |
| 465 bool ProfileSyncServiceHarness::AwaitGroupSyncCycleCompletion( | 484 bool ProfileSyncServiceHarness::AwaitGroupSyncCycleCompletion( |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 808 return true; | 827 return true; |
| 809 } | 828 } |
| 810 | 829 |
| 811 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 830 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
| 812 DictionaryValue value; | 831 DictionaryValue value; |
| 813 sync_ui_util::ConstructAboutInformation(service_, &value); | 832 sync_ui_util::ConstructAboutInformation(service_, &value); |
| 814 std::string service_status; | 833 std::string service_status; |
| 815 base::JSONWriter::Write(&value, true, &service_status); | 834 base::JSONWriter::Write(&value, true, &service_status); |
| 816 return service_status; | 835 return service_status; |
| 817 } | 836 } |
| OLD | NEW |