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 |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "sync/engine/sync_engine_event.h" | 16 #include "sync/engine/sync_cycle_event.h" |
Nicolas Zea
2014/02/11 00:35:05
forward declare
rlarocque
2014/02/11 00:48:28
Done.
| |
17 #include "sync/engine/sync_engine_event_listener.h" | |
17 #include "sync/engine/syncer_types.h" | 18 #include "sync/engine/syncer_types.h" |
18 #include "sync/internal_api/public/base/model_type.h" | 19 #include "sync/internal_api/public/base/model_type.h" |
19 #include "sync/internal_api/public/engine/sync_status.h" | 20 #include "sync/internal_api/public/engine/sync_status.h" |
20 #include "sync/engine/nudge_source.h" | 21 #include "sync/engine/nudge_source.h" |
21 | 22 |
22 namespace syncer { | 23 namespace syncer { |
23 | 24 |
24 class ScopedStatusLock; | 25 class ScopedStatusLock; |
25 struct ServerConnectionEvent; | 26 struct ServerConnectionEvent; |
26 | 27 |
27 // This class collects data and uses it to update its internal state. It can | 28 // This class collects data and uses it to update its internal state. It can |
28 // return a snapshot of this state as a SyncerStatus object. | 29 // return a snapshot of this state as a SyncerStatus object. |
29 // | 30 // |
30 // Most of this data ends up on the about:sync page. But the page is only | 31 // Most of this data ends up on the about:sync page. But the page is only |
31 // 'pinged' to update itself at the end of a sync cycle. A user could refresh | 32 // 'pinged' to update itself at the end of a sync cycle. A user could refresh |
32 // manually, but unless their timing is excellent it's unlikely that a user will | 33 // 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, | 34 // 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 | 35 // we will continue to collect data and update state mid-sync-cycle in case we |
35 // need to debug slow or stuck sync cycles. | 36 // need to debug slow or stuck sync cycles. |
36 class AllStatus : public SyncEngineEventListener { | 37 class AllStatus : public SyncEngineEventListener { |
37 friend class ScopedStatusLock; | 38 friend class ScopedStatusLock; |
38 public: | 39 public: |
39 AllStatus(); | 40 AllStatus(); |
40 virtual ~AllStatus(); | 41 virtual ~AllStatus(); |
41 | 42 |
42 virtual void OnSyncEngineEvent(const SyncEngineEvent& event) OVERRIDE; | 43 // SyncEngineEventListener implementation. |
44 virtual void OnSyncCycleEvent(const SyncCycleEvent& event) OVERRIDE; | |
45 virtual void OnActionableError(const SyncProtocolError& error) OVERRIDE; | |
46 virtual void OnRetryTimeChanged(base::Time retry_time) OVERRIDE; | |
47 virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) OVERRIDE; | |
43 | 48 |
44 SyncStatus status() const; | 49 SyncStatus status() const; |
45 | 50 |
46 void SetNotificationsEnabled(bool notifications_enabled); | 51 void SetNotificationsEnabled(bool notifications_enabled); |
47 | 52 |
48 void IncrementNotifiableCommits(); | 53 void IncrementNotifiableCommits(); |
49 | 54 |
50 void IncrementNotificationsReceived(); | 55 void IncrementNotificationsReceived(); |
51 | 56 |
52 void SetEncryptedTypes(ModelTypeSet types); | 57 void SetEncryptedTypes(ModelTypeSet types); |
53 void SetCryptographerReady(bool ready); | 58 void SetCryptographerReady(bool ready); |
54 void SetCryptoHasPendingKeys(bool has_pending_keys); | 59 void SetCryptoHasPendingKeys(bool has_pending_keys); |
55 void SetPassphraseType(PassphraseType type); | 60 void SetPassphraseType(PassphraseType type); |
56 void SetHasKeystoreKey(bool has_keystore_key); | 61 void SetHasKeystoreKey(bool has_keystore_key); |
57 void SetKeystoreMigrationTime(const base::Time& migration_time); | 62 void SetKeystoreMigrationTime(const base::Time& migration_time); |
58 | 63 |
59 void SetSyncId(const std::string& sync_id); | 64 void SetSyncId(const std::string& sync_id); |
60 void SetInvalidatorClientId(const std::string& invalidator_client_id); | 65 void SetInvalidatorClientId(const std::string& invalidator_client_id); |
61 | 66 |
62 void IncrementNudgeCounter(NudgeSource source); | 67 void IncrementNudgeCounter(NudgeSource source); |
63 | 68 |
64 protected: | 69 protected: |
65 // Examines syncer to calculate syncing and the unsynced count, | 70 // Examines syncer to calculate syncing and the unsynced count, |
66 // and returns a Status with new values. | 71 // and returns a Status with new values. |
67 SyncStatus CalcSyncing(const SyncEngineEvent& event) const; | 72 SyncStatus CalcSyncing(const SyncCycleEvent& event) const; |
68 SyncStatus CreateBlankStatus() const; | 73 SyncStatus CreateBlankStatus() const; |
69 | 74 |
70 SyncStatus status_; | 75 SyncStatus status_; |
71 | 76 |
72 mutable base::Lock mutex_; // Protects all data members. | 77 mutable base::Lock mutex_; // Protects all data members. |
73 DISALLOW_COPY_AND_ASSIGN(AllStatus); | 78 DISALLOW_COPY_AND_ASSIGN(AllStatus); |
74 }; | 79 }; |
75 | 80 |
76 class ScopedStatusLock { | 81 class ScopedStatusLock { |
77 public: | 82 public: |
78 explicit ScopedStatusLock(AllStatus* allstatus); | 83 explicit ScopedStatusLock(AllStatus* allstatus); |
79 ~ScopedStatusLock(); | 84 ~ScopedStatusLock(); |
80 protected: | 85 protected: |
81 AllStatus* allstatus_; | 86 AllStatus* allstatus_; |
82 }; | 87 }; |
83 | 88 |
84 } // namespace syncer | 89 } // namespace syncer |
85 | 90 |
86 #endif // SYNC_INTERNAL_API_ALL_STATUS_H_ | 91 #endif // SYNC_INTERNAL_API_ALL_STATUS_H_ |
OLD | NEW |