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 21 matching lines...) Expand all Loading... |
32 #include "base/stl_util.h" | 32 #include "base/stl_util.h" |
33 #include "base/strings/string_util.h" | 33 #include "base/strings/string_util.h" |
34 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 34 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
35 #include "base/threading/thread_task_runner_handle.h" | 35 #include "base/threading/thread_task_runner_handle.h" |
36 #include "base/timer/timer.h" | 36 #include "base/timer/timer.h" |
37 #include "content/browser/appcache/appcache_interceptor.h" | 37 #include "content/browser/appcache/appcache_interceptor.h" |
38 #include "content/browser/appcache/appcache_navigation_handle_core.h" | 38 #include "content/browser/appcache/appcache_navigation_handle_core.h" |
39 #include "content/browser/appcache/chrome_appcache_service.h" | 39 #include "content/browser/appcache/chrome_appcache_service.h" |
40 #include "content/browser/bad_message.h" | 40 #include "content/browser/bad_message.h" |
41 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 41 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
| 42 #include "content/browser/browsing_data/clear_site_data_throttle.h" |
42 #include "content/browser/child_process_security_policy_impl.h" | 43 #include "content/browser/child_process_security_policy_impl.h" |
43 #include "content/browser/frame_host/navigation_request_info.h" | 44 #include "content/browser/frame_host/navigation_request_info.h" |
44 #include "content/browser/loader/async_resource_handler.h" | 45 #include "content/browser/loader/async_resource_handler.h" |
45 #include "content/browser/loader/detachable_resource_handler.h" | 46 #include "content/browser/loader/detachable_resource_handler.h" |
46 #include "content/browser/loader/intercepting_resource_handler.h" | 47 #include "content/browser/loader/intercepting_resource_handler.h" |
47 #include "content/browser/loader/loader_delegate.h" | 48 #include "content/browser/loader/loader_delegate.h" |
48 #include "content/browser/loader/mime_sniffing_resource_handler.h" | 49 #include "content/browser/loader/mime_sniffing_resource_handler.h" |
49 #include "content/browser/loader/mojo_async_resource_handler.h" | 50 #include "content/browser/loader/mojo_async_resource_handler.h" |
50 #include "content/browser/loader/navigation_resource_handler.h" | 51 #include "content/browser/loader/navigation_resource_handler.h" |
51 #include "content/browser/loader/navigation_resource_throttle.h" | 52 #include "content/browser/loader/navigation_resource_throttle.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)), | 354 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)), |
354 max_outstanding_requests_cost_per_process_( | 355 max_outstanding_requests_cost_per_process_( |
355 kMaxOutstandingRequestsCostPerProcess), | 356 kMaxOutstandingRequestsCostPerProcess), |
356 largest_outstanding_request_count_seen_(0), | 357 largest_outstanding_request_count_seen_(0), |
357 largest_outstanding_request_per_process_count_seen_(0), | 358 largest_outstanding_request_per_process_count_seen_(0), |
358 delegate_(nullptr), | 359 delegate_(nullptr), |
359 loader_delegate_(nullptr), | 360 loader_delegate_(nullptr), |
360 allow_cross_origin_auth_prompt_(false), | 361 allow_cross_origin_auth_prompt_(false), |
361 create_download_handler_intercept_(download_handler_intercept), | 362 create_download_handler_intercept_(download_handler_intercept), |
362 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 363 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
363 io_thread_task_runner_(io_thread_runner) { | 364 io_thread_task_runner_(io_thread_runner), |
| 365 experimental_web_features_enabled_( |
| 366 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 367 switches::kEnableExperimentalWebPlatformFeatures)) { |
364 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 368 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
365 DCHECK(!g_resource_dispatcher_host); | 369 DCHECK(!g_resource_dispatcher_host); |
366 g_resource_dispatcher_host = this; | 370 g_resource_dispatcher_host = this; |
367 | 371 |
368 ANNOTATE_BENIGN_RACE( | 372 ANNOTATE_BENIGN_RACE( |
369 &last_user_gesture_time_, | 373 &last_user_gesture_time_, |
370 "We don't care about the precise value, see http://crbug.com/92889"); | 374 "We don't care about the precise value, see http://crbug.com/92889"); |
371 | 375 |
372 io_thread_task_runner_->PostTask( | 376 io_thread_task_runner_->PostTask( |
373 FROM_HERE, | 377 FROM_HERE, |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 resource_type, | 1552 resource_type, |
1549 &throttles); | 1553 &throttles); |
1550 } | 1554 } |
1551 | 1555 |
1552 if (request->has_upload()) { | 1556 if (request->has_upload()) { |
1553 // Request wake lock while uploading data. | 1557 // Request wake lock while uploading data. |
1554 throttles.push_back( | 1558 throttles.push_back( |
1555 base::MakeUnique<WakeLockResourceThrottle>(request->url().host())); | 1559 base::MakeUnique<WakeLockResourceThrottle>(request->url().host())); |
1556 } | 1560 } |
1557 | 1561 |
| 1562 // The experimental Clear-Site-Data throttle. |
| 1563 if (experimental_web_features_enabled_) { |
| 1564 std::unique_ptr<ResourceThrottle> clear_site_data_throttle = |
| 1565 ClearSiteDataThrottle::MaybeCreateThrottleForRequest(request); |
| 1566 if (clear_site_data_throttle) |
| 1567 throttles.push_back(std::move(clear_site_data_throttle)); |
| 1568 } |
| 1569 |
1558 // TODO(ricea): Stop looking this up so much. | 1570 // TODO(ricea): Stop looking this up so much. |
1559 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 1571 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
1560 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id, | 1572 throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id, |
1561 info->IsAsync(), request)); | 1573 info->IsAsync(), request)); |
1562 | 1574 |
1563 // Split the handler in two groups: the ones that need to execute | 1575 // Split the handler in two groups: the ones that need to execute |
1564 // WillProcessResponse before mime sniffing and the others. | 1576 // WillProcessResponse before mime sniffing and the others. |
1565 std::vector<std::unique_ptr<ResourceThrottle>> pre_mime_sniffing_throttles; | 1577 std::vector<std::unique_ptr<ResourceThrottle>> pre_mime_sniffing_throttles; |
1566 std::vector<std::unique_ptr<ResourceThrottle>> post_mime_sniffing_throttles; | 1578 std::vector<std::unique_ptr<ResourceThrottle>> post_mime_sniffing_throttles; |
1567 for (auto& throttle : throttles) { | 1579 for (auto& throttle : throttles) { |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2670 &throttles); | 2682 &throttles); |
2671 if (!throttles.empty()) { | 2683 if (!throttles.empty()) { |
2672 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2684 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
2673 std::move(throttles))); | 2685 std::move(throttles))); |
2674 } | 2686 } |
2675 } | 2687 } |
2676 return handler; | 2688 return handler; |
2677 } | 2689 } |
2678 | 2690 |
2679 } // namespace content | 2691 } // namespace content |
OLD | NEW |