active_devices_provider.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2020 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_DRIVER_ACTIVE_DEVICES_PROVIDER_H_
  5. #define COMPONENTS_SYNC_DRIVER_ACTIVE_DEVICES_PROVIDER_H_
  6. #include <string>
  7. #include "base/callback.h"
  8. #include "components/sync/engine/active_devices_invalidation_info.h"
  9. namespace syncer {
  10. // An interface helping to get the information about active devices. Devices are
  11. // considered active if there are DeviceInfo entries that are (typically) less
  12. // than one day old (with a little margin around half an hour).
  13. class ActiveDevicesProvider {
  14. public:
  15. using ActiveDevicesChangedCallback = base::RepeatingClosure;
  16. virtual ~ActiveDevicesProvider() = default;
  17. // Prepare information for the following sync cycles about invalidations on
  18. // other devices.
  19. virtual ActiveDevicesInvalidationInfo CalculateInvalidationInfo(
  20. const std::string& local_cache_guid) const = 0;
  21. // The |callback| will be called on each change in device infos. It might be
  22. // called multiple times with the same number of active devices. The
  23. // |callback| must be cleared before this object is destroyed.
  24. virtual void SetActiveDevicesChangedCallback(
  25. ActiveDevicesChangedCallback callback) = 0;
  26. };
  27. } // namespace syncer
  28. #endif // COMPONENTS_SYNC_DRIVER_ACTIVE_DEVICES_PROVIDER_H_