| Index: content/browser/web_contents/web_contents_impl.cc | 
| diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc | 
| index 233c1e09382b4b22fc94781650d4d79be0dff518..601da658cb701b2277e57b4aa3786ff8065af1d5 100644 | 
| --- a/content/browser/web_contents/web_contents_impl.cc | 
| +++ b/content/browser/web_contents/web_contents_impl.cc | 
| @@ -154,21 +154,6 @@ const char kWebContentsAndroidKey[] = "web_contents_android"; | 
| base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> > | 
| g_created_callbacks = LAZY_INSTANCE_INITIALIZER; | 
|  | 
| -static void DidDownloadImage(const WebContents::ImageDownloadCallback& callback, | 
| -                             int id, | 
| -                             const GURL& image_url, | 
| -                             image_downloader::DownloadResultPtr result) { | 
| -  DCHECK(result); | 
| - | 
| -  const std::vector<SkBitmap> images = | 
| -      result->images.To<std::vector<SkBitmap>>(); | 
| -  const std::vector<gfx::Size> original_image_sizes = | 
| -      result->original_image_sizes.To<std::vector<gfx::Size>>(); | 
| - | 
| -  callback.Run(id, result->http_status_code, image_url, images, | 
| -               original_image_sizes); | 
| -} | 
| - | 
| void NotifyCacheOnIO( | 
| scoped_refptr<net::URLRequestContextGetter> request_context, | 
| const GURL& url, | 
| @@ -415,7 +400,8 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context) | 
| audio_stream_monitor_(this), | 
| virtual_keyboard_requested_(false), | 
| page_scale_factor_is_one_(true), | 
| -      loading_weak_factory_(this) { | 
| +      loading_weak_factory_(this), | 
| +      weak_factory_(this) { | 
| frame_tree_.SetFrameRemoveListener( | 
| base::Bind(&WebContentsImpl::OnFrameRemoved, | 
| base::Unretained(this))); | 
| @@ -2818,12 +2804,14 @@ int WebContentsImpl::DownloadImage( | 
| // Android), the downloader service will be invalid. Pre-Mojo, this would | 
| // hang the callback indefinetly since the IPC would be dropped. Now, | 
| // respond with a 400 HTTP error code to indicate that something went wrong. | 
| +    image_downloader::DownloadResultPtr result = | 
| +        image_downloader::DownloadResult::New(); | 
| +    result->http_status_code = 400; | 
| BrowserThread::PostTask( | 
| BrowserThread::UI, FROM_HERE, | 
| -        base::Bind(&WebContents::ImageDownloadCallback::Run, | 
| -                   base::Owned(new ImageDownloadCallback(callback)), | 
| -                   download_id, 400, url, std::vector<SkBitmap>(), | 
| -                   std::vector<gfx::Size>())); | 
| +        base::Bind(&WebContentsImpl::OnDidDownloadImage, | 
| +                   weak_factory_.GetWeakPtr(), callback, download_id, url, | 
| +                   base::Passed(&result))); | 
| return download_id; | 
| } | 
|  | 
| @@ -2836,8 +2824,9 @@ int WebContentsImpl::DownloadImage( | 
| req->bypass_cache = bypass_cache; | 
|  | 
| mojo_image_downloader->DownloadImage( | 
| -      std::move(req), | 
| -      base::Bind(&DidDownloadImage, callback, download_id, url)); | 
| +      std::move(req), base::Bind(&WebContentsImpl::OnDidDownloadImage, | 
| +                                 weak_factory_.GetWeakPtr(), callback, | 
| +                                 download_id, url)); | 
| return download_id; | 
| } | 
|  | 
| @@ -4616,6 +4605,20 @@ bool WebContentsImpl::GetAllowOtherViews() { | 
|  | 
| #endif | 
|  | 
| +void WebContentsImpl::OnDidDownloadImage( | 
| +    const ImageDownloadCallback& callback, | 
| +    int id, | 
| +    const GURL& image_url, | 
| +    image_downloader::DownloadResultPtr result) { | 
| +  const std::vector<SkBitmap> images = | 
| +      result->images.To<std::vector<SkBitmap>>(); | 
| +  const std::vector<gfx::Size> original_image_sizes = | 
| +      result->original_image_sizes.To<std::vector<gfx::Size>>(); | 
| + | 
| +  callback.Run(id, result->http_status_code, image_url, images, | 
| +               original_image_sizes); | 
| +} | 
| + | 
| void WebContentsImpl::OnDialogClosed(int render_process_id, | 
| int render_frame_id, | 
| IPC::Message* reply_msg, | 
|  |