| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 #include "content/public/browser/global_request_id.h" | 80 #include "content/public/browser/global_request_id.h" |
| 81 #include "content/public/browser/navigation_ui_data.h" | 81 #include "content/public/browser/navigation_ui_data.h" |
| 82 #include "content/public/browser/plugin_service.h" | 82 #include "content/public/browser/plugin_service.h" |
| 83 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 83 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 84 #include "content/public/browser/resource_request_details.h" | 84 #include "content/public/browser/resource_request_details.h" |
| 85 #include "content/public/browser/resource_throttle.h" | 85 #include "content/public/browser/resource_throttle.h" |
| 86 #include "content/public/browser/stream_handle.h" | 86 #include "content/public/browser/stream_handle.h" |
| 87 #include "content/public/browser/stream_info.h" | 87 #include "content/public/browser/stream_info.h" |
| 88 #include "content/public/common/browser_side_navigation_policy.h" | 88 #include "content/public/common/browser_side_navigation_policy.h" |
| 89 #include "content/public/common/content_features.h" | 89 #include "content/public/common/content_features.h" |
| 90 #include "content/public/common/content_switches.h" | |
| 91 #include "content/public/common/resource_request.h" | 90 #include "content/public/common/resource_request.h" |
| 92 #include "content/public/common/resource_request_body.h" | 91 #include "content/public/common/resource_request_body.h" |
| 93 #include "content/public/common/resource_request_completion_status.h" | 92 #include "content/public/common/resource_request_completion_status.h" |
| 94 #include "ipc/ipc_message_macros.h" | 93 #include "ipc/ipc_message_macros.h" |
| 95 #include "ipc/ipc_message_start.h" | 94 #include "ipc/ipc_message_start.h" |
| 96 #include "net/base/auth.h" | 95 #include "net/base/auth.h" |
| 97 #include "net/base/load_flags.h" | 96 #include "net/base/load_flags.h" |
| 98 #include "net/base/mime_util.h" | 97 #include "net/base/mime_util.h" |
| 99 #include "net/base/net_errors.h" | 98 #include "net/base/net_errors.h" |
| 100 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 99 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)), | 339 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)), |
| 341 max_outstanding_requests_cost_per_process_( | 340 max_outstanding_requests_cost_per_process_( |
| 342 kMaxOutstandingRequestsCostPerProcess), | 341 kMaxOutstandingRequestsCostPerProcess), |
| 343 largest_outstanding_request_count_seen_(0), | 342 largest_outstanding_request_count_seen_(0), |
| 344 largest_outstanding_request_per_process_count_seen_(0), | 343 largest_outstanding_request_per_process_count_seen_(0), |
| 345 delegate_(nullptr), | 344 delegate_(nullptr), |
| 346 loader_delegate_(nullptr), | 345 loader_delegate_(nullptr), |
| 347 allow_cross_origin_auth_prompt_(false), | 346 allow_cross_origin_auth_prompt_(false), |
| 348 create_download_handler_intercept_(download_handler_intercept), | 347 create_download_handler_intercept_(download_handler_intercept), |
| 349 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 348 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 350 io_thread_task_runner_(io_thread_runner), | 349 io_thread_task_runner_(io_thread_runner) { |
| 351 experimental_web_features_enabled_( | |
| 352 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 353 switches::kEnableExperimentalWebPlatformFeatures)) { | |
| 354 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 350 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 355 DCHECK(!g_resource_dispatcher_host); | 351 DCHECK(!g_resource_dispatcher_host); |
| 356 g_resource_dispatcher_host = this; | 352 g_resource_dispatcher_host = this; |
| 357 | 353 |
| 358 ANNOTATE_BENIGN_RACE( | 354 ANNOTATE_BENIGN_RACE( |
| 359 &last_user_gesture_time_, | 355 &last_user_gesture_time_, |
| 360 "We don't care about the precise value, see http://crbug.com/92889"); | 356 "We don't care about the precise value, see http://crbug.com/92889"); |
| 361 | 357 |
| 362 io_thread_task_runner_->PostTask( | 358 io_thread_task_runner_->PostTask( |
| 363 FROM_HERE, | 359 FROM_HERE, |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 resource_type, | 1592 resource_type, |
| 1597 &throttles); | 1593 &throttles); |
| 1598 } | 1594 } |
| 1599 | 1595 |
| 1600 if (request->has_upload()) { | 1596 if (request->has_upload()) { |
| 1601 // Request wake lock while uploading data. | 1597 // Request wake lock while uploading data. |
| 1602 throttles.push_back( | 1598 throttles.push_back( |
| 1603 base::MakeUnique<WakeLockResourceThrottle>(request->url().host())); | 1599 base::MakeUnique<WakeLockResourceThrottle>(request->url().host())); |
| 1604 } | 1600 } |
| 1605 | 1601 |
| 1606 // The experimental Clear-Site-Data throttle. | 1602 // The Clear-Site-Data throttle. |
| 1607 if (experimental_web_features_enabled_) { | 1603 std::unique_ptr<ResourceThrottle> clear_site_data_throttle = |
| 1608 std::unique_ptr<ResourceThrottle> clear_site_data_throttle = | 1604 ClearSiteDataThrottle::MaybeCreateThrottleForRequest(request); |
| 1609 ClearSiteDataThrottle::MaybeCreateThrottleForRequest(request); | 1605 if (clear_site_data_throttle) |
| 1610 if (clear_site_data_throttle) | 1606 throttles.push_back(std::move(clear_site_data_throttle)); |
| 1611 throttles.push_back(std::move(clear_site_data_throttle)); | |
| 1612 } | |
| 1613 | 1607 |
| 1614 // TODO(ricea): Stop looking this up so much. | 1608 // TODO(ricea): Stop looking this up so much. |
| 1615 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 1609 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
| 1616 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id, | 1610 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id, |
| 1617 info->IsAsync(), request)); | 1611 info->IsAsync(), request)); |
| 1618 | 1612 |
| 1619 // Split the handler in two groups: the ones that need to execute | 1613 // Split the handler in two groups: the ones that need to execute |
| 1620 // WillProcessResponse before mime sniffing and the others. | 1614 // WillProcessResponse before mime sniffing and the others. |
| 1621 std::vector<std::unique_ptr<ResourceThrottle>> pre_mime_sniffing_throttles; | 1615 std::vector<std::unique_ptr<ResourceThrottle>> pre_mime_sniffing_throttles; |
| 1622 std::vector<std::unique_ptr<ResourceThrottle>> post_mime_sniffing_throttles; | 1616 std::vector<std::unique_ptr<ResourceThrottle>> post_mime_sniffing_throttles; |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2781 if (iter->second > 2) { | 2775 if (iter->second > 2) { |
| 2782 active_tabs++; | 2776 active_tabs++; |
| 2783 if (active_tabs >= 2) | 2777 if (active_tabs >= 2) |
| 2784 return true; | 2778 return true; |
| 2785 } | 2779 } |
| 2786 } | 2780 } |
| 2787 return false; | 2781 return false; |
| 2788 } | 2782 } |
| 2789 | 2783 |
| 2790 } // namespace content | 2784 } // namespace content |
| OLD | NEW |