| 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/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 LoaderIOThreadNotifier::~LoaderIOThreadNotifier() {} | 524 LoaderIOThreadNotifier::~LoaderIOThreadNotifier() {} |
| 525 | 525 |
| 526 void LoaderIOThreadNotifier::RenderFrameDeleted( | 526 void LoaderIOThreadNotifier::RenderFrameDeleted( |
| 527 RenderFrameHost* render_frame_host) { | 527 RenderFrameHost* render_frame_host) { |
| 528 NotifyForRouteFromUI( | 528 NotifyForRouteFromUI( |
| 529 static_cast<RenderFrameHostImpl*>(render_frame_host) | 529 static_cast<RenderFrameHostImpl*>(render_frame_host) |
| 530 ->GetGlobalFrameRoutingId(), | 530 ->GetGlobalFrameRoutingId(), |
| 531 base::Bind(&ResourceDispatcherHostImpl::OnRenderFrameDeleted)); | 531 base::Bind(&ResourceDispatcherHostImpl::OnRenderFrameDeleted)); |
| 532 } | 532 } |
| 533 | 533 |
| 534 // static | |
| 535 ResourceDispatcherHost* ResourceDispatcherHost::Get() { | |
| 536 return g_resource_dispatcher_host; | |
| 537 } | |
| 538 | |
| 539 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() | 534 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() |
| 540 : save_file_manager_(new SaveFileManager()), | 535 : save_file_manager_(new SaveFileManager()), |
| 541 request_id_(-1), | 536 request_id_(-1), |
| 542 is_shutdown_(false), | 537 is_shutdown_(false), |
| 543 num_in_flight_requests_(0), | 538 num_in_flight_requests_(0), |
| 544 max_num_in_flight_requests_(base::SharedMemory::GetHandleLimit()), | 539 max_num_in_flight_requests_(base::SharedMemory::GetHandleLimit()), |
| 545 max_num_in_flight_requests_per_process_(static_cast<int>( | 540 max_num_in_flight_requests_per_process_(static_cast<int>( |
| 546 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)), | 541 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)), |
| 547 max_outstanding_requests_cost_per_process_( | 542 max_outstanding_requests_cost_per_process_( |
| 548 kMaxOutstandingRequestsCostPerProcess), | 543 kMaxOutstandingRequestsCostPerProcess), |
| 549 filter_(NULL), | 544 filter_(NULL), |
| 550 delegate_(NULL), | 545 delegate_(NULL), |
| 551 allow_cross_origin_auth_prompt_(false), | 546 allow_cross_origin_auth_prompt_(false), |
| 552 cert_store_for_testing_(nullptr) { | 547 cert_store_for_testing_(nullptr) { |
| 553 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 548 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 554 DCHECK(!g_resource_dispatcher_host); | 549 DCHECK(!g_resource_dispatcher_host); |
| 555 g_resource_dispatcher_host = this; | 550 g_resource_dispatcher_host = this; |
| 551 } |
| 556 | 552 |
| 553 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() { |
| 554 DCHECK(outstanding_requests_stats_map_.empty()); |
| 555 DCHECK(g_resource_dispatcher_host); |
| 556 g_resource_dispatcher_host = NULL; |
| 557 } |
| 558 |
| 559 void ResourceDispatcherHostImpl::Init() { |
| 557 GetContentClient()->browser()->ResourceDispatcherHostCreated(); | 560 GetContentClient()->browser()->ResourceDispatcherHostCreated(); |
| 558 | 561 |
| 559 ANNOTATE_BENIGN_RACE( | 562 ANNOTATE_BENIGN_RACE( |
| 560 &last_user_gesture_time_, | 563 &last_user_gesture_time_, |
| 561 "We don't care about the precise value, see http://crbug.com/92889"); | 564 "We don't care about the precise value, see http://crbug.com/92889"); |
| 562 | 565 |
| 563 BrowserThread::PostTask(BrowserThread::IO, | 566 BrowserThread::PostTask(BrowserThread::IO, |
| 564 FROM_HERE, | 567 FROM_HERE, |
| 565 base::Bind(&ResourceDispatcherHostImpl::OnInit, | 568 base::Bind(&ResourceDispatcherHostImpl::OnInit, |
| 566 base::Unretained(this))); | 569 base::Unretained(this))); |
| 567 | 570 |
| 568 update_load_states_timer_.reset(new base::RepeatingTimer()); | 571 update_load_states_timer_.reset(new base::RepeatingTimer()); |
| 569 | 572 |
| 570 // stale-while-revalidate currently doesn't work with browser-side navigation. | 573 // stale-while-revalidate currently doesn't work with browser-side navigation. |
| 571 // Only enable stale-while-revalidate if browser navigation is not enabled. | 574 // Only enable stale-while-revalidate if browser navigation is not enabled. |
| 572 // | 575 // |
| 573 // TODO(ricea): Make stale-while-revalidate and browser-side navigation work | 576 // TODO(ricea): Make stale-while-revalidate and browser-side navigation work |
| 574 // together. Or disable stale-while-revalidate completely before browser-side | 577 // together. Or disable stale-while-revalidate completely before browser-side |
| 575 // navigation becomes the default. crbug.com/561610 | 578 // navigation becomes the default. crbug.com/561610 |
| 576 if (!IsBrowserSideNavigationEnabled() && | 579 if (!IsBrowserSideNavigationEnabled() && |
| 577 base::FeatureList::IsEnabled(features::kStaleWhileRevalidate)) { | 580 base::FeatureList::IsEnabled(features::kStaleWhileRevalidate)) { |
| 578 async_revalidation_manager_.reset(new AsyncRevalidationManager); | 581 async_revalidation_manager_.reset(new AsyncRevalidationManager); |
| 579 } | 582 } |
| 580 } | 583 } |
| 581 | 584 |
| 582 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() { | |
| 583 DCHECK(outstanding_requests_stats_map_.empty()); | |
| 584 DCHECK(g_resource_dispatcher_host); | |
| 585 g_resource_dispatcher_host = NULL; | |
| 586 } | |
| 587 | |
| 588 // static | 585 // static |
| 589 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() { | 586 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() { |
| 590 return g_resource_dispatcher_host; | 587 return g_resource_dispatcher_host; |
| 591 } | 588 } |
| 592 | 589 |
| 593 // static | 590 // static |
| 594 void ResourceDispatcherHostImpl::ResumeBlockedRequestsForRouteFromUI( | 591 void ResourceDispatcherHostImpl::ResumeBlockedRequestsForRouteFromUI( |
| 595 const GlobalFrameRoutingId& global_routing_id) { | 592 const GlobalFrameRoutingId& global_routing_id) { |
| 596 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 593 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 597 NotifyForRouteFromUI( | 594 NotifyForRouteFromUI( |
| (...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2688 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); | 2685 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); |
| 2689 response->head.security_info = SerializeSecurityInfo(ssl); | 2686 response->head.security_info = SerializeSecurityInfo(ssl); |
| 2690 } | 2687 } |
| 2691 | 2688 |
| 2692 CertStore* ResourceDispatcherHostImpl::GetCertStore() { | 2689 CertStore* ResourceDispatcherHostImpl::GetCertStore() { |
| 2693 return cert_store_for_testing_ ? cert_store_for_testing_ | 2690 return cert_store_for_testing_ ? cert_store_for_testing_ |
| 2694 : CertStore::GetInstance(); | 2691 : CertStore::GetInstance(); |
| 2695 } | 2692 } |
| 2696 | 2693 |
| 2697 } // namespace content | 2694 } // namespace content |
| OLD | NEW |