sync_engine_event_listener.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #ifndef COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_EVENT_LISTENER_H_
  5. #define COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_EVENT_LISTENER_H_
  6. #include "base/time/time.h"
  7. #include "components/sync/base/model_type.h"
  8. namespace syncer {
  9. struct SyncProtocolError;
  10. struct SyncCycleEvent;
  11. class ProtocolEvent;
  12. class SyncEngineEventListener {
  13. public:
  14. SyncEngineEventListener() = default;
  15. // Generated at various points during the sync cycle.
  16. virtual void OnSyncCycleEvent(const SyncCycleEvent& event) = 0;
  17. // This event is sent when we receive an actionable error. It is up to
  18. // the listeners to figure out the action to take using the error sent.
  19. virtual void OnActionableError(const SyncProtocolError& error) = 0;
  20. // This event is sent when scheduler decides to wait before next request
  21. // either because it gets throttled by server or because it backs off after
  22. // request failure. Retry time is passed in retry_time field of event.
  23. virtual void OnRetryTimeChanged(base::Time retry_time) = 0;
  24. // This event is sent when types are throttled or unthrottled.
  25. virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) = 0;
  26. // This event is sent when types are backed off or unbacked off.
  27. virtual void OnBackedOffTypesChanged(ModelTypeSet backed_off_types) = 0;
  28. // This event is sent when the server requests a migration.
  29. virtual void OnMigrationRequested(ModelTypeSet migration_types) = 0;
  30. // Emits events when sync communicates with the server.
  31. virtual void OnProtocolEvent(const ProtocolEvent& event) = 0;
  32. protected:
  33. virtual ~SyncEngineEventListener() = default;
  34. };
  35. } // namespace syncer
  36. #endif // COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_EVENT_LISTENER_H_