OLD | NEW |
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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 } | 492 } |
493 } | 493 } |
494 | 494 |
495 net::Error ResourceDispatcherHostImpl::BeginDownload( | 495 net::Error ResourceDispatcherHostImpl::BeginDownload( |
496 scoped_ptr<net::URLRequest> request, | 496 scoped_ptr<net::URLRequest> request, |
497 bool is_content_initiated, | 497 bool is_content_initiated, |
498 ResourceContext* context, | 498 ResourceContext* context, |
499 int child_id, | 499 int child_id, |
500 int route_id, | 500 int route_id, |
501 bool prefer_cache, | 501 bool prefer_cache, |
502 const DownloadSaveInfo& save_info, | 502 scoped_ptr<DownloadSaveInfo> save_info, |
503 const DownloadStartedCallback& started_callback) { | 503 const DownloadStartedCallback& started_callback) { |
504 if (is_shutdown_) | 504 if (is_shutdown_) |
505 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES); | 505 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES); |
506 | 506 |
507 const GURL& url = request->original_url(); | 507 const GURL& url = request->original_url(); |
508 | 508 |
509 // http://crbug.com/90971 | 509 // http://crbug.com/90971 |
510 char url_buf[128]; | 510 char url_buf[128]; |
511 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); | 511 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); |
512 base::debug::Alias(url_buf); | 512 base::debug::Alias(url_buf); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 } | 545 } |
546 | 546 |
547 ResourceRequestInfoImpl* extra_info = | 547 ResourceRequestInfoImpl* extra_info = |
548 CreateRequestInfo(child_id, route_id, true, context); | 548 CreateRequestInfo(child_id, route_id, true, context); |
549 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. | 549 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. |
550 | 550 |
551 // From this point forward, the |DownloadResourceHandler| is responsible for | 551 // From this point forward, the |DownloadResourceHandler| is responsible for |
552 // |started_callback|. | 552 // |started_callback|. |
553 scoped_ptr<ResourceHandler> handler( | 553 scoped_ptr<ResourceHandler> handler( |
554 CreateResourceHandlerForDownload(request.get(), is_content_initiated, | 554 CreateResourceHandlerForDownload(request.get(), is_content_initiated, |
555 save_info, started_callback)); | 555 save_info.Pass(), started_callback)); |
556 | 556 |
557 BeginRequestInternal(request.Pass(), handler.Pass()); | 557 BeginRequestInternal(request.Pass(), handler.Pass()); |
558 | 558 |
559 return net::OK; | 559 return net::OK; |
560 } | 560 } |
561 | 561 |
562 void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest( | 562 void ResourceDispatcherHostImpl::ClearLoginDelegateForRequest( |
563 net::URLRequest* request) { | 563 net::URLRequest* request) { |
564 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 564 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
565 if (info) { | 565 if (info) { |
566 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID()); | 566 ResourceLoader* loader = GetLoader(info->GetGlobalRequestID()); |
567 if (loader) | 567 if (loader) |
568 loader->ClearLoginDelegate(); | 568 loader->ClearLoginDelegate(); |
569 } | 569 } |
570 } | 570 } |
571 | 571 |
572 void ResourceDispatcherHostImpl::Shutdown() { | 572 void ResourceDispatcherHostImpl::Shutdown() { |
573 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 573 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
574 BrowserThread::PostTask(BrowserThread::IO, | 574 BrowserThread::PostTask(BrowserThread::IO, |
575 FROM_HERE, | 575 FROM_HERE, |
576 base::Bind(&ResourceDispatcherHostImpl::OnShutdown, | 576 base::Bind(&ResourceDispatcherHostImpl::OnShutdown, |
577 base::Unretained(this))); | 577 base::Unretained(this))); |
578 } | 578 } |
579 | 579 |
580 scoped_ptr<ResourceHandler> | 580 scoped_ptr<ResourceHandler> |
581 ResourceDispatcherHostImpl::CreateResourceHandlerForDownload( | 581 ResourceDispatcherHostImpl::CreateResourceHandlerForDownload( |
582 net::URLRequest* request, | 582 net::URLRequest* request, |
583 bool is_content_initiated, | 583 bool is_content_initiated, |
584 const DownloadSaveInfo& save_info, | 584 scoped_ptr<DownloadSaveInfo> save_info, |
585 const DownloadResourceHandler::OnStartedCallback& started_cb) { | 585 const DownloadResourceHandler::OnStartedCallback& started_cb) { |
586 scoped_ptr<ResourceHandler> handler( | 586 scoped_ptr<ResourceHandler> handler( |
587 new DownloadResourceHandler(request, started_cb, save_info)); | 587 new DownloadResourceHandler(request, started_cb, save_info.Pass())); |
588 if (delegate_) { | 588 if (delegate_) { |
589 const ResourceRequestInfo* request_info( | 589 const ResourceRequestInfo* request_info( |
590 ResourceRequestInfo::ForRequest(request)); | 590 ResourceRequestInfo::ForRequest(request)); |
591 | 591 |
592 ScopedVector<ResourceThrottle> throttles; | 592 ScopedVector<ResourceThrottle> throttles; |
593 delegate_->DownloadStarting( | 593 delegate_->DownloadStarting( |
594 request, request_info->GetContext(), request_info->GetChildID(), | 594 request, request_info->GetContext(), request_info->GetChildID(), |
595 request_info->GetRouteID(), request_info->GetRequestID(), | 595 request_info->GetRouteID(), request_info->GetRequestID(), |
596 is_content_initiated, &throttles); | 596 is_content_initiated, &throttles); |
597 if (!throttles.empty()) { | 597 if (!throttles.empty()) { |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 | 1723 |
1724 return i->second.get(); | 1724 return i->second.get(); |
1725 } | 1725 } |
1726 | 1726 |
1727 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, | 1727 ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, |
1728 int request_id) const { | 1728 int request_id) const { |
1729 return GetLoader(GlobalRequestID(child_id, request_id)); | 1729 return GetLoader(GlobalRequestID(child_id, request_id)); |
1730 } | 1730 } |
1731 | 1731 |
1732 } // namespace content | 1732 } // namespace content |
OLD | NEW |