Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: content/renderer/image_downloader/image_downloader_impl.cc

Issue 1873003002: Ensure all AssociatedURLLoader be cancelled before shutting down Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/image_downloader/image_downloader_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "content/child/image_decoder.h" 12 #include "content/child/image_decoder.h"
13 #include "content/public/renderer/render_frame.h" 13 #include "content/public/renderer/render_frame.h"
14 #include "content/public/renderer/render_thread.h"
14 #include "content/renderer/fetchers/multi_resolution_image_resource_fetcher.h" 15 #include "content/renderer/fetchers/multi_resolution_image_resource_fetcher.h"
15 #include "mojo/common/url_type_converters.h" 16 #include "mojo/common/url_type_converters.h"
16 #include "mojo/converters/geometry/geometry_type_converters.h" 17 #include "mojo/converters/geometry/geometry_type_converters.h"
17 #include "net/base/data_url.h" 18 #include "net/base/data_url.h"
18 #include "skia/ext/image_operations.h" 19 #include "skia/ext/image_operations.h"
19 #include "skia/public/type_converters.h" 20 #include "skia/public/type_converters.h"
20 #include "third_party/WebKit/public/platform/WebURLRequest.h" 21 #include "third_party/WebKit/public/platform/WebURLRequest.h"
21 #include "third_party/WebKit/public/platform/WebVector.h" 22 #include "third_party/WebKit/public/platform/WebVector.h"
22 #include "third_party/WebKit/public/web/WebLocalFrame.h" 23 #include "third_party/WebKit/public/web/WebLocalFrame.h"
23 #include "third_party/WebKit/public/web/WebView.h" 24 #include "third_party/WebKit/public/web/WebView.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 115
115 } // namespace 116 } // namespace
116 117
117 namespace content { 118 namespace content {
118 119
119 ImageDownloaderImpl::ImageDownloaderImpl( 120 ImageDownloaderImpl::ImageDownloaderImpl(
120 RenderFrame* render_frame, 121 RenderFrame* render_frame,
121 mojo::InterfaceRequest<content::mojom::ImageDownloader> request) 122 mojo::InterfaceRequest<content::mojom::ImageDownloader> request)
122 : RenderFrameObserver(render_frame), binding_(this, std::move(request)) { 123 : RenderFrameObserver(render_frame), binding_(this, std::move(request)) {
123 DCHECK(render_frame); 124 DCHECK(render_frame);
125 RenderThread::Get()->AddObserver(this);
124 } 126 }
125 127
126 ImageDownloaderImpl::~ImageDownloaderImpl() { 128 ImageDownloaderImpl::~ImageDownloaderImpl() {
129 RenderThread::Get()->RemoveObserver(this);
127 } 130 }
128 131
129 // static 132 // static
130 void ImageDownloaderImpl::CreateMojoService( 133 void ImageDownloaderImpl::CreateMojoService(
131 RenderFrame* render_frame, 134 RenderFrame* render_frame,
132 mojo::InterfaceRequest<content::mojom::ImageDownloader> request) { 135 mojo::InterfaceRequest<content::mojom::ImageDownloader> request) {
133 DVLOG(1) << "ImageDownloaderImpl::CreateService"; 136 DVLOG(1) << "ImageDownloaderImpl::CreateService";
134 DCHECK(render_frame); 137 DCHECK(render_frame);
135 138
136 new ImageDownloaderImpl(render_frame, std::move(request)); 139 new ImageDownloaderImpl(render_frame, std::move(request));
137 } 140 }
138 141
142 // Ensure all loaders cleared before calling blink::shutdown.
143 void ImageDownloaderImpl::OnRenderProcessShutdown() {
144 image_fetchers_.clear();
145 }
146
139 // ImageDownloader methods: 147 // ImageDownloader methods:
140 void ImageDownloaderImpl::DownloadImage(const mojo::String& url, 148 void ImageDownloaderImpl::DownloadImage(const mojo::String& url,
141 bool is_favicon, 149 bool is_favicon,
142 uint32_t max_bitmap_size, 150 uint32_t max_bitmap_size,
143 bool bypass_cache, 151 bool bypass_cache,
144 const DownloadImageCallback& callback) { 152 const DownloadImageCallback& callback) {
145 const GURL image_url = url.To<GURL>(); 153 const GURL image_url = url.To<GURL>();
146 154
147 std::vector<SkBitmap> result_images; 155 std::vector<SkBitmap> result_images;
148 std::vector<gfx::Size> result_original_image_sizes; 156 std::vector<gfx::Size> result_original_image_sizes;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 int32_t http_status_code, 219 int32_t http_status_code,
212 const std::vector<SkBitmap>& result_images, 220 const std::vector<SkBitmap>& result_images,
213 const std::vector<gfx::Size>& result_original_image_sizes, 221 const std::vector<gfx::Size>& result_original_image_sizes,
214 const DownloadImageCallback& callback) { 222 const DownloadImageCallback& callback) {
215 callback.Run(http_status_code, 223 callback.Run(http_status_code,
216 mojo::Array<skia::mojom::BitmapPtr>::From(result_images), 224 mojo::Array<skia::mojom::BitmapPtr>::From(result_images),
217 mojo::Array<mojo::SizePtr>::From(result_original_image_sizes)); 225 mojo::Array<mojo::SizePtr>::From(result_original_image_sizes));
218 } 226 }
219 227
220 } // namespace content 228 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/image_downloader/image_downloader_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698