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 #include "content/renderer/image_downloader/image_downloader_impl.h" | 5 #include "content/renderer/image_downloader/image_downloader_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Owns itself. Will be deleted when message pipe is destroyed or RenderFrame | 106 // Owns itself. Will be deleted when message pipe is destroyed or RenderFrame |
107 // is destructed. | 107 // is destructed. |
108 new ImageDownloaderImpl(render_frame, std::move(request)); | 108 new ImageDownloaderImpl(render_frame, std::move(request)); |
109 } | 109 } |
110 | 110 |
111 // ImageDownloader methods: | 111 // ImageDownloader methods: |
112 void ImageDownloaderImpl::DownloadImage(const GURL& image_url, | 112 void ImageDownloaderImpl::DownloadImage(const GURL& image_url, |
113 bool is_favicon, | 113 bool is_favicon, |
114 uint32_t max_bitmap_size, | 114 uint32_t max_bitmap_size, |
115 bool bypass_cache, | 115 bool bypass_cache, |
116 const DownloadImageCallback& callback) { | 116 DownloadImageCallback callback) { |
117 std::vector<SkBitmap> result_images; | 117 std::vector<SkBitmap> result_images; |
118 std::vector<gfx::Size> result_original_image_sizes; | 118 std::vector<gfx::Size> result_original_image_sizes; |
119 | 119 |
120 ImageDownloaderBase::DownloadImage( | 120 ImageDownloaderBase::DownloadImage( |
121 image_url, is_favicon, bypass_cache, | 121 image_url, is_favicon, bypass_cache, |
122 base::Bind(&ImageDownloaderImpl::DidDownloadImage, base::Unretained(this), | 122 base::Bind(&ImageDownloaderImpl::DidDownloadImage, base::Unretained(this), |
123 max_bitmap_size, callback)); | 123 max_bitmap_size, base::Passed(&callback))); |
124 } | 124 } |
125 | 125 |
126 void ImageDownloaderImpl::DidDownloadImage( | 126 void ImageDownloaderImpl::DidDownloadImage( |
127 uint32_t max_image_size, | 127 uint32_t max_image_size, |
128 const DownloadImageCallback& callback, | 128 DownloadImageCallback callback, |
129 int32_t http_status_code, | 129 int32_t http_status_code, |
130 const std::vector<SkBitmap>& images) { | 130 const std::vector<SkBitmap>& images) { |
131 std::vector<SkBitmap> result_images; | 131 std::vector<SkBitmap> result_images; |
132 std::vector<gfx::Size> result_original_image_sizes; | 132 std::vector<gfx::Size> result_original_image_sizes; |
133 FilterAndResizeImagesForMaximalSize(images, max_image_size, &result_images, | 133 FilterAndResizeImagesForMaximalSize(images, max_image_size, &result_images, |
134 &result_original_image_sizes); | 134 &result_original_image_sizes); |
135 | 135 |
136 callback.Run(http_status_code, result_images, result_original_image_sizes); | 136 std::move(callback).Run(http_status_code, result_images, |
| 137 result_original_image_sizes); |
137 } | 138 } |
138 | 139 |
139 void ImageDownloaderImpl::OnDestruct() { | 140 void ImageDownloaderImpl::OnDestruct() { |
140 delete this; | 141 delete this; |
141 } | 142 } |
142 | 143 |
143 } // namespace content | 144 } // namespace content |
OLD | NEW |