forwarding_model_type_controller_delegate.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_MODEL_FORWARDING_MODEL_TYPE_CONTROLLER_DELEGATE_H_
  5. #define COMPONENTS_SYNC_MODEL_FORWARDING_MODEL_TYPE_CONTROLLER_DELEGATE_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "components/sync/model/model_type_controller_delegate.h"
  8. namespace syncer {
  9. // Trivial implementation of ModelTypeControllerDelegate that simply forwards
  10. // call to another delegate (no task posting involved). This is useful when an
  11. // API requires transferring ownership, but the calling site also wants to keep
  12. // ownership of the actual implementation, and can guarantee the lifetime
  13. // constraints.
  14. class ForwardingModelTypeControllerDelegate
  15. : public ModelTypeControllerDelegate {
  16. public:
  17. // Except for tests, |other| must not be null and must outlive this object.
  18. explicit ForwardingModelTypeControllerDelegate(
  19. ModelTypeControllerDelegate* other);
  20. ForwardingModelTypeControllerDelegate(
  21. const ForwardingModelTypeControllerDelegate&) = delete;
  22. ForwardingModelTypeControllerDelegate& operator=(
  23. const ForwardingModelTypeControllerDelegate&) = delete;
  24. ~ForwardingModelTypeControllerDelegate() override;
  25. // ModelTypeControllerDelegate implementation.
  26. void OnSyncStarting(const DataTypeActivationRequest& request,
  27. StartCallback callback) override;
  28. void OnSyncStopping(SyncStopMetadataFate metadata_fate) override;
  29. void GetAllNodesForDebugging(AllNodesCallback callback) override;
  30. void GetTypeEntitiesCountForDebugging(
  31. base::OnceCallback<void(const TypeEntitiesCount&)> callback)
  32. const override;
  33. void RecordMemoryUsageAndCountsHistograms() override;
  34. private:
  35. const raw_ptr<ModelTypeControllerDelegate> other_;
  36. };
  37. } // namespace syncer
  38. #endif // COMPONENTS_SYNC_MODEL_FORWARDING_MODEL_TYPE_CONTROLLER_DELEGATE_H_