Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 | |
| 5 #ifndef CONTENT_IMAGE_DOWNLOADER_IMPL_H_ | |
| 6 #define CONTENT_IMAGE_DOWNLOADER_IMPL_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/memory/scoped_vector.h" | |
| 11 #include "content/common/image_downloader/image_downloader.mojom.h" | |
| 12 #include "content/public/renderer/render_frame_observer.h" | |
| 13 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | |
| 14 #include "url/gurl.h" | |
| 15 | |
| 16 class SkBitmap; | |
| 17 | |
| 18 namespace gfx { | |
| 19 class Size; | |
| 20 } | |
| 21 | |
| 22 namespace content { | |
| 23 | |
| 24 class MultiResolutionImageResourceFetcher; | |
| 25 class RenderFrame; | |
| 26 | |
| 27 class ImageDownloaderImpl : public image_downloader::ImageDownloader, | |
| 28 public RenderFrameObserver { | |
| 29 public: | |
| 30 static void CreateMojoService( | |
| 31 RenderFrame* render_frame, | |
| 32 mojo::InterfaceRequest<image_downloader::ImageDownloader> request); | |
| 33 | |
| 34 private: | |
| 35 explicit ImageDownloaderImpl( | |
|
Anand Mistry (off Chromium)
2015/06/16 07:51:36
No 'explicit' since you have more than 2 arguments
leonhsl(Using Gerrit)
2015/06/23 02:18:02
Done.
| |
| 36 RenderFrame* render_frame, | |
| 37 mojo::InterfaceRequest<image_downloader::ImageDownloader> request); | |
| 38 ~ImageDownloaderImpl() override; | |
| 39 | |
| 40 // ImageDownloader methods: | |
| 41 void DownloadImage(image_downloader::DownloadRequestPtr req, | |
| 42 const DownloadImageCallback& callback) override; | |
| 43 | |
| 44 // Requests to fetch an image. When done, the ImageDownloaderImpl | |
| 45 // is notified by way of DidFetchImage. Returns true if the | |
| 46 // request was successfully started, false otherwise. | |
| 47 // If the image is a favicon, cookies will not be | |
| 48 // sent nor accepted during download. If the image has multiple frames, all | |
| 49 // the frames whose size <= |max_image_size| are returned. If all of the | |
| 50 // frames are larger than |max_image_size|, the smallest frame is resized to | |
| 51 // |max_image_size| and is the only result. |max_image_size| == 0 is | |
| 52 // interpreted as no max image size. | |
| 53 bool FetchImage(const GURL& image_url, | |
| 54 bool is_favicon, | |
| 55 uint32_t max_image_size, | |
| 56 bool bypass_cache, | |
| 57 const DownloadImageCallback& callback); | |
| 58 | |
| 59 // This callback is triggered when FetchImage completes, either | |
| 60 // succesfully or with a failure. See FetchImage for more | |
| 61 // details. | |
| 62 void DidFetchImage(uint32_t max_image_size, | |
| 63 const DownloadImageCallback& callback, | |
| 64 MultiResolutionImageResourceFetcher* fetcher, | |
| 65 const std::vector<SkBitmap>& images); | |
| 66 | |
| 67 // Reply download result | |
| 68 void ReplyDownloadResult( | |
| 69 int32_t http_status_code, | |
| 70 const std::vector<SkBitmap>& result_images, | |
| 71 const std::vector<gfx::Size>& result_original_image_sizes, | |
| 72 const DownloadImageCallback& callback); | |
| 73 | |
| 74 // We use StrongBinding to ensure deletion of "this" when connection closed | |
| 75 mojo::StrongBinding<ImageDownloader> binding_; | |
| 76 | |
| 77 typedef ScopedVector<MultiResolutionImageResourceFetcher> | |
| 78 ImageResourceFetcherList; | |
| 79 | |
| 80 // ImageResourceFetchers schedule via FetchImage. | |
| 81 ImageResourceFetcherList image_fetchers_; | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(ImageDownloaderImpl); | |
| 84 }; | |
| 85 | |
| 86 } // namespace content | |
| 87 | |
| 88 #endif // CONTENT_IMAGE_DOWNLOADER_IMPL_H_ | |
| OLD | NEW |