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

Unified Diff: chrome/browser/image_decoder.cc

Issue 1071453002: Fail all started requests if the utility process crashes or fails to start. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@racy-image-decoder
Patch Set: Rebase Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/image_decoder.h ('k') | chrome/browser/image_decoder_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/image_decoder.cc
diff --git a/chrome/browser/image_decoder.cc b/chrome/browser/image_decoder.cc
index 4498f33e1f0bfdb4f0e81302e060fd7aa7f85b7f..c3973a5ac843fbe3709120efc63cf9935bbbb710 100644
--- a/chrome/browser/image_decoder.cc
+++ b/chrome/browser/image_decoder.cc
@@ -176,6 +176,37 @@ void ImageDecoder::StopBatchMode() {
utility_process_host_->EndBatchMode();
utility_process_host_.reset();
}
+
+ // There could be outstanding request that are taking too long. Fail these so
+ // that there aren't any dangling requests.
+ FailAllRequests();
+}
+
+void ImageDecoder::FailAllRequests() {
+ RequestMap requests;
+ {
+ base::AutoLock lock(map_lock_);
+ requests = image_request_id_map_;
+ }
+
+ // Since |OnProcessCrashed| and |OnProcessLaunchFailed| are run asynchronously
+ // from the actual event, it's possible for a new utility process to have been
+ // created and sent requests by the time these functions are run. This results
+ // in failing requests that are unaffected by the crash. Although not ideal,
+ // this is valid and simpler than tracking which request is sent to which
+ // utility process, and whether the request has been sent at all.
+ for (const auto& request : requests)
+ OnDecodeImageFailed(request.first);
+}
+
+void ImageDecoder::OnProcessCrashed(int exit_code) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ FailAllRequests();
+}
+
+void ImageDecoder::OnProcessLaunchFailed() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ FailAllRequests();
}
bool ImageDecoder::OnMessageReceived(
« no previous file with comments | « chrome/browser/image_decoder.h ('k') | chrome/browser/image_decoder_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698