Index: net/url_request/url_fetcher_response_writer.cc |
diff --git a/net/url_request/url_fetcher_response_writer.cc b/net/url_request/url_fetcher_response_writer.cc |
index fcc8cbf38ffc4129245cd2cf2ceb63466e112a67..5b369b35f334f83a4ffaeb67d32a5488eea65e10 100644 |
--- a/net/url_request/url_fetcher_response_writer.cc |
+++ b/net/url_request/url_fetcher_response_writer.cc |
@@ -40,7 +40,8 @@ int URLFetcherStringWriter::Write(IOBuffer* buffer, |
return num_bytes; |
} |
-int URLFetcherStringWriter::Finish(const CompletionCallback& callback) { |
+int URLFetcherStringWriter::Finish(int net_error, |
+ const CompletionCallback& callback) { |
// Do nothing. |
return OK; |
} |
@@ -106,7 +107,16 @@ int URLFetcherFileWriter::Write(IOBuffer* buffer, |
return result; |
} |
-int URLFetcherFileWriter::Finish(const CompletionCallback& callback) { |
+int URLFetcherFileWriter::Finish(int net_error, |
+ const CompletionCallback& callback) { |
+ DCHECK_NE(ERR_IO_PENDING, net_error); |
+ if (net_error < 0) { |
+ // If an error occurred, simply delete the file after any pending operation |
+ // is done. Do not call file_stream_->Close() because there might |
+ // be an operation pending. See crbug.com/487732. |
+ CloseAndDeleteFile(); |
+ return OK; |
+ } |
// If the file_stream_ still exists at this point, close it. |
if (file_stream_) { |
int result = file_stream_->Close(base::Bind( |