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

Unified Diff: mock_http_fetcher.cc

Issue 5009009: AU: Fix potential issues with premature destruction of HTTP fetchers. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: review comments Created 10 years, 1 month 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 | « libcurl_http_fetcher.cc ('k') | multi_http_fetcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mock_http_fetcher.cc
diff --git a/mock_http_fetcher.cc b/mock_http_fetcher.cc
index eec550f6f49765af1d831b5d4388f322c205cc38..1a88b94ef88d3a113d8d4ea36efa48890202b434 100644
--- a/mock_http_fetcher.cc
+++ b/mock_http_fetcher.cc
@@ -41,6 +41,11 @@ bool MockHttpFetcher::SendData(bool skip_delivery) {
data_.size() - sent_size_);
CHECK(delegate_);
delegate_->ReceivedBytes(this, &data_[sent_size_], chunk_size);
+ // We may get terminated in the callback.
+ if (sent_size_ == data_.size()) {
+ LOG(INFO) << "Terminated in the ReceivedBytes callback.";
+ return timeout_source_;
+ }
sent_size_ += chunk_size;
CHECK_LE(sent_size_, data_.size());
if (sent_size_ == data_.size()) {
@@ -81,6 +86,7 @@ bool MockHttpFetcher::TimeoutCallback() {
// If the transfer is in progress, aborts the transfer early.
// The transfer cannot be resumed.
void MockHttpFetcher::TerminateTransfer() {
+ LOG(INFO) << "Terminating transfer.";
sent_size_ = data_.size();
// kill any timeout
if (timeout_source_) {
@@ -88,6 +94,7 @@ void MockHttpFetcher::TerminateTransfer() {
g_source_destroy(timeout_source_);
timeout_source_ = NULL;
}
+ delegate_->TransferTerminated(this);
}
void MockHttpFetcher::Pause() {
« no previous file with comments | « libcurl_http_fetcher.cc ('k') | multi_http_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698