OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The AllStatus object watches various sync engine components and aggregates | 5 // The AllStatus object watches various sync engine components and aggregates |
6 // the status of all of them into one place. | 6 // the status of all of them into one place. |
7 | 7 |
8 #ifndef SYNC_INTERNAL_API_ALL_STATUS_H_ | 8 #ifndef SYNC_INTERNAL_API_ALL_STATUS_H_ |
9 #define SYNC_INTERNAL_API_ALL_STATUS_H_ | 9 #define SYNC_INTERNAL_API_ALL_STATUS_H_ |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 // manually, but unless their timing is excellent it's unlikely that a user will | 32 // manually, but unless their timing is excellent it's unlikely that a user will |
33 // see any state in mid-sync cycle. We have no plans to change this. However, | 33 // see any state in mid-sync cycle. We have no plans to change this. However, |
34 // we will continue to collect data and update state mid-sync-cycle in case we | 34 // we will continue to collect data and update state mid-sync-cycle in case we |
35 // need to debug slow or stuck sync cycles. | 35 // need to debug slow or stuck sync cycles. |
36 class AllStatus : public SyncEngineEventListener { | 36 class AllStatus : public SyncEngineEventListener { |
37 friend class ScopedStatusLock; | 37 friend class ScopedStatusLock; |
38 public: | 38 public: |
39 AllStatus(); | 39 AllStatus(); |
40 virtual ~AllStatus(); | 40 virtual ~AllStatus(); |
41 | 41 |
42 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE; | 42 // SyncEngineEventListener implementation. |
| 43 virtual void OnSyncCycleEvent(const SyncCycleEvent& event) OVERRIDE; |
| 44 virtual void OnActionableError(const SyncProtocolError& error) OVERRIDE; |
| 45 virtual void OnRetryTimeChanged(base::Time retry_time) OVERRIDE; |
| 46 virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) OVERRIDE; |
43 | 47 |
44 SyncStatus status() const; | 48 SyncStatus status() const; |
45 | 49 |
46 void SetNotificationsEnabled(bool notifications_enabled); | 50 void SetNotificationsEnabled(bool notifications_enabled); |
47 | 51 |
48 void IncrementNotifiableCommits(); | 52 void IncrementNotifiableCommits(); |
49 | 53 |
50 void IncrementNotificationsReceived(); | 54 void IncrementNotificationsReceived(); |
51 | 55 |
52 void SetEncryptedTypes(ModelTypeSet types); | 56 void SetEncryptedTypes(ModelTypeSet types); |
53 void SetCryptographerReady(bool ready); | 57 void SetCryptographerReady(bool ready); |
54 void SetCryptoHasPendingKeys(bool has_pending_keys); | 58 void SetCryptoHasPendingKeys(bool has_pending_keys); |
55 void SetPassphraseType(PassphraseType type); | 59 void SetPassphraseType(PassphraseType type); |
56 void SetHasKeystoreKey(bool has_keystore_key); | 60 void SetHasKeystoreKey(bool has_keystore_key); |
57 void SetKeystoreMigrationTime(const base::Time& migration_time); | 61 void SetKeystoreMigrationTime(const base::Time& migration_time); |
58 | 62 |
59 void SetSyncId(const std::string& sync_id); | 63 void SetSyncId(const std::string& sync_id); |
60 void SetInvalidatorClientId(const std::string& invalidator_client_id); | 64 void SetInvalidatorClientId(const std::string& invalidator_client_id); |
61 | 65 |
62 void IncrementNudgeCounter(NudgeSource source); | 66 void IncrementNudgeCounter(NudgeSource source); |
63 | 67 |
64 protected: | 68 protected: |
65 // Examines syncer to calculate syncing and the unsynced count, | 69 // Examines syncer to calculate syncing and the unsynced count, |
66 // and returns a Status with new values. | 70 // and returns a Status with new values. |
67 SyncStatus CalcSyncing(const SyncEngineEvent& event) const; | 71 SyncStatus CalcSyncing(const SyncCycleEvent& event) const; |
68 SyncStatus CreateBlankStatus() const; | 72 SyncStatus CreateBlankStatus() const; |
69 | 73 |
70 SyncStatus status_; | 74 SyncStatus status_; |
71 | 75 |
72 mutable base::Lock mutex_; // Protects all data members. | 76 mutable base::Lock mutex_; // Protects all data members. |
73 DISALLOW_COPY_AND_ASSIGN(AllStatus); | 77 DISALLOW_COPY_AND_ASSIGN(AllStatus); |
74 }; | 78 }; |
75 | 79 |
76 class ScopedStatusLock { | 80 class ScopedStatusLock { |
77 public: | 81 public: |
78 explicit ScopedStatusLock(AllStatus* allstatus); | 82 explicit ScopedStatusLock(AllStatus* allstatus); |
79 ~ScopedStatusLock(); | 83 ~ScopedStatusLock(); |
80 protected: | 84 protected: |
81 AllStatus* allstatus_; | 85 AllStatus* allstatus_; |
82 }; | 86 }; |
83 | 87 |
84 } // namespace syncer | 88 } // namespace syncer |
85 | 89 |
86 #endif // SYNC_INTERNAL_API_ALL_STATUS_H_ | 90 #endif // SYNC_INTERNAL_API_ALL_STATUS_H_ |
OLD | NEW |