image_prefetcher.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2020 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_QUERY_TILES_INTERNAL_IMAGE_PREFETCHER_H_
  5. #define COMPONENTS_QUERY_TILES_INTERNAL_IMAGE_PREFETCHER_H_
  6. #include <memory>
  7. #include "base/callback.h"
  8. #include "components/query_tiles/internal/tile_types.h"
  9. namespace query_tiles {
  10. class ImageLoader;
  11. struct TileGroup;
  12. // Used to prefetch images for a tile group in a background task.
  13. class ImagePrefetcher {
  14. public:
  15. static std::unique_ptr<ImagePrefetcher> Create(
  16. ImagePrefetchMode prefetch_mode,
  17. std::unique_ptr<ImageLoader> image_loader);
  18. ImagePrefetcher() = default;
  19. virtual ~ImagePrefetcher() = default;
  20. ImagePrefetcher(const ImagePrefetcher&) = delete;
  21. ImagePrefetcher& operator=(const ImagePrefetcher&) = delete;
  22. // Prefetch a |tile_group|. |done_callback| will be invoked after prefetching
  23. // is done.
  24. virtual void Prefetch(TileGroup tile_group,
  25. bool is_from_reduced_mode,
  26. base::OnceClosure done_callback) = 0;
  27. };
  28. } // namespace query_tiles
  29. #endif // COMPONENTS_QUERY_TILES_INTERNAL_IMAGE_PREFETCHER_H_