| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 ImageDownloaderImpl::ImageDownloaderImpl( | 124 ImageDownloaderImpl::ImageDownloaderImpl( |
| 125 RenderFrame* render_frame, | 125 RenderFrame* render_frame, |
| 126 mojo::InterfaceRequest<content::mojom::ImageDownloader> request) | 126 mojo::InterfaceRequest<content::mojom::ImageDownloader> request) |
| 127 : RenderFrameObserver(render_frame), binding_(this, std::move(request)) { | 127 : RenderFrameObserver(render_frame), binding_(this, std::move(request)) { |
| 128 DCHECK(render_frame); | 128 DCHECK(render_frame); |
| 129 RenderThread::Get()->AddObserver(this); | 129 RenderThread::Get()->AddObserver(this); |
| 130 } | 130 } |
| 131 | 131 |
| 132 ImageDownloaderImpl::~ImageDownloaderImpl() { | 132 ImageDownloaderImpl::~ImageDownloaderImpl() { |
| 133 RenderThread::Get()->RemoveObserver(this); | 133 RenderThread* thread = RenderThread::Get(); |
| 134 // As ImageDownloaderImpl is a strong binding with message pipe, the |
| 135 // destructor may run after message loop shutdown, so we need to check whether |
| 136 // RenderThread is null. |
| 137 if (thread) |
| 138 thread->RemoveObserver(this); |
| 134 } | 139 } |
| 135 | 140 |
| 136 // static | 141 // static |
| 137 void ImageDownloaderImpl::CreateMojoService( | 142 void ImageDownloaderImpl::CreateMojoService( |
| 138 RenderFrame* render_frame, | 143 RenderFrame* render_frame, |
| 139 mojo::InterfaceRequest<content::mojom::ImageDownloader> request) { | 144 mojo::InterfaceRequest<content::mojom::ImageDownloader> request) { |
| 140 DVLOG(1) << "ImageDownloaderImpl::CreateService"; | 145 DVLOG(1) << "ImageDownloaderImpl::CreateService"; |
| 141 DCHECK(render_frame); | 146 DCHECK(render_frame); |
| 142 | 147 |
| 143 new ImageDownloaderImpl(render_frame, std::move(request)); | 148 new ImageDownloaderImpl(render_frame, std::move(request)); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 const std::vector<gfx::Size>& result_original_image_sizes, | 230 const std::vector<gfx::Size>& result_original_image_sizes, |
| 226 const DownloadImageCallback& callback) { | 231 const DownloadImageCallback& callback) { |
| 227 callback.Run(http_status_code, result_images, result_original_image_sizes); | 232 callback.Run(http_status_code, result_images, result_original_image_sizes); |
| 228 } | 233 } |
| 229 | 234 |
| 230 void ImageDownloaderImpl::OnDestruct() { | 235 void ImageDownloaderImpl::OnDestruct() { |
| 231 delete this; | 236 delete this; |
| 232 } | 237 } |
| 233 | 238 |
| 234 } // namespace content | 239 } // namespace content |
| OLD | NEW |