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 10 matching lines...) Expand all Loading... | |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/sync/sessions/session_state.h" | 22 #include "chrome/browser/sync/sessions/session_state.h" |
23 #include "chrome/browser/sync/signin_manager.h" | 23 #include "chrome/browser/sync/signin_manager.h" |
24 #include "chrome/browser/sync/sync_ui_util.h" | 24 #include "chrome/browser/sync/sync_ui_util.h" |
25 | 25 |
26 using browser_sync::sessions::SyncSessionSnapshot; | 26 using browser_sync::sessions::SyncSessionSnapshot; |
27 | 27 |
28 // The amount of time for which we wait for a live sync operation to complete. | 28 // The amount of time for which we wait for a live sync operation to complete. |
29 static const int kLiveSyncOperationTimeoutMs = 45000; | 29 static const int kLiveSyncOperationTimeoutMs = 45000; |
30 | 30 |
31 // The amount of time we wait for testcases that verify exponential backoff. | |
32 static const int kExponentialBackoffVerificationTimeoutMs = 60000; | |
Raghu Simha
2011/08/05 18:04:52
Ideally, you should use the pre-defined values in
Raghu Simha
2011/08/05 18:04:52
Curious: Why 60 seconds and not 45 seconds? (or 90
lipalani1
2011/08/05 21:33:57
If you add up all the max retry values for 4 retri
lipalani1
2011/08/05 21:33:57
Added a todo here.
On 2011/08/05 18:04:52, rsimha
| |
33 | |
31 // Simple class to implement a timeout using PostDelayedTask. If it is not | 34 // Simple class to implement a timeout using PostDelayedTask. If it is not |
32 // aborted before picked up by a message queue, then it asserts with the message | 35 // aborted before picked up by a message queue, then it asserts with the message |
33 // provided. This class is not thread safe. | 36 // provided. This class is not thread safe. |
34 class StateChangeTimeoutEvent | 37 class StateChangeTimeoutEvent |
35 : public base::RefCountedThreadSafe<StateChangeTimeoutEvent> { | 38 : public base::RefCountedThreadSafe<StateChangeTimeoutEvent> { |
36 public: | 39 public: |
37 StateChangeTimeoutEvent(ProfileSyncServiceHarness* caller, | 40 StateChangeTimeoutEvent(ProfileSyncServiceHarness* caller, |
38 const std::string& message); | 41 const std::string& message); |
39 | 42 |
40 // The entry point to the class from PostDelayedTask. | 43 // The entry point to the class from PostDelayedTask. |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 break; | 323 break; |
321 } | 324 } |
322 case WAITING_FOR_SYNC_DISABLED: { | 325 case WAITING_FOR_SYNC_DISABLED: { |
323 VLOG(1) << GetClientInfoString("WAITING_FOR_SYNC_DISABLED"); | 326 VLOG(1) << GetClientInfoString("WAITING_FOR_SYNC_DISABLED"); |
324 if (service()->HasSyncSetupCompleted() == false) { | 327 if (service()->HasSyncSetupCompleted() == false) { |
325 // Sync has been disabled. | 328 // Sync has been disabled. |
326 SignalStateCompleteWithNextState(SYNC_DISABLED); | 329 SignalStateCompleteWithNextState(SYNC_DISABLED); |
327 } | 330 } |
328 break; | 331 break; |
329 } | 332 } |
333 case WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION: { | |
Raghu Simha
2011/08/05 18:04:52
VLOG(1) << GetClientInfoString("WAITING_FOR_EXPONE
lipalani1
2011/08/05 21:33:57
Done.
| |
334 if (retry_verifier_.VerifyRetryInterval(*GetLastSessionSnapshot()) | |
335 == false) { | |
336 SignalStateCompleteWithNextState( | |
337 EXPONENTIAL_BACKOFF_VERIFICATION_FAILED); | |
Raghu Simha
2011/08/05 18:04:52
The next state should be one of the "there is noth
lipalani1
2011/08/05 21:33:57
Done.
| |
338 } else { | |
339 // We only verify the first 5 retries. | |
340 if (retry_verifier_.RetryCount() >= 5) { | |
341 SignalStateCompleteWithNextState( | |
342 EXPONENTIAL_BACKOFF_VERIFICATION_SUCEEDED); | |
Raghu Simha
2011/08/05 18:04:52
The next state should be one of the "there is noth
lipalani1
2011/08/05 21:33:57
Done.
| |
343 } | |
344 } | |
345 } | |
346 break; | |
Raghu Simha
2011/08/05 18:04:52
The break statement goes inside the brace just abo
lipalani1
2011/08/05 21:33:57
Done.
| |
330 case SERVER_UNREACHABLE: { | 347 case SERVER_UNREACHABLE: { |
331 VLOG(1) << GetClientInfoString("SERVER_UNREACHABLE"); | 348 VLOG(1) << GetClientInfoString("SERVER_UNREACHABLE"); |
332 if (GetStatus().server_reachable) { | 349 if (GetStatus().server_reachable) { |
333 // The client was offline due to the network being disabled, but is now | 350 // The client was offline due to the network being disabled, but is now |
334 // back online. Wait for the pending sync cycle to complete. | 351 // back online. Wait for the pending sync cycle to complete. |
335 SignalStateCompleteWithNextState(WAITING_FOR_SYNC_TO_FINISH); | 352 SignalStateCompleteWithNextState(WAITING_FOR_SYNC_TO_FINISH); |
336 } | 353 } |
337 break; | 354 break; |
338 } | 355 } |
339 case SET_PASSPHRASE_FAILED: { | 356 case SET_PASSPHRASE_FAILED: { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 } | 487 } |
471 | 488 |
472 bool ProfileSyncServiceHarness::AwaitSyncDisabled(const std::string& reason) { | 489 bool ProfileSyncServiceHarness::AwaitSyncDisabled(const std::string& reason) { |
473 DCHECK(service()->HasSyncSetupCompleted()); | 490 DCHECK(service()->HasSyncSetupCompleted()); |
474 DCHECK_NE(wait_state_, SYNC_DISABLED); | 491 DCHECK_NE(wait_state_, SYNC_DISABLED); |
475 wait_state_ = WAITING_FOR_SYNC_DISABLED; | 492 wait_state_ = WAITING_FOR_SYNC_DISABLED; |
476 AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason); | 493 AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason); |
477 return wait_state_ == SYNC_DISABLED; | 494 return wait_state_ == SYNC_DISABLED; |
478 } | 495 } |
479 | 496 |
497 bool ProfileSyncServiceHarness::AwaitExponentialBackoffVerification() { | |
498 retry_verifier_.Initialize(*GetLastSessionSnapshot()); | |
499 wait_state_ = WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION; | |
500 AwaitStatusChangeWithTimeout(kExponentialBackoffVerificationTimeoutMs, | |
501 "Verify Exponential backoff"); | |
502 return (wait_state_ == EXPONENTIAL_BACKOFF_VERIFICATION_SUCEEDED); | |
Raghu Simha
2011/08/05 18:04:52
return (retry_verifier_.RetryCount() >= 5);
lipalani1
2011/08/05 21:33:57
Done as we discussed.
On 2011/08/05 18:04:52, rsim
| |
503 } | |
504 | |
480 bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion( | 505 bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion( |
481 ProfileSyncServiceHarness* partner) { | 506 ProfileSyncServiceHarness* partner) { |
482 VLOG(1) << GetClientInfoString("AwaitMutualSyncCycleCompletion"); | 507 VLOG(1) << GetClientInfoString("AwaitMutualSyncCycleCompletion"); |
483 if (!AwaitSyncCycleCompletion("Sync cycle completion on active client.")) | 508 if (!AwaitSyncCycleCompletion("Sync cycle completion on active client.")) |
484 return false; | 509 return false; |
485 return partner->WaitUntilTimestampMatches(this, | 510 return partner->WaitUntilTimestampMatches(this, |
486 "Sync cycle completion on passive client."); | 511 "Sync cycle completion on passive client."); |
487 } | 512 } |
488 | 513 |
489 bool ProfileSyncServiceHarness::AwaitGroupSyncCycleCompletion( | 514 bool ProfileSyncServiceHarness::AwaitGroupSyncCycleCompletion( |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
832 return true; | 857 return true; |
833 } | 858 } |
834 | 859 |
835 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 860 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
836 DictionaryValue value; | 861 DictionaryValue value; |
837 sync_ui_util::ConstructAboutInformation(service_, &value); | 862 sync_ui_util::ConstructAboutInformation(service_, &value); |
838 std::string service_status; | 863 std::string service_status; |
839 base::JSONWriter::Write(&value, true, &service_status); | 864 base::JSONWriter::Write(&value, true, &service_status); |
840 return service_status; | 865 return service_status; |
841 } | 866 } |
OLD | NEW |