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

Unified Diff: net/url_request/url_fetcher_response_writer.cc

Issue 23500006: URLFetcher won't call delegate until file is closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke's 3rd review Created 7 years, 3 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 | « net/url_request/url_fetcher_response_writer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cb30dad8089efd6acd2d699126782cce3d147c45..a7d5b5a8a24e8050de7c65d8760ba274dc690800 100644
--- a/net/url_request/url_fetcher_response_writer.cc
+++ b/net/url_request/url_fetcher_response_writer.cc
@@ -102,8 +102,19 @@ int URLFetcherFileWriter::Write(IOBuffer* buffer,
}
int URLFetcherFileWriter::Finish(const CompletionCallback& callback) {
+ int result = file_stream_->Close(base::Bind(
+ &URLFetcherFileWriter::CloseComplete,
+ weak_factory_.GetWeakPtr(), callback));
+ if (result != ERR_IO_PENDING)
+ file_stream_.reset();
+ return result;
+}
+
+void URLFetcherFileWriter::CloseComplete(const CompletionCallback& callback,
+ int result) {
+ // Destroy |file_stream_| whether or not the close succeeded.
file_stream_.reset();
- return OK;
+ callback.Run(result);
}
void URLFetcherFileWriter::DidWrite(const CompletionCallback& callback,
« no previous file with comments | « net/url_request/url_fetcher_response_writer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698