command_line_top_host_provider.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_OPTIMIZATION_GUIDE_CORE_COMMAND_LINE_TOP_HOST_PROVIDER_H_
  5. #define COMPONENTS_OPTIMIZATION_GUIDE_CORE_COMMAND_LINE_TOP_HOST_PROVIDER_H_
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "components/optimization_guide/core/top_host_provider.h"
  10. namespace optimization_guide {
  11. // A TopHostProvider implementation that provides top hosts based on what is fed
  12. // through the command line. This implementation is intended to be used just for
  13. // developer and integration testing.
  14. class CommandLineTopHostProvider : public TopHostProvider {
  15. public:
  16. // Creates a TopHostProvider if the flag for overriding top hosts has been
  17. // enabled.
  18. static std::unique_ptr<CommandLineTopHostProvider> CreateIfEnabled();
  19. CommandLineTopHostProvider(const CommandLineTopHostProvider&) = delete;
  20. CommandLineTopHostProvider& operator=(const CommandLineTopHostProvider&) =
  21. delete;
  22. ~CommandLineTopHostProvider() override;
  23. // TopHostProvider implementation:
  24. std::vector<std::string> GetTopHosts() override;
  25. private:
  26. explicit CommandLineTopHostProvider(
  27. const std::vector<std::string>& top_hosts);
  28. std::vector<std::string> top_hosts_;
  29. };
  30. } // namespace optimization_guide
  31. #endif // COMPONENTS_OPTIMIZATION_GUIDE_CORE_COMMAND_LINE_TOP_HOST_PROVIDER_H_