| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_IMAGE_DOWNLOADER_IMAGE_DOWNLOADER_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_IMAGE_DOWNLOADER_IMAGE_DOWNLOADER_IMPL_H_ |
| 6 #define CONTENT_RENDERER_IMAGE_DOWNLOADER_IMAGE_DOWNLOADER_IMPL_H_ | 6 #define CONTENT_RENDERER_IMAGE_DOWNLOADER_IMAGE_DOWNLOADER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "content/common/image_downloader/image_downloader.mojom.h" | 14 #include "content/common/image_downloader/image_downloader.mojom.h" |
| 15 #include "content/public/renderer/render_frame_observer.h" | 15 #include "content/public/renderer/render_frame_observer.h" |
| 16 #include "content/public/renderer/render_thread_observer.h" | 16 #include "content/public/renderer/render_thread_observer.h" |
| 17 #include "mojo/public/cpp/bindings/strong_binding.h" | 17 #include "mojo/public/cpp/bindings/binding.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 class SkBitmap; | 20 class SkBitmap; |
| 21 | 21 |
| 22 namespace gfx { | 22 namespace gfx { |
| 23 class Size; | 23 class Size; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 | 27 |
| 28 class MultiResolutionImageResourceFetcher; | 28 class MultiResolutionImageResourceFetcher; |
| 29 class RenderFrame; | 29 class RenderFrame; |
| 30 | 30 |
| 31 class ImageDownloaderImpl : public content::mojom::ImageDownloader, | 31 class ImageDownloaderImpl : public mojom::ImageDownloader, |
| 32 public RenderFrameObserver, | 32 public RenderFrameObserver, |
| 33 public RenderThreadObserver { | 33 public RenderThreadObserver { |
| 34 public: | 34 public: |
| 35 static void CreateMojoService( | 35 ~ImageDownloaderImpl() override; |
| 36 RenderFrame* render_frame, | 36 |
| 37 mojo::InterfaceRequest<content::mojom::ImageDownloader> request); | 37 static void CreateMojoService(RenderFrame* render_frame, |
| 38 mojom::ImageDownloaderRequest request); |
| 38 | 39 |
| 39 // RenderThreadObserver implementation. | 40 // RenderThreadObserver implementation. |
| 40 void OnRenderProcessShutdown() override; | 41 void OnRenderProcessShutdown() override; |
| 41 | 42 |
| 42 private: | 43 private: |
| 43 ImageDownloaderImpl( | 44 ImageDownloaderImpl(RenderFrame* render_frame, |
| 44 RenderFrame* render_frame, | 45 mojom::ImageDownloaderRequest request); |
| 45 mojo::InterfaceRequest<content::mojom::ImageDownloader> request); | |
| 46 ~ImageDownloaderImpl() override; | |
| 47 | 46 |
| 48 // RenderFrameObserver implementation. | 47 // RenderFrameObserver implementation. |
| 49 void OnDestruct() override; | 48 void OnDestruct() override; |
| 50 | 49 |
| 51 // ImageDownloader methods: | 50 // ImageDownloader methods: |
| 52 void DownloadImage(const GURL& url, | 51 void DownloadImage(const GURL& url, |
| 53 bool is_favicon, | 52 bool is_favicon, |
| 54 uint32_t max_bitmap_size, | 53 uint32_t max_bitmap_size, |
| 55 bool bypass_cache, | 54 bool bypass_cache, |
| 56 const DownloadImageCallback& callback) override; | 55 const DownloadImageCallback& callback) override; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 78 MultiResolutionImageResourceFetcher* fetcher, | 77 MultiResolutionImageResourceFetcher* fetcher, |
| 79 const std::vector<SkBitmap>& images); | 78 const std::vector<SkBitmap>& images); |
| 80 | 79 |
| 81 // Reply download result | 80 // Reply download result |
| 82 void ReplyDownloadResult( | 81 void ReplyDownloadResult( |
| 83 int32_t http_status_code, | 82 int32_t http_status_code, |
| 84 const std::vector<SkBitmap>& result_images, | 83 const std::vector<SkBitmap>& result_images, |
| 85 const std::vector<gfx::Size>& result_original_image_sizes, | 84 const std::vector<gfx::Size>& result_original_image_sizes, |
| 86 const DownloadImageCallback& callback); | 85 const DownloadImageCallback& callback); |
| 87 | 86 |
| 88 // We use StrongBinding to ensure deletion of "this" when connection closed | |
| 89 mojo::StrongBinding<ImageDownloader> binding_; | |
| 90 | |
| 91 typedef ScopedVector<MultiResolutionImageResourceFetcher> | 87 typedef ScopedVector<MultiResolutionImageResourceFetcher> |
| 92 ImageResourceFetcherList; | 88 ImageResourceFetcherList; |
| 93 | 89 |
| 94 // ImageResourceFetchers schedule via FetchImage. | 90 // ImageResourceFetchers schedule via FetchImage. |
| 95 ImageResourceFetcherList image_fetchers_; | 91 ImageResourceFetcherList image_fetchers_; |
| 96 | 92 |
| 93 mojo::Binding<mojom::ImageDownloader> binding_; |
| 94 |
| 97 DISALLOW_COPY_AND_ASSIGN(ImageDownloaderImpl); | 95 DISALLOW_COPY_AND_ASSIGN(ImageDownloaderImpl); |
| 98 }; | 96 }; |
| 99 | 97 |
| 100 } // namespace content | 98 } // namespace content |
| 101 | 99 |
| 102 #endif // CONTENT_RENDERER_IMAGE_DOWNLOADER_IMAGE_DOWNLOADER_IMPL_H_ | 100 #endif // CONTENT_RENDERER_IMAGE_DOWNLOADER_IMAGE_DOWNLOADER_IMPL_H_ |
| OLD | NEW |