123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- // Copyright (c) 2012 The Chromium Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
- #ifndef COMPONENTS_SYNC_ENGINE_SYNC_STATUS_TRACKER_H_
- #define COMPONENTS_SYNC_ENGINE_SYNC_STATUS_TRACKER_H_
- #include <map>
- #include <string>
- #include "base/callback.h"
- #include "base/compiler_specific.h"
- #include "base/sequence_checker.h"
- #include "components/sync/base/model_type.h"
- #include "components/sync/engine/sync_engine_event_listener.h"
- #include "components/sync/engine/sync_status.h"
- #include "components/sync/protocol/nigori_specifics.pb.h"
- namespace syncer {
- struct SyncCycleEvent;
- // This class watches various sync engine components, updating its internal
- // state upon change and firing the callback injected on construction.
- //
- // Most of this data ends up on the chrome://sync-internals page. But the page
- // is only 'pinged' to update itself at the end of a sync cycle. A user could
- // refresh manually, but unless their timing is excellent it's unlikely that a
- // user will see any state in mid-sync cycle. We have no plans to change this.
- // However, we will continue to collect data and update state mid-sync-cycle in
- // case we need to debug slow or stuck sync cycles.
- class SyncStatusTracker : public SyncEngineEventListener {
- public:
- explicit SyncStatusTracker(
- const base::RepeatingCallback<void(const SyncStatus&)>&
- status_changed_callback);
- ~SyncStatusTracker() override;
- SyncStatusTracker(const SyncStatusTracker&) = delete;
- SyncStatusTracker& operator=(const SyncStatusTracker&) = delete;
- // SyncEngineEventListener implementation.
- void OnSyncCycleEvent(const SyncCycleEvent& event) override;
- void OnActionableError(const SyncProtocolError& error) override;
- void OnRetryTimeChanged(base::Time retry_time) override;
- void OnThrottledTypesChanged(ModelTypeSet throttled_types) override;
- void OnBackedOffTypesChanged(ModelTypeSet backed_off_types) override;
- void OnMigrationRequested(ModelTypeSet types) override;
- void OnProtocolEvent(const ProtocolEvent& event) override;
- void SetNotificationsEnabled(bool notifications_enabled);
- void IncrementNotificationsReceived();
- void SetEncryptedTypes(ModelTypeSet types);
- void SetCryptographerCanEncrypt(bool can_encrypt);
- void SetCryptoHasPendingKeys(bool has_pending_keys);
- void SetPassphraseType(PassphraseType type);
- void SetHasKeystoreKey(bool has_keystore_key);
- void SetKeystoreMigrationTime(const base::Time& migration_time);
- void SetTrustedVaultDebugInfo(
- const sync_pb::NigoriSpecifics::TrustedVaultDebugInfo&
- trusted_vault_debug_info);
- void SetCacheGuid(const std::string& cache_guid);
- void SetInvalidatorClientId(const std::string& invalidator_client_id);
- void SetLocalBackendFolder(const std::string& folder);
- protected:
- // Examines syncer to calculate syncing and the unsynced count,
- // and returns a Status with new values.
- SyncStatus CalcSyncing(const SyncCycleEvent& event) const;
- SyncStatus CreateBlankStatus() const;
- SyncStatus status_;
- private:
- const base::RepeatingCallback<void(const SyncStatus&)>
- status_changed_callback_;
- SEQUENCE_CHECKER(sequence_checker_);
- };
- } // namespace syncer
- #endif // COMPONENTS_SYNC_ENGINE_SYNC_STATUS_TRACKER_H_
|