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

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 signed/unsigned compare issue. 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 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "content/browser/renderer_host/throttling_resource_handler.h" 42 #include "content/browser/renderer_host/throttling_resource_handler.h"
43 #include "content/browser/renderer_host/transfer_navigation_resource_throttle.h" 43 #include "content/browser/renderer_host/transfer_navigation_resource_throttle.h"
44 #include "content/browser/resource_context_impl.h" 44 #include "content/browser/resource_context_impl.h"
45 #include "content/browser/worker_host/worker_service_impl.h" 45 #include "content/browser/worker_host/worker_service_impl.h"
46 #include "content/common/resource_messages.h" 46 #include "content/common/resource_messages.h"
47 #include "content/common/ssl_status_serialization.h" 47 #include "content/common/ssl_status_serialization.h"
48 #include "content/common/view_messages.h" 48 #include "content/common/view_messages.h"
49 #include "content/public/browser/browser_thread.h" 49 #include "content/public/browser/browser_thread.h"
50 #include "content/public/browser/content_browser_client.h" 50 #include "content/public/browser/content_browser_client.h"
51 #include "content/public/browser/download_manager.h" 51 #include "content/public/browser/download_manager.h"
52 #include "content/public/browser/download_save_info.h"
52 #include "content/public/browser/global_request_id.h" 53 #include "content/public/browser/global_request_id.h"
53 #include "content/public/browser/notification_service.h" 54 #include "content/public/browser/notification_service.h"
54 #include "content/public/browser/resource_dispatcher_host_delegate.h" 55 #include "content/public/browser/resource_dispatcher_host_delegate.h"
55 #include "content/public/browser/resource_request_details.h" 56 #include "content/public/browser/resource_request_details.h"
56 #include "content/public/browser/resource_throttle.h" 57 #include "content/public/browser/resource_throttle.h"
57 #include "content/public/browser/user_metrics.h" 58 #include "content/public/browser/user_metrics.h"
58 #include "content/public/common/content_switches.h" 59 #include "content/public/common/content_switches.h"
59 #include "content/public/common/process_type.h" 60 #include "content/public/common/process_type.h"
60 #include "content/public/common/url_constants.h" 61 #include "content/public/common/url_constants.h"
61 #include "net/base/auth.h" 62 #include "net/base/auth.h"
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 } 492 }
492 493
493 net::Error ResourceDispatcherHostImpl::BeginDownload( 494 net::Error ResourceDispatcherHostImpl::BeginDownload(
494 scoped_ptr<net::URLRequest> request, 495 scoped_ptr<net::URLRequest> request,
495 bool is_content_initiated, 496 bool is_content_initiated,
496 ResourceContext* context, 497 ResourceContext* context,
497 int child_id, 498 int child_id,
498 int route_id, 499 int route_id,
499 bool prefer_cache, 500 bool prefer_cache,
500 scoped_ptr<DownloadSaveInfo> save_info, 501 scoped_ptr<DownloadSaveInfo> save_info,
502 const std::string& last_modified,
503 const std::string& etag,
504 content::DownloadId download_id,
501 const DownloadStartedCallback& started_callback) { 505 const DownloadStartedCallback& started_callback) {
502 if (is_shutdown_) 506 if (is_shutdown_)
503 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES); 507 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES);
504 508
505 const GURL& url = request->original_url(); 509 const GURL& url = request->original_url();
506 510
507 // http://crbug.com/90971 511 // http://crbug.com/90971
508 char url_buf[128]; 512 char url_buf[128];
509 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); 513 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf));
510 base::debug::Alias(url_buf); 514 base::debug::Alias(url_buf);
(...skipping 18 matching lines...) Expand all
529 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> 533 if (!ChildProcessSecurityPolicyImpl::GetInstance()->
530 CanRequestURL(child_id, url)) { 534 CanRequestURL(child_id, url)) {
531 VLOG(1) << "Denied unauthorized download request for " 535 VLOG(1) << "Denied unauthorized download request for "
532 << url.possibly_invalid_spec(); 536 << url.possibly_invalid_spec();
533 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED); 537 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED);
534 } 538 }
535 539
536 request_id_--; 540 request_id_--;
537 541
538 const net::URLRequestContext* request_context = context->GetRequestContext(); 542 const net::URLRequestContext* request_context = context->GetRequestContext();
543
544 // If we're not at the beginning of the file, retrieve only the remaining
545 // portion.
546 if (save_info->offset > 0) {
547 request->SetExtraRequestHeaderByName(
548 "Range",
549 StringPrintf("bytes=%" PRId64 "-", save_info->offset),
550 true);
551 }
552
553 // If it's the second (or later) request for this file, make sure it
554 // hasn't been modified.
555 if (!last_modified.empty()) {
556 request->SetExtraRequestHeaderByName("If-Unmodified-Since",
557 last_modified,
558 true);
559 }
560 if (!etag.empty()) {
561 // Set requested ETAG.
562 request->SetExtraRequestHeaderByName("If-Match", etag, true);
563 }
539 if (!request_context->job_factory()->IsHandledURL(url)) { 564 if (!request_context->job_factory()->IsHandledURL(url)) {
540 VLOG(1) << "Download request for unsupported protocol: " 565 VLOG(1) << "Download request for unsupported protocol: "
541 << url.possibly_invalid_spec(); 566 << url.possibly_invalid_spec();
542 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED); 567 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED);
543 } 568 }
544 569
545 ResourceRequestInfoImpl* extra_info = 570 ResourceRequestInfoImpl* extra_info =
546 CreateRequestInfo(child_id, route_id, true, context); 571 CreateRequestInfo(child_id, route_id, true, context);
547 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. 572 extra_info->AssociateWithRequest(request.get()); // Request takes ownership.
548 573
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 1745
1721 return i->second.get(); 1746 return i->second.get();
1722 } 1747 }
1723 1748
1724 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, 1749 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id,
1725 int request_id) const { 1750 int request_id) const {
1726 return GetLoader(GlobalRequestID(child_id, request_id)); 1751 return GetLoader(GlobalRequestID(child_id, request_id));
1727 } 1752 }
1728 1753
1729 } // namespace content 1754 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/resource_dispatcher_host_impl.h ('k') | content/browser/renderer_host/resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698