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

Unified Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 11571025: Initial CL for Downloads resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix try bot problems. Created 8 years 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/loader/resource_dispatcher_host_impl.cc
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index fd945c744a5fe8c85659d748a10017c1eab5d4b0..f92401088c40aa1509a1743ad4edb50de88deec0 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -49,6 +49,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"
@@ -498,6 +499,9 @@ net::Error ResourceDispatcherHostImpl::BeginDownload(
int route_id,
bool prefer_cache,
scoped_ptr<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);
@@ -536,6 +540,27 @@ net::Error ResourceDispatcherHostImpl::BeginDownload(
request_id_--;
const net::URLRequestContext* request_context = context->GetRequestContext();
+
asanka 2012/12/28 22:01:42 Can we move this to where we construct the URLRequ
Randy Smith (Not in Mondays) 2012/12/29 17:16:16 Chuckle. Sure. I was going to do a separate eval
+ // 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 we've asked for a range, we want to make sure that we only
+ // get that range if our current copy of the information is good.
+ if (!last_modified.empty()) {
+ request->SetExtraRequestHeaderByName("If-Unmodified-Since",
+ last_modified,
+ true);
+ }
+ if (!etag.empty()) {
+ request->SetExtraRequestHeaderByName("If-Match", etag, true);
+ }
+ }
+
if (!request_context->job_factory()->IsHandledURL(url)) {
VLOG(1) << "Download request for unsupported protocol: "
<< url.possibly_invalid_spec();
@@ -550,7 +575,7 @@ net::Error ResourceDispatcherHostImpl::BeginDownload(
// |started_callback|.
scoped_ptr<ResourceHandler> handler(
CreateResourceHandlerForDownload(request.get(), is_content_initiated,
- true, save_info.Pass(),
+ true, download_id, save_info.Pass(),
started_callback));
BeginRequestInternal(request.Pass(), handler.Pass());
@@ -581,10 +606,11 @@ ResourceDispatcherHostImpl::CreateResourceHandlerForDownload(
net::URLRequest* request,
bool is_content_initiated,
bool must_download,
+ DownloadId id,
scoped_ptr<DownloadSaveInfo> save_info,
const DownloadResourceHandler::OnStartedCallback& started_cb) {
scoped_ptr<ResourceHandler> handler(
- new DownloadResourceHandler(request, started_cb, save_info.Pass()));
+ new DownloadResourceHandler(id, request, started_cb, save_info.Pass()));
if (delegate_) {
const ResourceRequestInfo* request_info(
ResourceRequestInfo::ForRequest(request));

Powered by Google App Engine
This is Rietveld 408576698