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

Side by Side Diff: content/browser/renderer_host/resource_dispatcher_host_impl.cc

Issue 10831302: Download resumption - Preliminary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed content unit tests. Created 8 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" 7 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h"
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "content/browser/renderer_host/throttling_resource_handler.h" 43 #include "content/browser/renderer_host/throttling_resource_handler.h"
44 #include "content/browser/renderer_host/transfer_navigation_resource_throttle.h" 44 #include "content/browser/renderer_host/transfer_navigation_resource_throttle.h"
45 #include "content/browser/resource_context_impl.h" 45 #include "content/browser/resource_context_impl.h"
46 #include "content/browser/worker_host/worker_service_impl.h" 46 #include "content/browser/worker_host/worker_service_impl.h"
47 #include "content/common/resource_messages.h" 47 #include "content/common/resource_messages.h"
48 #include "content/common/ssl_status_serialization.h" 48 #include "content/common/ssl_status_serialization.h"
49 #include "content/common/view_messages.h" 49 #include "content/common/view_messages.h"
50 #include "content/public/browser/browser_thread.h" 50 #include "content/public/browser/browser_thread.h"
51 #include "content/public/browser/content_browser_client.h" 51 #include "content/public/browser/content_browser_client.h"
52 #include "content/public/browser/download_manager.h" 52 #include "content/public/browser/download_manager.h"
53 #include "content/public/browser/download_save_info.h"
53 #include "content/public/browser/global_request_id.h" 54 #include "content/public/browser/global_request_id.h"
54 #include "content/public/browser/notification_service.h" 55 #include "content/public/browser/notification_service.h"
55 #include "content/public/browser/resource_dispatcher_host_delegate.h" 56 #include "content/public/browser/resource_dispatcher_host_delegate.h"
56 #include "content/public/browser/resource_request_details.h" 57 #include "content/public/browser/resource_request_details.h"
57 #include "content/public/browser/resource_throttle.h" 58 #include "content/public/browser/resource_throttle.h"
58 #include "content/public/browser/user_metrics.h" 59 #include "content/public/browser/user_metrics.h"
59 #include "content/public/common/content_switches.h" 60 #include "content/public/common/content_switches.h"
60 #include "content/public/common/process_type.h" 61 #include "content/public/common/process_type.h"
61 #include "content/public/common/url_constants.h" 62 #include "content/public/common/url_constants.h"
62 #include "net/base/auth.h" 63 #include "net/base/auth.h"
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 } 494 }
494 495
495 net::Error ResourceDispatcherHostImpl::BeginDownload( 496 net::Error ResourceDispatcherHostImpl::BeginDownload(
496 scoped_ptr<net::URLRequest> request, 497 scoped_ptr<net::URLRequest> request,
497 bool is_content_initiated, 498 bool is_content_initiated,
498 ResourceContext* context, 499 ResourceContext* context,
499 int child_id, 500 int child_id,
500 int route_id, 501 int route_id,
501 bool prefer_cache, 502 bool prefer_cache,
502 const DownloadSaveInfo& save_info, 503 const DownloadSaveInfo& save_info,
504 const std::string& last_modified,
505 const std::string& etag,
506 content::DownloadId download_id,
503 const DownloadStartedCallback& started_callback) { 507 const DownloadStartedCallback& started_callback) {
504 if (is_shutdown_) 508 if (is_shutdown_)
505 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES); 509 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES);
506 510
507 const GURL& url = request->original_url(); 511 const GURL& url = request->original_url();
508 512
509 // http://crbug.com/90971 513 // http://crbug.com/90971
510 char url_buf[128]; 514 char url_buf[128];
511 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); 515 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf));
512 base::debug::Alias(url_buf); 516 base::debug::Alias(url_buf);
(...skipping 18 matching lines...) Expand all
531 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> 535 if (!ChildProcessSecurityPolicyImpl::GetInstance()->
532 CanRequestURL(child_id, url)) { 536 CanRequestURL(child_id, url)) {
533 VLOG(1) << "Denied unauthorized download request for " 537 VLOG(1) << "Denied unauthorized download request for "
534 << url.possibly_invalid_spec(); 538 << url.possibly_invalid_spec();
535 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED); 539 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED);
536 } 540 }
537 541
538 request_id_--; 542 request_id_--;
539 543
540 const net::URLRequestContext* request_context = context->GetRequestContext(); 544 const net::URLRequestContext* request_context = context->GetRequestContext();
545
546 // If we're not at the beginning of the file, retrieve only the remaining
547 // portion.
548 if (save_info.offset > 0) {
549 request->SetExtraRequestHeaderByName(
550 "Range",
551 StringPrintf("bytes=%" PRId64 "-", save_info.offset),
552 true);
553 }
554
555 // If it's the second (or later) request for this file, make sure it
556 // hasn't been modified.
557 if (!last_modified.empty()) {
558 request->SetExtraRequestHeaderByName("If-Unmodified-Since",
559 last_modified,
560 true);
561 }
562 if (!etag.empty()) {
563 // Set requested ETAG.
564 request->SetExtraRequestHeaderByName("If-Match", etag, true);
565 }
541 if (!request_context->job_factory()->IsHandledURL(url)) { 566 if (!request_context->job_factory()->IsHandledURL(url)) {
542 VLOG(1) << "Download request for unsupported protocol: " 567 VLOG(1) << "Download request for unsupported protocol: "
543 << url.possibly_invalid_spec(); 568 << url.possibly_invalid_spec();
544 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED); 569 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED);
545 } 570 }
546 571
547 ResourceRequestInfoImpl* extra_info = 572 ResourceRequestInfoImpl* extra_info =
548 CreateRequestInfo(child_id, route_id, true, context); 573 CreateRequestInfo(child_id, route_id, true, context);
549 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. 574 extra_info->AssociateWithRequest(request.get()); // Request takes ownership.
550 575
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 1748
1724 return i->second.get(); 1749 return i->second.get();
1725 } 1750 }
1726 1751
1727 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, 1752 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id,
1728 int request_id) const { 1753 int request_id) const {
1729 return GetLoader(GlobalRequestID(child_id, request_id)); 1754 return GetLoader(GlobalRequestID(child_id, request_id));
1730 } 1755 }
1731 1756
1732 } // namespace content 1757 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698