Commit d7b11f6f authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

Fix crash in ProfileDownloader

ProfileDownloaderDelegate implementation may delete ProfileDownloader inside
OnProfileDownloadSuccess or OnProfileDownloadFailure, so profile_image_fetcher_
has to be reset before calling these methods.

Bug: 736358
Change-Id: I5f16bd1c3b54f7f317957cf916ef1b9d93b30494
Reviewed-on: https://chromium-review.googlesource.com/546055Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481923}
parent 3f22b496
...@@ -237,9 +237,11 @@ void ProfileDownloader::OnURLFetchComplete(const net::URLFetcher* source) { ...@@ -237,9 +237,11 @@ void ProfileDownloader::OnURLFetchComplete(const net::URLFetcher* source) {
if (source->GetResponseCode() == net::HTTP_OK) { if (source->GetResponseCode() == net::HTTP_OK) {
std::string data; std::string data;
source->GetResponseAsString(&data); source->GetResponseAsString(&data);
profile_image_fetcher_.reset();
DVLOG(1) << "Decoding the image..."; DVLOG(1) << "Decoding the image...";
ImageDecoder::Start(this, data); ImageDecoder::Start(this, data);
} else if (source->GetResponseCode() == net::HTTP_NOT_FOUND) { } else if (source->GetResponseCode() == net::HTTP_NOT_FOUND) {
profile_image_fetcher_.reset();
VLOG(1) << "Got 404, using default picture..."; VLOG(1) << "Got 404, using default picture...";
picture_status_ = PICTURE_DEFAULT; picture_status_ = PICTURE_DEFAULT;
delegate_->OnProfileDownloadSuccess(this); delegate_->OnProfileDownloadSuccess(this);
...@@ -251,11 +253,11 @@ void ProfileDownloader::OnURLFetchComplete(const net::URLFetcher* source) { ...@@ -251,11 +253,11 @@ void ProfileDownloader::OnURLFetchComplete(const net::URLFetcher* source) {
DVLOG(1) << " Url: " << source->GetURL().spec(); DVLOG(1) << " Url: " << source->GetURL().spec();
bool network_error = bool network_error =
source->GetStatus().status() != net::URLRequestStatus::SUCCESS; source->GetStatus().status() != net::URLRequestStatus::SUCCESS;
profile_image_fetcher_.reset();
delegate_->OnProfileDownloadFailure(this, network_error ? delegate_->OnProfileDownloadFailure(this, network_error ?
ProfileDownloaderDelegate::NETWORK_ERROR : ProfileDownloaderDelegate::NETWORK_ERROR :
ProfileDownloaderDelegate::SERVICE_ERROR); ProfileDownloaderDelegate::SERVICE_ERROR);
} }
profile_image_fetcher_.reset();
} }
void ProfileDownloader::OnImageDecoded(const SkBitmap& decoded_image) { void ProfileDownloader::OnImageDecoded(const SkBitmap& decoded_image) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment