diff options
author | twellington <twellington@chromium.org> | 2015-03-31 17:33:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-01 00:34:33 +0000 |
commit | 612b9b6a87e75b87658eebf6a64474cca6395515 (patch) | |
tree | 8baf79f304324945183cb18b2766423d8cd7797c | |
parent | 07fd7b1e2615286d792a769585da93abf2be8015 (diff) | |
download | chromium_src-612b9b6a87e75b87658eebf6a64474cca6395515.zip chromium_src-612b9b6a87e75b87658eebf6a64474cca6395515.tar.gz chromium_src-612b9b6a87e75b87658eebf6a64474cca6395515.tar.bz2 |
Catch utility process StartBatchMode failures
BUG=472180
Review URL: https://codereview.chromium.org/1041043008
Cr-Commit-Position: refs/heads/master@{#323154}
-rw-r--r-- | chrome/browser/image_decoder.cc | 15 | ||||
-rw-r--r-- | chrome/browser/image_decoder.h | 5 |
2 files changed, 18 insertions, 2 deletions
diff --git a/chrome/browser/image_decoder.cc b/chrome/browser/image_decoder.cc index cfd887e..9e21662 100644 --- a/chrome/browser/image_decoder.cc +++ b/chrome/browser/image_decoder.cc @@ -80,6 +80,16 @@ void ImageDecoder::DecodeImageInSandbox( if (!utility_process_host_) { StartBatchMode(); } + if (!utility_process_host_) { + // Utility process failed to start; notify delegate and return. + // Without this check, we were seeing crashes on startup. Further + // investigation is needed to determine why the utility process + // is failing to start. See crbug.com/472272 + image_request->task_runner()->PostTask( + FROM_HERE, base::Bind(&ImageRequest::OnDecodeImageFailed, + base::Unretained(image_request))); + return; + } last_request_ = base::TimeTicks::Now(); base::AutoLock lock(map_lock_); @@ -117,7 +127,10 @@ void ImageDecoder::StartBatchMode() { utility_process_host_ = UtilityProcessHost::Create(this, base::MessageLoopProxy::current().get()) ->AsWeakPtr(); - utility_process_host_->StartBatchMode(); + if (!utility_process_host_->StartBatchMode()) { + utility_process_host_.reset(); + return; + } batch_mode_timer_.Start( FROM_HERE, base::TimeDelta::FromSeconds(kBatchModeTimeoutSeconds), this, &ImageDecoder::StopBatchMode); diff --git a/chrome/browser/image_decoder.h b/chrome/browser/image_decoder.h index d4615cf..438622c 100644 --- a/chrome/browser/image_decoder.h +++ b/chrome/browser/image_decoder.h @@ -85,7 +85,8 @@ class ImageDecoder : public content::UtilityProcessHostClient { ~ImageDecoder() override; // Sends a request to the sandboxed process to decode the image. Starts - // batch mode if necessary. + // batch mode if necessary. If the utility process fails to start, + // an OnDecodeImageFailed task is posted to image_request's |task_runner_|. void DecodeImageInSandbox(ImageRequest* image_request, const std::vector<unsigned char>& image_data, ImageCodec image_codec, @@ -96,6 +97,8 @@ class ImageDecoder : public content::UtilityProcessHostClient { using RequestMap = std::map<int, ImageRequest*>; // Starts UtilityProcessHost in batch mode and starts |batch_mode_timer_|. + // If the utility process fails to start, the method resets + // |utility_process_host_| and returns. void StartBatchMode(); // Stops batch mode if no requests have come in since |