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

Unified Diff: net/url_request/url_fetcher_response_writer.cc

Issue 2425673006: Make URLFetcherFileWriter::Finish() skip closing file when there is an error (Closed)
Patch Set: Address comments and added tests Created 4 years, 2 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
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(

Powered by Google App Engine
This is Rietveld 408576698