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

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: Reorder two methods. 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
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..d2f42370b3644f452e592b11310edf6c3c04634f 100644
--- a/net/url_request/url_fetcher_response_writer.cc
+++ b/net/url_request/url_fetcher_response_writer.cc
@@ -102,8 +102,18 @@ int URLFetcherFileWriter::Write(IOBuffer* buffer,
}
int URLFetcherFileWriter::Finish(const CompletionCallback& callback) {
+ int result = file_stream_->Close(base::Bind(
+ &URLFetcherFileWriter::CloseComplete, base::Unretained(this), callback));
mmenke 2013/09/10 18:32:52 The base::Unretained changes the safe usage model
waffles 2013/09/10 21:41:34 Done.
+ if (result != ERR_IO_PENDING)
+ file_stream_.reset();
+ return result;
+}
+
+void URLFetcherFileWriter::CloseComplete(const CompletionCallback& callback,
+ int result) {
+ // Either we closed the file or we can't; either way destroy the file_stream.
file_stream_.reset();
- return OK;
+ callback.Run(result);
}
void URLFetcherFileWriter::DidWrite(const CompletionCallback& callback,
« net/base/file_stream_unittest.cc ('K') | « 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