Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2199)

Unified Diff: chrome/browser/sync/test/integration/status_change_checker.h

Issue 299843007: sync: Refactor StatusChangeChecker hierarchy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/test/integration/status_change_checker.h
diff --git a/chrome/browser/sync/test/integration/status_change_checker.h b/chrome/browser/sync/test/integration/status_change_checker.h
index 9f8c10867d689052c880a6dce17cd208a19f8e59..ac136e5f8ef3f623a7d003f7442f1f46438f46eb 100644
--- a/chrome/browser/sync/test/integration/status_change_checker.h
+++ b/chrome/browser/sync/test/integration/status_change_checker.h
@@ -7,30 +7,58 @@
#include <string>
+#include "base/time/time.h"
+
class ProfileSyncServiceHarness;
-// Interface for a helper class that can be used to check if a desired change in
-// the state of the sync engine has taken place. Used by the desktop sync
-// integration tests.
+// Interface for a helper class that can pump the message loop while waiting
+// for a certain state transition to take place.
+//
+// This is a template that should be filled in by child classes so they can
+// observe specific kinds of changes and await specific conditions.
//
-// Usage: Tests that want to use this class to wait for an arbitrary sync state
-// must implement a concrete StatusChangeChecker object and pass it to
-// ProfileSyncServiceHarness::AwaitStatusChange().
+// The instances of this class are intended to be single-use. It doesn't make
+// sense to call StartBlockingWait() more than once.
class StatusChangeChecker {
public:
explicit StatusChangeChecker();
- // Called every time ProfileSyncServiceHarness is notified of a change in the
- // state of the sync engine. Returns true if the desired change has occurred.
- virtual bool IsExitConditionSatisfied() = 0;
-
// Returns a string representing this current StatusChangeChecker, and
// possibly some small part of its state. For example: "AwaitPassphraseError"
// or "AwaitMigrationDone(BOOKMARKS)".
virtual std::string GetDebugMessage() const = 0;
+ // Returns true if the blocking wait was exited because of a timeout.
+ bool TimedOut() const;
+
+ virtual bool IsExitConditionSatisfied() = 0;
+
protected:
virtual ~StatusChangeChecker();
+
+ // Timeout length when blocking.
+ virtual base::TimeDelta GetTimeoutDuration();
+
+ // Helper function to start running the nested message loop.
+ //
+ // Will exit if IsExitConditionSatisfied() returns true when called from
+ // CheckExitCondition(), if a timeout occurs, or if StopWaiting() is called.
+ //
+ // The timeout length is specified with GetTimeoutDuration().
+ void StartBlockingWait();
+
+ // Stop the nested running of the message loop started in StartBlockingWait().
+ void StopWaiting();
+
+ // Checks IsExitConditionSatisfied() and calls StopWaiting() if it returns
+ // true.
+ void CheckExitCondition();
+
+ // Called when the blocking wait timeout is exceeded.
+ void OnTimeout();
+
+ bool timed_out_;
+ bool wait_started_;
};
#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_

Powered by Google App Engine
This is Rietveld 408576698