Chromium Code Reviews| 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 d7b5211cca4f9c5cad700d19fcbacf145c7f87ee..392dc481c4bb105767e6b02cc7738d08d22b2c48 100644 |
| --- a/content/browser/download/download_resource_handler.cc |
| +++ b/content/browser/download/download_resource_handler.cc |
| @@ -51,7 +51,9 @@ DownloadResourceHandler::DownloadResourceHandler( |
| save_info_(save_info), |
| buffer_(new content::DownloadBuffer), |
| rdh_(rdh), |
| - is_paused_(false) { |
| + is_paused_(false), |
| + was_interrupted_(false), |
| + interrupted_bytes_(0) { |
| DCHECK(dl_id.IsValid()); |
| download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT); |
| } |
| @@ -94,7 +96,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 = was_interrupted_ ? interrupted_bytes_ : 0; |
| info->total_bytes = content_length_; |
| info->state = DownloadItem::IN_PROGRESS; |
| info->download_id = download_id_.local(); |
| @@ -102,12 +104,23 @@ 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 = was_interrupted_; |
| 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. |
| + // If we're starting a new download, get the last modified time and etag. |
|
Randy Smith (Not in Mondays)
2011/10/31 18:46:43
Why don't we get these all the time? Why conditio
ahendrickson
2011/11/13 21:15:20
Done.
|
| + if (was_interrupted_) { |
| + 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); |