Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / sync / sync_startup_tracker.h
blob17532829efee47cdb3c937f3226df463fdb9a8ce
1 // Copyright (c) 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 #ifndef CHROME_BROWSER_SYNC_SYNC_STARTUP_TRACKER_H_
6 #define CHROME_BROWSER_SYNC_SYNC_STARTUP_TRACKER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "components/sync_driver/sync_service_observer.h"
12 class Profile;
14 // SyncStartupTracker provides a centralized way for observers to detect when
15 // ProfileSyncService has successfully started up, or when startup has failed
16 // due to some kind of error. This code was originally part of SigninTracker
17 // but now that sync initialization is no longer a required part of signin,
18 // it has been broken out of that class so only those places that care about
19 // sync initialization depend on it.
20 class SyncStartupTracker : public sync_driver::SyncServiceObserver {
21 public:
22 // Observer interface used to notify observers when sync has started up.
23 class Observer {
24 public:
25 virtual ~Observer() {}
27 virtual void SyncStartupCompleted() = 0;
28 virtual void SyncStartupFailed() = 0;
31 SyncStartupTracker(Profile* profile, Observer* observer);
32 ~SyncStartupTracker() override;
34 enum SyncServiceState {
35 // Sync backend is still starting up.
36 SYNC_STARTUP_PENDING,
37 // An error has been detected that prevents the sync backend from starting
38 // up.
39 SYNC_STARTUP_ERROR,
40 // Sync startup has completed (i.e. ProfileSyncService::IsSyncActive()
41 // returns true).
42 SYNC_STARTUP_COMPLETE
45 // Returns the current state of the sync service.
46 static SyncServiceState GetSyncServiceState(Profile* profile);
48 // sync_driver::SyncServiceObserver implementation.
49 void OnStateChanged() override;
51 private:
52 // Checks the current service state and notifies |observer_| if the state
53 // has changed. Note that it is expected that the observer will free this
54 // object, so callers should not reference this object after making this call.
55 void CheckServiceState();
57 // Profile whose ProfileSyncService we should track.
58 Profile* profile_;
60 // Weak pointer to the observer to notify.
61 Observer* observer_;
63 DISALLOW_COPY_AND_ASSIGN(SyncStartupTracker);
66 #endif // CHROME_BROWSER_SYNC_SYNC_STARTUP_TRACKER_H_