missive_storage_module_delegate_impl.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2021 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_REPORTING_STORAGE_MISSIVE_STORAGE_MODULE_DELEGATE_IMPL_H_
  5. #define COMPONENTS_REPORTING_STORAGE_MISSIVE_STORAGE_MODULE_DELEGATE_IMPL_H_
  6. #include "base/callback.h"
  7. #include "components/reporting/proto/synced/record.pb.h"
  8. #include "components/reporting/proto/synced/record_constants.pb.h"
  9. #include "components/reporting/storage/missive_storage_module.h"
  10. #include "components/reporting/util/status.h"
  11. namespace reporting {
  12. // Provides a delegate that sends all requests to callbacks.
  13. class MissiveStorageModuleDelegateImpl
  14. : public MissiveStorageModule::MissiveStorageModuleDelegateInterface {
  15. public:
  16. using AddRecordCallback = base::RepeatingCallback<
  17. void(Priority, Record, MissiveStorageModule::EnqueueCallback)>;
  18. using FlushCallback =
  19. base::RepeatingCallback<void(Priority,
  20. MissiveStorageModule::FlushCallback)>;
  21. MissiveStorageModuleDelegateImpl(AddRecordCallback add_record,
  22. FlushCallback flush);
  23. ~MissiveStorageModuleDelegateImpl() override;
  24. void AddRecord(Priority priority,
  25. Record record,
  26. MissiveStorageModule::EnqueueCallback callback) override;
  27. void Flush(Priority priority,
  28. MissiveStorageModule::FlushCallback callback) override;
  29. void ReportSuccess(const SequenceInformation& sequence_information,
  30. bool force) override;
  31. void UpdateEncryptionKey(
  32. const SignedEncryptionInfo& signed_encryption_key) override;
  33. private:
  34. const AddRecordCallback add_record_;
  35. const FlushCallback flush_;
  36. };
  37. } // namespace reporting
  38. #endif // COMPONENTS_REPORTING_STORAGE_MISSIVE_STORAGE_MODULE_DELEGATE_IMPL_H_