input_delegate.cc 1011 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2022 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. #include "components/segmentation_platform/public/input_delegate.h"
  5. namespace segmentation_platform::processing {
  6. InputDelegate::InputDelegate() = default;
  7. InputDelegate::~InputDelegate() = default;
  8. InputDelegateHolder::InputDelegateHolder() = default;
  9. InputDelegateHolder::~InputDelegateHolder() = default;
  10. InputDelegate* InputDelegateHolder::GetDelegate(
  11. proto::CustomInput::FillPolicy policy) {
  12. auto it = input_delegates_.find(policy);
  13. if (it != input_delegates_.end()) {
  14. return it->second.get();
  15. }
  16. return nullptr;
  17. }
  18. void InputDelegateHolder::SetDelegate(proto::CustomInput::FillPolicy policy,
  19. std::unique_ptr<InputDelegate> delegate) {
  20. DCHECK(!input_delegates_.count(policy));
  21. input_delegates_[policy] = std::move(delegate);
  22. }
  23. } // namespace segmentation_platform::processing