forwarding_model_type_processor.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2019 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_FORWARDING_MODEL_TYPE_PROCESSOR_H_
  5. #define COMPONENTS_SYNC_ENGINE_FORWARDING_MODEL_TYPE_PROCESSOR_H_
  6. #include <memory>
  7. #include "base/memory/raw_ptr.h"
  8. #include "components/sync/engine/model_type_processor.h"
  9. namespace syncer {
  10. // Trivial implementation of ModelTypeProcessor, that simply forwards
  11. // call to another processor. This is useful when an API requires transferring
  12. // ownership, but the calling site also wants to keep ownership of the actual
  13. // implementation, and can guarantee the lifetime constraints.
  14. class ForwardingModelTypeProcessor : public ModelTypeProcessor {
  15. public:
  16. // |processor| must not be null and must outlive this object.
  17. explicit ForwardingModelTypeProcessor(ModelTypeProcessor* processor);
  18. ForwardingModelTypeProcessor(const ForwardingModelTypeProcessor&) = delete;
  19. ForwardingModelTypeProcessor& operator=(const ForwardingModelTypeProcessor&) =
  20. delete;
  21. ~ForwardingModelTypeProcessor() override;
  22. void ConnectSync(std::unique_ptr<CommitQueue> worker) override;
  23. void DisconnectSync() override;
  24. void GetLocalChanges(size_t max_entries,
  25. GetLocalChangesCallback callback) override;
  26. void OnCommitCompleted(
  27. const sync_pb::ModelTypeState& type_state,
  28. const CommitResponseDataList& committed_response_list,
  29. const FailedCommitResponseDataList& error_response_list) override;
  30. void OnCommitFailed(SyncCommitError commit_error) override;
  31. void OnUpdateReceived(const sync_pb::ModelTypeState& type_state,
  32. UpdateResponseDataList updates) override;
  33. private:
  34. const raw_ptr<ModelTypeProcessor> processor_;
  35. };
  36. } // namespace syncer
  37. #endif // COMPONENTS_SYNC_ENGINE_FORWARDING_MODEL_TYPE_PROCESSOR_H_