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

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

Issue 2286603002: Forbid ImageDownloaderImpl from accessing RenderThread instance after message loop shutdown. (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | 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/location.h" 10 #include "base/location.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (thread)
yzshen1 2016/08/26 19:20:31 Please comment on why this null check is necessary
leonhsl(Using Gerrit) 2016/08/29 02:17:30 Done and thanks.
135 thread->RemoveObserver(this);
134 } 136 }
135 137
136 // static 138 // static
137 void ImageDownloaderImpl::CreateMojoService( 139 void ImageDownloaderImpl::CreateMojoService(
138 RenderFrame* render_frame, 140 RenderFrame* render_frame,
139 mojo::InterfaceRequest<content::mojom::ImageDownloader> request) { 141 mojo::InterfaceRequest<content::mojom::ImageDownloader> request) {
140 DVLOG(1) << "ImageDownloaderImpl::CreateService"; 142 DVLOG(1) << "ImageDownloaderImpl::CreateService";
141 DCHECK(render_frame); 143 DCHECK(render_frame);
142 144
143 new ImageDownloaderImpl(render_frame, std::move(request)); 145 new ImageDownloaderImpl(render_frame, std::move(request));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 const std::vector<gfx::Size>& result_original_image_sizes, 227 const std::vector<gfx::Size>& result_original_image_sizes,
226 const DownloadImageCallback& callback) { 228 const DownloadImageCallback& callback) {
227 callback.Run(http_status_code, result_images, result_original_image_sizes); 229 callback.Run(http_status_code, result_images, result_original_image_sizes);
228 } 230 }
229 231
230 void ImageDownloaderImpl::OnDestruct() { 232 void ImageDownloaderImpl::OnDestruct() {
231 delete this; 233 delete this;
232 } 234 }
233 235
234 } // namespace content 236 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698