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

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

Issue 165393010: Draft: Moving code out of ProfileSyncServiceHarness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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 #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
12 class ProfileSyncServiceObserver;
13
10 // 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
11 // 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
12 // integration tests. 16 // integration tests.
13 // 17 //
14 // 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
15 // must implement a concrete StatusChangeChecker object and pass it to 19 // must implement a concrete StatusChangeChecker object and pass it to
16 // ProfileSyncServiceHarness::AwaitStatusChange(). 20 // ProfileSyncServiceHarness::AwaitStatusChange().
17 class StatusChangeChecker { 21 class StatusChangeChecker {
18 public: 22 public:
19 explicit StatusChangeChecker(const std::string& source); 23 explicit StatusChangeChecker();
20 24
21 // Called every time ProfileSyncServiceHarness is notified of a change in the 25 // Called every time ProfileSyncServiceHarness is notified of a change in the
22 // state of the sync engine. Returns true if the desired change has occurred. 26 // state of the sync engine. Returns true if the desired change has occurred.
23 virtual bool IsExitConditionSatisfied() = 0; 27 virtual bool IsExitConditionSatisfied() = 0;
24 28
25 std::string source() const { return source_; } 29 // Returns a string representing this current StatusChangeChecker, and
30 // possibly some small part of its state. For example: "AwaitPassphraseError"
31 // or "AwaitMigrationDone(BOOKMARKS)".
32 virtual std::string GetDebugMessage() const = 0;
33
34 // The maximum length of time to wait for this operation before timing out.
35 virtual base::TimeDelta GetTimeoutDuration() = 0;
36
37 virtual void InitObserver(ProfileSyncServiceObserver*) = 0;
38 virtual void UninitObserver(ProfileSyncServiceObserver*) = 0;
39
40 // Exposed only for the StatusChangeCheckerRunner. Please don't call this.
41 void set_is_waiting(bool value);
42
43 // Runs the StatusChangeChecker to completion.
44 static bool Run(StatusChangeChecker* checker);
26 45
27 protected: 46 protected:
28 virtual ~StatusChangeChecker(); 47 virtual ~StatusChangeChecker();
29 48
49 // Returns true if the 'wait' is in progress.
50 bool IsWaiting();
51
52 // Asks that we stop waiting and return a successfully. (ie. Don't time out).
53 void StopWaitingAndSucceed();
54
30 private: 55 private:
31 // Used for logging / debugging. Can be used to hold the name of the internal 56 bool is_waiting_;
32 // function called by IsExitConditionSatisfied. Logged along with select info
33 // when ProfileSyncServiceHarness observes a change in ProfileSyncService.
34 std::string source_;
35 }; 57 };
36 58
37 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_ 59 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_STATUS_CHANGE_CHECKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698