Chromium Code Reviews| Index: libcurl_http_fetcher.cc |
| diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc |
| index d5358bd252118b90efa4fd8219192c51d2cf77ca..b65d6b1e2e71aa73abd72e1d4b8b300124a61912 100644 |
| --- a/libcurl_http_fetcher.cc |
| +++ b/libcurl_http_fetcher.cc |
| @@ -28,6 +28,8 @@ const char kCACertificatesPath[] = "/usr/share/update_engine/ca-certificates"; |
| } // namespace {} |
| LibcurlHttpFetcher::~LibcurlHttpFetcher() { |
| + LOG_IF(ERROR, transfer_in_progress_) |
| + << "Destroying the fetcher while a transfer is in progress."; |
| CleanUp(); |
| } |
| @@ -135,11 +137,20 @@ void LibcurlHttpFetcher::BeginTransfer(const std::string& url) { |
| CurlPerformOnce(); |
| } |
| +void LibcurlHttpFetcher::ForceTransferTermination() { |
| + CleanUp(); |
| + if (delegate_) { |
| + // Note that after the callback returns this object may be destroyed. |
|
adlr
2010/11/17 21:33:50
this comment seems important, maybe it should also
petkov
2010/11/17 21:47:54
You mean in the docstring for the ForceTransferTer
|
| + delegate_->TransferTerminated(this); |
| + } |
| +} |
| + |
| void LibcurlHttpFetcher::TerminateTransfer() { |
| - if (in_write_callback_) |
| + if (in_write_callback_) { |
| terminate_requested_ = true; |
| - else |
| - CleanUp(); |
| + } else { |
| + ForceTransferTermination(); |
| + } |
| } |
| void LibcurlHttpFetcher::CurlPerformOnce() { |
| @@ -152,7 +163,7 @@ void LibcurlHttpFetcher::CurlPerformOnce() { |
| while (CURLM_CALL_MULTI_PERFORM == retcode) { |
| retcode = curl_multi_perform(curl_multi_handle_, &running_handles); |
| if (terminate_requested_) { |
| - CleanUp(); |
| + ForceTransferTermination(); |
| return; |
| } |
| } |