Chromium Code Reviews| 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/location.h" | 10 #include "base/location.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 return; | 114 return; |
| 115 images->push_back(resized); | 115 images->push_back(resized); |
| 116 original_image_sizes->push_back( | 116 original_image_sizes->push_back( |
| 117 gfx::Size(min_image->width(), min_image->height())); | 117 gfx::Size(min_image->width(), min_image->height())); |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace | 120 } // namespace |
| 121 | 121 |
| 122 namespace content { | 122 namespace content { |
| 123 | 123 |
| 124 ImageDownloaderImpl::ImageDownloaderImpl( | 124 ImageDownloaderImpl::ImageDownloaderImpl( |
|
miu
2016/11/29 22:56:08
Factoring: This other constructor should delegate
xjz
2016/12/02 19:23:10
Not applicable.
| |
| 125 RenderFrame* render_frame, | 125 RenderFrame* render_frame, |
| 126 mojom::ImageDownloaderRequest request) | 126 mojom::ImageDownloaderRequest request) |
| 127 : RenderFrameObserver(render_frame), | 127 : RenderFrameObserver(render_frame), |
| 128 binding_(this, std::move(request)) { | 128 binding_(this, std::move(request)) { |
| 129 DCHECK(render_frame); | 129 DCHECK(render_frame); |
| 130 RenderThread::Get()->AddObserver(this); | 130 RenderThread::Get()->AddObserver(this); |
| 131 binding_.set_connection_error_handler( | 131 binding_.set_connection_error_handler( |
| 132 base::Bind(&ImageDownloaderImpl::OnDestruct, base::Unretained(this))); | 132 base::Bind(&ImageDownloaderImpl::OnDestruct, base::Unretained(this))); |
| 133 } | 133 } |
| 134 | 134 |
| 135 ImageDownloaderImpl::ImageDownloaderImpl(RenderFrame* render_frame) | |
| 136 : RenderFrameObserver(render_frame), binding_(this) { | |
| 137 DCHECK(render_frame); | |
| 138 RenderThread::Get()->AddObserver(this); | |
| 139 } | |
| 140 | |
| 135 ImageDownloaderImpl::~ImageDownloaderImpl() { | 141 ImageDownloaderImpl::~ImageDownloaderImpl() { |
| 136 RenderThread* thread = RenderThread::Get(); | 142 RenderThread* thread = RenderThread::Get(); |
| 137 // As ImageDownloaderImpl is a strong binding with message pipe, the | 143 // As ImageDownloaderImpl is a strong binding with message pipe, the |
| 138 // destructor may run after message loop shutdown, so we need to check whether | 144 // destructor may run after message loop shutdown, so we need to check whether |
| 139 // RenderThread is null. | 145 // RenderThread is null. |
| 140 if (thread) | 146 if (thread) |
| 141 thread->RemoveObserver(this); | 147 thread->RemoveObserver(this); |
| 142 } | 148 } |
| 143 | 149 |
| 144 // static | 150 // static |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 const std::vector<gfx::Size>& result_original_image_sizes, | 240 const std::vector<gfx::Size>& result_original_image_sizes, |
| 235 const DownloadImageCallback& callback) { | 241 const DownloadImageCallback& callback) { |
| 236 callback.Run(http_status_code, result_images, result_original_image_sizes); | 242 callback.Run(http_status_code, result_images, result_original_image_sizes); |
| 237 } | 243 } |
| 238 | 244 |
| 239 void ImageDownloaderImpl::OnDestruct() { | 245 void ImageDownloaderImpl::OnDestruct() { |
| 240 delete this; | 246 delete this; |
| 241 } | 247 } |
| 242 | 248 |
| 243 } // namespace content | 249 } // namespace content |
| OLD | NEW |