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

Side by Side Diff: chrome/browser/sync/test/integration/status_change_checker.cc

Issue 2379433002: [Sync] Refactoring of sync integration test checkers to remove boilerplate await methods. (Closed)
Patch Set: Rebase Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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 #include "chrome/browser/sync/test/integration/status_change_checker.h" 5 #include "chrome/browser/sync/test/integration/status_change_checker.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
11 11
12 StatusChangeChecker::StatusChangeChecker() : timed_out_(false) { 12 StatusChangeChecker::StatusChangeChecker() : timed_out_(false) {}
13 }
14 13
15 StatusChangeChecker::~StatusChangeChecker() {} 14 StatusChangeChecker::~StatusChangeChecker() {}
16 15
16 bool StatusChangeChecker::Wait() {
17 if (IsExitConditionSatisfied()) {
18 DVLOG(1) << "Already satisfied: " << GetDebugMessage();
19 } else {
20 DVLOG(1) << "Blocking: " << GetDebugMessage();
21 StartBlockingWait();
22 }
23 return !TimedOut();
24 }
25
17 bool StatusChangeChecker::TimedOut() const { 26 bool StatusChangeChecker::TimedOut() const {
18 return timed_out_; 27 return timed_out_;
19 } 28 }
20 29
21 base::TimeDelta StatusChangeChecker::GetTimeoutDuration() { 30 base::TimeDelta StatusChangeChecker::GetTimeoutDuration() {
22 return base::TimeDelta::FromSeconds(45); 31 return base::TimeDelta::FromSeconds(45);
23 } 32 }
24 33
25 void StatusChangeChecker::StartBlockingWait() { 34 void StatusChangeChecker::StartBlockingWait() {
26 base::OneShotTimer timer; 35 base::OneShotTimer timer;
(...skipping 19 matching lines...) Expand all
46 DVLOG(1) << "Await -> Condition met: " << GetDebugMessage(); 55 DVLOG(1) << "Await -> Condition met: " << GetDebugMessage();
47 StopWaiting(); 56 StopWaiting();
48 } 57 }
49 } 58 }
50 59
51 void StatusChangeChecker::OnTimeout() { 60 void StatusChangeChecker::OnTimeout() {
52 DVLOG(1) << "Await -> Timed out: " << GetDebugMessage(); 61 DVLOG(1) << "Await -> Timed out: " << GetDebugMessage();
53 timed_out_ = true; 62 timed_out_ = true;
54 StopWaiting(); 63 StopWaiting();
55 } 64 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/status_change_checker.h ('k') | chrome/browser/sync/test/integration/sync_auth_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698