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

Unified Diff: http_fetcher.h

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 | « download_action_unittest.cc ('k') | http_fetcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: http_fetcher.h
diff --git a/http_fetcher.h b/http_fetcher.h
index d0f9cb207ad4d72ee9f0fd9f8b5caa0a8c19d965..6d8608b62996f72d7d198983917471f360dc3913 100644
--- a/http_fetcher.h
+++ b/http_fetcher.h
@@ -45,11 +45,13 @@ class HttpFetcher {
// Downloading should resume from this offset
virtual void SetOffset(off_t offset) = 0;
- // Begins the transfer to the specified URL.
+ // Begins the transfer to the specified URL. This fetcher instance should not
+ // be destroyed until either TransferComplete, or TransferTerminated is
+ // called.
virtual void BeginTransfer(const std::string& url) = 0;
- // Aborts the transfer. TransferComplete() will not be called on the
- // delegate.
+ // Aborts the transfer. The transfer may not abort right away -- delegate's
+ // TransferTerminated() will be called when the transfer is actually done.
virtual void TerminateTransfer() = 0;
// If data is coming in too quickly, you can call Pause() to pause the
@@ -97,9 +99,14 @@ class HttpFetcherDelegate {
// Called if the fetcher seeks to a particular offset.
virtual void SeekToOffset(off_t offset) {}
- // Called when the transfer has completed successfully or been somehow
- // aborted.
+ // Called when the transfer has completed successfully or been aborted through
+ // means other than TerminateTransfer. It's OK to destroy the |fetcher| object
+ // in this callback.
virtual void TransferComplete(HttpFetcher* fetcher, bool successful) = 0;
+
+ // Called when the transfer has been aborted through TerminateTransfer. It's
+ // OK to destroy the |fetcher| object in this callback.
+ virtual void TransferTerminated(HttpFetcher* fetcher) {}
};
} // namespace chromeos_update_engine
« no previous file with comments | « download_action_unittest.cc ('k') | http_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698