Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_ |
| 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_ | 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/time/time.h" | |
| 11 | |
| 10 class ProfileSyncServiceHarness; | 12 class ProfileSyncServiceHarness; |
| 11 | 13 |
| 12 // Interface for a helper class that can be used to check if a desired change in | 14 // Interface for a helper class that can be used to check if a desired change in |
| 13 // the state of the sync engine has taken place. Used by the desktop sync | 15 // the state of the sync engine has taken place. Used by the desktop sync |
| 14 // integration tests. | 16 // integration tests. |
| 15 // | 17 // |
| 16 // Usage: Tests that want to use this class to wait for an arbitrary sync state | 18 // Usage: Tests that want to use this class to wait for an arbitrary sync state |
| 17 // must implement a concrete StatusChangeChecker object and pass it to | 19 // must implement a concrete StatusChangeChecker object and pass it to |
| 18 // ProfileSyncServiceHarness::AwaitStatusChange(). | 20 // ProfileSyncServiceHarness::AwaitStatusChange(). |
| 19 class StatusChangeChecker { | 21 class StatusChangeChecker { |
| 20 public: | 22 public: |
| 21 explicit StatusChangeChecker(); | 23 explicit StatusChangeChecker(); |
| 22 | 24 |
| 23 // Called every time ProfileSyncServiceHarness is notified of a change in the | |
| 24 // state of the sync engine. Returns true if the desired change has occurred. | |
| 25 virtual bool IsExitConditionSatisfied() = 0; | |
| 26 | |
| 27 // Returns a string representing this current StatusChangeChecker, and | 25 // Returns a string representing this current StatusChangeChecker, and |
| 28 // possibly some small part of its state. For example: "AwaitPassphraseError" | 26 // possibly some small part of its state. For example: "AwaitPassphraseError" |
| 29 // or "AwaitMigrationDone(BOOKMARKS)". | 27 // or "AwaitMigrationDone(BOOKMARKS)". |
| 30 virtual std::string GetDebugMessage() const = 0; | 28 virtual std::string GetDebugMessage() const = 0; |
| 31 | 29 |
| 30 // Returns true if the blocking wait was exited because of a timeout. | |
| 31 bool TimedOut() const; | |
| 32 | |
| 33 virtual bool IsExitConditionSatisfied() = 0; | |
| 34 | |
| 32 protected: | 35 protected: |
| 33 virtual ~StatusChangeChecker(); | 36 virtual ~StatusChangeChecker(); |
| 37 | |
| 38 // Timeout length when blocking. Default is 45s. | |
|
pval...(no longer on Chromium)
2014/05/22 21:07:12
"Default is 45s." doesn't seem very future proof.
rlarocque
2014/05/22 21:29:30
Done.
| |
| 39 virtual base::TimeDelta GetTimeoutDuration(); | |
| 40 | |
| 41 // Helper function to start running the nested message loop. | |
| 42 // | |
| 43 // Will exit if IsExitConditionSatisfied() returns true when called from | |
| 44 // CheckExitCondition(), if a timeout occurs, or if Unblock() is called. | |
| 45 // | |
| 46 // The timeout length is specified with GetTimeoutDuration(). | |
| 47 void StartBlockingWait(); | |
| 48 | |
| 49 // Stop the nested running of the message loop started in StartBlockingWait(). | |
| 50 void Unblock(); | |
|
pval...(no longer on Chromium)
2014/05/22 21:07:12
is StopBlockingWait() or StopWaiting() a better na
rlarocque
2014/05/22 21:29:30
Done. Changed name to StopWaiting().
| |
| 51 | |
| 52 // Checks IsExitConditionSatisfied() and calls Unblock() if it returns true. | |
| 53 void CheckExitCondition(); | |
| 54 | |
| 55 // Called when the blocking wait timeout is exceeded. | |
| 56 void OnTimeout(); | |
| 57 | |
| 58 bool timed_out_; | |
| 59 bool wait_started_; | |
| 34 }; | 60 }; |
| 35 | 61 |
| 36 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_ | 62 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_ |
| OLD | NEW |