Index: content/browser/renderer_host/resource_dispatcher_host_impl.cc |
diff --git a/content/browser/renderer_host/resource_dispatcher_host_impl.cc b/content/browser/renderer_host/resource_dispatcher_host_impl.cc |
index 607163d0f40730018a8a33f3abeefe14c1f779bd..87f5c6fe22906e1bfe206f456be6bba198a3951d 100644 |
--- a/content/browser/renderer_host/resource_dispatcher_host_impl.cc |
+++ b/content/browser/renderer_host/resource_dispatcher_host_impl.cc |
@@ -50,6 +50,7 @@ |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/content_browser_client.h" |
#include "content/public/browser/download_manager.h" |
+#include "content/public/browser/download_save_info.h" |
#include "content/public/browser/global_request_id.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/resource_dispatcher_host_delegate.h" |
@@ -500,6 +501,9 @@ net::Error ResourceDispatcherHostImpl::BeginDownload( |
int route_id, |
bool prefer_cache, |
const DownloadSaveInfo& save_info, |
+ const std::string& last_modified, |
+ const std::string& etag, |
+ content::DownloadId download_id, |
const DownloadStartedCallback& started_callback) { |
if (is_shutdown_) |
return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES); |
@@ -538,6 +542,27 @@ net::Error ResourceDispatcherHostImpl::BeginDownload( |
request_id_--; |
const net::URLRequestContext* request_context = context->GetRequestContext(); |
+ |
+ // If we're not at the beginning of the file, retrieve only the remaining |
+ // portion. |
+ if (save_info.offset > 0) { |
+ request->SetExtraRequestHeaderByName( |
+ "Range", |
+ StringPrintf("bytes=%" PRId64 "-", save_info.offset), |
+ true); |
+ } |
+ |
+ // If it's the second (or later) request for this file, make sure it |
+ // hasn't been modified. |
+ if (!last_modified.empty()) { |
+ request->SetExtraRequestHeaderByName("If-Unmodified-Since", |
+ last_modified, |
+ true); |
+ } |
+ if (!etag.empty()) { |
+ // Set requested ETAG. |
+ request->SetExtraRequestHeaderByName("If-Match", etag, true); |
+ } |
if (!request_context->job_factory()->IsHandledURL(url)) { |
VLOG(1) << "Download request for unsupported protocol: " |
<< url.possibly_invalid_spec(); |