image_loader.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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_LOADER_H_
  5. #define COMPONENTS_QUERY_TILES_INTERNAL_IMAGE_LOADER_H_
  6. #include "base/callback.h"
  7. #include "url/gurl.h"
  8. class SkBitmap;
  9. namespace query_tiles {
  10. // Loads image for query tiles.
  11. class ImageLoader {
  12. public:
  13. using BitmapCallback = base::OnceCallback<void(SkBitmap bitmap)>;
  14. using SuccessCallback = base::OnceCallback<void(bool)>;
  15. ImageLoader() = default;
  16. virtual ~ImageLoader() = default;
  17. ImageLoader(const ImageLoader&) = delete;
  18. ImageLoader& operator=(const ImageLoader&) = delete;
  19. // Fetches the bitmap of an image based on its URL. Callback will be invoked
  20. // with the bitmap of the image, or an empty bitmap on failure.
  21. virtual void FetchImage(const GURL& url, BitmapCallback callback) = 0;
  22. // Prefetches the image data. The decoding will be deferred to next full
  23. // browser mode launch. Must be called in reduced mode. The |callback| will be
  24. // invoked after network fetch is done.
  25. virtual void PrefetchImage(const GURL& url, SuccessCallback callback) = 0;
  26. };
  27. } // namespace query_tiles
  28. #endif // COMPONENTS_QUERY_TILES_INTERNAL_IMAGE_LOADER_H_