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
3 // found in the LICENSE file.
5 #include "chrome/browser/sync/test/integration/status_change_checker.h"
7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/timer/timer.h"
11 StatusChangeChecker::StatusChangeChecker() : timed_out_(false) {
14 StatusChangeChecker::~StatusChangeChecker() {}
16 bool StatusChangeChecker::TimedOut() const {
20 base::TimeDelta StatusChangeChecker::GetTimeoutDuration() {
21 return base::TimeDelta::FromSeconds(45);
24 void StatusChangeChecker::StartBlockingWait() {
25 base::OneShotTimer<StatusChangeChecker> timer;
26 timer.Start(FROM_HERE,
28 base::Bind(&StatusChangeChecker::OnTimeout,
29 base::Unretained(this)));
32 base::MessageLoop* loop = base::MessageLoop::current();
33 base::MessageLoop::ScopedNestableTaskAllower allow(loop);
38 void StatusChangeChecker::StopWaiting() {
39 base::MessageLoop::current()->QuitWhenIdle();
42 void StatusChangeChecker::CheckExitCondition() {
43 DVLOG(1) << "Await -> Checking Condition: " << GetDebugMessage();
44 if (IsExitConditionSatisfied()) {
45 DVLOG(1) << "Await -> Condition met: " << GetDebugMessage();
50 void StatusChangeChecker::OnTimeout() {
51 DVLOG(1) << "Await -> Timed out: " << GetDebugMessage();