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

Unified Diff: content/browser/download/download_resource_handler.cc

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with trunk. Created 9 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
Index: content/browser/download/download_resource_handler.cc
diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc
index d703e1472222e4bbf9506ff013164b8c0eef854f..31d3385ac1ca219e8678d8a577cd2c8d93378f24 100644
--- a/content/browser/download/download_resource_handler.cc
+++ b/content/browser/download/download_resource_handler.cc
@@ -53,7 +53,8 @@ DownloadResourceHandler::DownloadResourceHandler(
save_info_(save_info),
buffer_(new content::DownloadBuffer),
rdh_(rdh),
- is_paused_(false) {
+ is_paused_(false),
+ start_offset_(0) {
DCHECK(dl_id.IsValid());
download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT);
}
@@ -100,7 +101,7 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id,
info->url_chain = request_->url_chain();
info->referrer_url = GURL(request_->referrer());
info->start_time = base::Time::Now();
- info->received_bytes = 0;
+ info->received_bytes = start_offset_;
info->total_bytes = content_length_;
info->state = DownloadItem::IN_PROGRESS;
info->download_id = download_id_;
@@ -108,12 +109,21 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id,
info->content_disposition = content_disposition_;
info->mime_type = response->response_head.mime_type;
download_stats::RecordDownloadMimeType(info->mime_type);
+ info->continued_download = (start_offset_ > 0);
DownloadRequestHandle request_handle(rdh_, global_id_.child_id,
render_view_id_, global_id_.request_id);
- // TODO(ahendrickson) -- Get the last modified time and etag, so we can
- // resume downloading.
+ // Get the last modified time and etag.
+ const net::HttpResponseHeaders* headers = request_->response_headers();
+ if (headers) {
+ std::string last_modified_hdr;
+ std::string etag;
+ if (headers->EnumerateHeader(NULL, "Last-Modified", &last_modified_hdr))
+ info->last_modified = last_modified_hdr;
+ if (headers->EnumerateHeader(NULL, "ETag", &etag))
+ info->etag = etag;
+ }
CallStartedCB(net::OK);

Powered by Google App Engine
This is Rietveld 408576698