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

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

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
« no previous file with comments | « chrome/browser/sync/test/integration/status_change_checker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/test/integration/status_change_checker.cc
diff --git a/chrome/browser/sync/test/integration/status_change_checker.cc b/chrome/browser/sync/test/integration/status_change_checker.cc
index b92b06a9abd3d7f237c9c24070384bcc3952f400..d8cbd1ad61bdf34effda864f4b3f63cb5866ca79 100644
--- a/chrome/browser/sync/test/integration/status_change_checker.cc
+++ b/chrome/browser/sync/test/integration/status_change_checker.cc
@@ -4,6 +4,55 @@
#include "chrome/browser/sync/test/integration/status_change_checker.h"
-StatusChangeChecker::StatusChangeChecker() {}
+#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
+#include "base/timer/timer.h"
+
+StatusChangeChecker::StatusChangeChecker()
+ : timed_out_(false),
+ wait_started_(false) {}
StatusChangeChecker::~StatusChangeChecker() {}
+
+bool StatusChangeChecker::TimedOut() const {
+ return timed_out_;
+}
+
+base::TimeDelta StatusChangeChecker::GetTimeoutDuration() {
+ return base::TimeDelta::FromSeconds(45);
+}
+
+void StatusChangeChecker::StartBlockingWait() {
+ DCHECK(!wait_started_) << "This class is intended for one use only.";
+ wait_started_ = true;
+
+ base::OneShotTimer<StatusChangeChecker> timer;
+ timer.Start(FROM_HERE,
+ GetTimeoutDuration(),
+ base::Bind(&StatusChangeChecker::OnTimeout,
+ base::Unretained(this)));
+
+ {
+ base::MessageLoop* loop = base::MessageLoop::current();
+ base::MessageLoop::ScopedNestableTaskAllower allow(loop);
+ loop->Run();
+ }
+}
+
+void StatusChangeChecker::StopWaiting() {
+ base::MessageLoop::current()->QuitWhenIdle();
+}
+
+void StatusChangeChecker::CheckExitCondition() {
+ DVLOG(1) << "Await -> Checking Condition: " << GetDebugMessage();
+ if (IsExitConditionSatisfied()) {
+ DVLOG(1) << "Await -> Condition met: " << GetDebugMessage();
+ StopWaiting();
+ }
+}
+
+void StatusChangeChecker::OnTimeout() {
+ DVLOG(1) << "Await -> Timed out: " << GetDebugMessage();
+ timed_out_ = true;
+ StopWaiting();
+}
« no previous file with comments | « chrome/browser/sync/test/integration/status_change_checker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698