single_client_status_change_checker.h revision effb81e5f8246d0db0270817048dc992db66e9fb
1// Copyright 2014 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.
4
5#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_SINGLE_CLIENT_STATUS_CHANGE_CHECKER_H_
6#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SINGLE_CLIENT_STATUS_CHANGE_CHECKER_H_
7
8#include "base/compiler_specific.h"
9#include "base/time/time.h"
10#include "chrome/browser/sync/profile_sync_service_observer.h"
11#include "chrome/browser/sync/test/integration/status_change_checker.h"
12
13class ProfileSyncService;
14class ProfileSyncServiceHarness;
15
16// This class provides some common functionality for StatusChangeCheckers that
17// observe only one ProfileSyncService.  This class is abstract.  Its
18// descendants are expected to provide additional functionality.
19class SingleClientStatusChangeChecker
20  : public StatusChangeChecker,
21    public ProfileSyncServiceObserver {
22 public:
23  explicit SingleClientStatusChangeChecker(ProfileSyncService* service);
24  virtual ~SingleClientStatusChangeChecker();
25
26  // Timeout length for this operation.  Default is 45s.
27  virtual base::TimeDelta GetTimeoutDuration();
28
29  // Called when waiting times out.
30  void OnTimeout();
31
32  // Blocks until the exit condition is satisfied or a timeout occurs.
33  void Await();
34
35  // ProfileSyncServiceObserver implementation.
36  virtual void OnStateChanged() OVERRIDE;
37
38  // Returns true if the checker timed out.
39  bool TimedOut();
40
41  // StatusChangeChecker implementations and stubs.
42  virtual bool IsExitConditionSatisfied() = 0;
43  virtual std::string GetDebugMessage() const = 0;
44
45 protected:
46  ProfileSyncService* service() { return service_; }
47
48 private:
49  ProfileSyncService* service_;
50  bool timed_out_;
51};
52
53#endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SINGLE_CLIENT_STATUS_CHANGE_CHECKER_H_
54