activity_data_service.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2017 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_UPDATE_CLIENT_ACTIVITY_DATA_SERVICE_H_
  5. #define COMPONENTS_UPDATE_CLIENT_ACTIVITY_DATA_SERVICE_H_
  6. #include <set>
  7. #include <string>
  8. #include <vector>
  9. #include "base/callback_forward.h"
  10. namespace update_client {
  11. const int kDateFirstTime = -1;
  12. const int kDaysFirstTime = -1;
  13. const int kDateUnknown = -2;
  14. const int kDaysUnknown = -2;
  15. // This is an interface that injects certain update information (active, days
  16. // since ...) into the update engine of the update client.
  17. // GetDaysSinceLastActive and GetDaysSinceLastRollCall are used for backward
  18. // compatibility.
  19. class ActivityDataService {
  20. public:
  21. // Calls `callback` with the subset of `ids` that are active.
  22. // The callback is called on the same sequence that calls this function.
  23. virtual void GetActiveBits(
  24. const std::vector<std::string>& ids,
  25. base::OnceCallback<void(const std::set<std::string>&)> callback)
  26. const = 0;
  27. // Calls `callback` with the subset of `ids` that are active, after clearing
  28. // their active setting. The callback is called on the same sequence that
  29. // calls this function.
  30. virtual void GetAndClearActiveBits(
  31. const std::vector<std::string>& ids,
  32. base::OnceCallback<void(const std::set<std::string>&)> callback) = 0;
  33. // The following 2 functions return the number of days since last
  34. // active/roll call.
  35. virtual int GetDaysSinceLastActive(const std::string& id) const = 0;
  36. virtual int GetDaysSinceLastRollCall(const std::string& id) const = 0;
  37. virtual ~ActivityDataService() = default;
  38. };
  39. } // namespace update_client
  40. #endif // COMPONENTS_UPDATE_CLIENT_ACTIVITY_DATA_SERVICE_H_