AU: MultiHttpFetcher, an HttpFetcher for specific byte ranges
MultiHttpFetcher takes an HttpFetcher class via template parameter,
and a collection of byte ranges. It hits up the URL multiple times,
once per range specified. For each time, it uses a new HttpFetcher of
the type specified and fast-forwards to the offset requested, and
aborting after enough bytes have been downloaded. Any range many
specify a length of -1, which means until the end of the file (as
dictated by the server). Thus, a single range of [0, -1] makes
MultiHttpFetcher a pass-through.
HttpFetcher change: ability to supply an offset.
LibcurlHttpFetcher changes: offset support (from HttpFetcher API),
ability to be terminted in a write-callback.
test_http_fetcher: support for failures in write() on the socket (at
least in the /big url case).
BUG=7391
TEST=unittests
Review URL: http://codereview.chromium.org/3591018
diff --git a/http_fetcher.h b/http_fetcher.h
index f8e510a..f61116a 100644
--- a/http_fetcher.h
+++ b/http_fetcher.h
@@ -42,6 +42,9 @@
post_data_.insert(post_data_.end(), char_data, char_data + size);
}
+ // Downloading should resume from this offset
+ virtual void SetOffset(off_t offset) = 0;
+
// Begins the transfer to the specified URL.
virtual void BeginTransfer(const std::string& url) = 0;
@@ -59,6 +62,11 @@
// Unpause() returns
virtual void Unpause() = 0;
+ // These two function are overloaded in LibcurlHttp fetcher to speed
+ // testing.
+ virtual void set_idle_seconds(int seconds) {}
+ virtual void set_retry_seconds(int seconds) {}
+
protected:
// The URL we're actively fetching from
std::string url_;