sync_engine_host.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_HOST_H_
  5. #define COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_HOST_H_
  6. #include "components/sync/base/model_type.h"
  7. #include "components/sync/engine/sync_encryption_handler.h"
  8. #include "components/sync/engine/sync_manager.h"
  9. #include "components/sync/protocol/sync_protocol_error.h"
  10. namespace syncer {
  11. class ProtocolEvent;
  12. // SyncEngineHost is the interface used by SyncEngine to communicate with the
  13. // entity that created it. It's essentially an observer interface except the
  14. // SyncEngine always has exactly one.
  15. class SyncEngineHost {
  16. public:
  17. SyncEngineHost() = default;
  18. virtual ~SyncEngineHost() = default;
  19. // The engine has completed initialization and it is now ready to accept and
  20. // process changes. If success is false, initialization wasn't able to be
  21. // completed and should be retried.
  22. //
  23. // |js_backend| is what chrome://sync-internals interacts with. It is
  24. // initialized only if |success| is true.
  25. virtual void OnEngineInitialized(bool success,
  26. bool is_first_time_sync_configure) = 0;
  27. // The engine queried the server recently and received some updates.
  28. virtual void OnSyncCycleCompleted(const SyncCycleSnapshot& snapshot) = 0;
  29. // Informs the host of some network event. These notifications are disabled by
  30. // default and must be enabled through an explicit request to the SyncEngine.
  31. //
  32. // It's disabled by default to avoid copying data across threads when no one
  33. // is listening for it.
  34. virtual void OnProtocolEvent(const ProtocolEvent& event) = 0;
  35. // The status of the connection to the sync server has changed.
  36. virtual void OnConnectionStatusChange(ConnectionStatus status) = 0;
  37. // Called to perform migration of |types|.
  38. virtual void OnMigrationNeededForTypes(ModelTypeSet types) = 0;
  39. // Called when the sync cycle returns there is an user actionable error.
  40. virtual void OnActionableError(const SyncProtocolError& error) = 0;
  41. // Called when the set of backed off types is changed.
  42. virtual void OnBackedOffTypesChanged() = 0;
  43. };
  44. } // namespace syncer
  45. #endif // COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_HOST_H_