session_sync_service.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2018 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_SESSIONS_SESSION_SYNC_SERVICE_H_
  5. #define COMPONENTS_SYNC_SESSIONS_SESSION_SYNC_SERVICE_H_
  6. #include "base/callback_list.h"
  7. #include "base/memory/weak_ptr.h"
  8. #include "components/keyed_service/core/keyed_service.h"
  9. #include "components/sync/driver/data_type_controller.h"
  10. namespace syncer {
  11. class GlobalIdMapper;
  12. class ModelTypeControllerDelegate;
  13. } // namespace syncer
  14. namespace sync_sessions {
  15. class OpenTabsUIDelegate;
  16. // KeyedService responsible session sync (aka tab sync).
  17. // This powers things like the history UI, where "Tabs from other devices"
  18. // exists, as well as the uploading counterpart for other devices to see our
  19. // local tabs.
  20. class SessionSyncService : public KeyedService {
  21. public:
  22. SessionSyncService();
  23. SessionSyncService(const SessionSyncService&) = delete;
  24. SessionSyncService& operator=(const SessionSyncService&) = delete;
  25. ~SessionSyncService() override;
  26. virtual syncer::GlobalIdMapper* GetGlobalIdMapper() const = 0;
  27. // Return the active OpenTabsUIDelegate. If open/proxy tabs is not enabled or
  28. // not currently syncing, returns nullptr.
  29. virtual OpenTabsUIDelegate* GetOpenTabsUIDelegate() = 0;
  30. // Allows client code to be notified when foreign sessions change.
  31. [[nodiscard]] virtual base::CallbackListSubscription
  32. SubscribeToForeignSessionsChanged(const base::RepeatingClosure& cb) = 0;
  33. virtual base::WeakPtr<syncer::ModelTypeControllerDelegate>
  34. GetControllerDelegate() = 0;
  35. // Intended to be used by ProxyDataTypeController: influences whether
  36. // GetOpenTabsUIDelegate() returns null or not.
  37. virtual void ProxyTabsStateChanged(
  38. syncer::DataTypeController::State state) = 0;
  39. };
  40. } // namespace sync_sessions
  41. #endif // COMPONENTS_SYNC_SESSIONS_SESSION_SYNC_SERVICE_H_