Chromium Code Reviews| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 namespace content { | 130 namespace content { |
| 131 | 131 |
| 132 namespace { | 132 namespace { |
| 133 | 133 |
| 134 static ResourceDispatcherHostImpl* g_resource_dispatcher_host; | 134 static ResourceDispatcherHostImpl* g_resource_dispatcher_host; |
| 135 | 135 |
| 136 // The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates | 136 // The interval for calls to ResourceDispatcherHostImpl::UpdateLoadStates |
| 137 const int kUpdateLoadStatesIntervalMsec = 250; | 137 const int kUpdateLoadStatesIntervalMsec = 250; |
| 138 | 138 |
| 139 // Maximum byte "cost" of all the outstanding requests for a renderer. | 139 // Maximum byte "cost" of all the outstanding requests for a renderer. |
| 140 // See delcaration of |max_outstanding_requests_cost_per_process_| for details. | 140 // See declaration of |max_outstanding_requests_cost_per_process_| for details. |
| 141 // This bound is 25MB, which allows for around 6000 outstanding requests. | 141 // This bound is 25MB, which allows for around 6000 outstanding requests. |
| 142 const int kMaxOutstandingRequestsCostPerProcess = 26214400; | 142 const int kMaxOutstandingRequestsCostPerProcess = 26214400; |
| 143 | 143 |
| 144 // The number of milliseconds after noting a user gesture that we will | 144 // The number of milliseconds after noting a user gesture that we will |
| 145 // tag newly-created URLRequest objects with the | 145 // tag newly-created URLRequest objects with the |
| 146 // net::LOAD_MAYBE_USER_GESTURE load flag. This is a fairly arbitrary | 146 // net::LOAD_MAYBE_USER_GESTURE load flag. This is a fairly arbitrary |
| 147 // guess at how long to expect direct impact from a user gesture, but | 147 // guess at how long to expect direct impact from a user gesture, but |
| 148 // this should be OK as the load flag is a best-effort thing only, | 148 // this should be OK as the load flag is a best-effort thing only, |
| 149 // rather than being intended as fully accurate. | 149 // rather than being intended as fully accurate. |
| 150 const int kUserGestureWindowMs = 3500; | 150 const int kUserGestureWindowMs = 3500; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 CreateDownloadHandlerIntercept download_handler_intercept, | 343 CreateDownloadHandlerIntercept download_handler_intercept, |
| 344 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_runner) | 344 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_runner) |
| 345 : request_id_(-1), | 345 : request_id_(-1), |
| 346 is_shutdown_(false), | 346 is_shutdown_(false), |
| 347 num_in_flight_requests_(0), | 347 num_in_flight_requests_(0), |
| 348 max_num_in_flight_requests_(base::SharedMemory::GetHandleLimit()), | 348 max_num_in_flight_requests_(base::SharedMemory::GetHandleLimit()), |
| 349 max_num_in_flight_requests_per_process_(static_cast<int>( | 349 max_num_in_flight_requests_per_process_(static_cast<int>( |
| 350 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)), | 350 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)), |
| 351 max_outstanding_requests_cost_per_process_( | 351 max_outstanding_requests_cost_per_process_( |
| 352 kMaxOutstandingRequestsCostPerProcess), | 352 kMaxOutstandingRequestsCostPerProcess), |
| 353 largest_outstanding_request_count_seen_(0), | |
| 354 largest_outstanding_request_per_process_count_seen_(0), | |
| 353 delegate_(nullptr), | 355 delegate_(nullptr), |
| 354 loader_delegate_(nullptr), | 356 loader_delegate_(nullptr), |
| 355 allow_cross_origin_auth_prompt_(false), | 357 allow_cross_origin_auth_prompt_(false), |
| 356 create_download_handler_intercept_(download_handler_intercept), | 358 create_download_handler_intercept_(download_handler_intercept), |
| 357 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 359 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 358 io_thread_task_runner_(io_thread_runner) { | 360 io_thread_task_runner_(io_thread_runner) { |
| 359 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 361 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 360 DCHECK(!g_resource_dispatcher_host); | 362 DCHECK(!g_resource_dispatcher_host); |
| 361 g_resource_dispatcher_host = this; | 363 g_resource_dispatcher_host = this; |
| 362 | 364 |
| (...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1897 // in-flight requests for this process, in case we need to transfer it to | 1899 // in-flight requests for this process, in case we need to transfer it to |
| 1898 // another process. This should be a toggle. | 1900 // another process. This should be a toggle. |
| 1899 DCHECK_NE(info->counted_as_in_flight_request(), count > 0); | 1901 DCHECK_NE(info->counted_as_in_flight_request(), count > 0); |
| 1900 info->set_counted_as_in_flight_request(count > 0); | 1902 info->set_counted_as_in_flight_request(count > 0); |
| 1901 | 1903 |
| 1902 OustandingRequestsStats stats = GetOutstandingRequestsStats(*info); | 1904 OustandingRequestsStats stats = GetOutstandingRequestsStats(*info); |
| 1903 stats.num_requests += count; | 1905 stats.num_requests += count; |
| 1904 DCHECK_GE(stats.num_requests, 0); | 1906 DCHECK_GE(stats.num_requests, 0); |
| 1905 UpdateOutstandingRequestsStats(*info, stats); | 1907 UpdateOutstandingRequestsStats(*info, stats); |
| 1906 | 1908 |
| 1909 if (num_in_flight_requests_ > largest_outstanding_request_count_seen_) { | |
|
Charlie Harrison
2017/04/19 23:08:28
I wonder if this would be better logged in Shutdow
xunjieli
2017/04/20 13:34:11
Similar to crbug.com/704988, Chrome on Android nev
Charlie Harrison
2017/04/20 13:39:16
OK, this LGTM but it would be preferable to hook i
xunjieli
2017/04/20 20:06:08
Acknowledged. I didn't find a way to hook it up wi
Charlie Harrison
2017/04/20 20:09:14
One possible way to implement it would be to pull
xunjieli
2017/04/20 20:14:15
Acknowledged. Thanks.
| |
| 1910 largest_outstanding_request_count_seen_ = num_in_flight_requests_; | |
| 1911 UMA_HISTOGRAM_COUNTS_1M( | |
| 1912 "Net.ResourceDispatcherHost.OutstandingRequests.Total", | |
| 1913 largest_outstanding_request_count_seen_); | |
| 1914 } | |
| 1915 | |
| 1916 if (stats.num_requests > largest_outstanding_request_count_seen_) { | |
| 1917 largest_outstanding_request_per_process_count_seen_ = stats.num_requests; | |
| 1918 UMA_HISTOGRAM_COUNTS_1M( | |
| 1919 "Net.ResourceDispatcherHost.OutstandingRequests.PerProcess", | |
| 1920 largest_outstanding_request_per_process_count_seen_); | |
| 1921 } | |
| 1922 | |
| 1907 return stats; | 1923 return stats; |
| 1908 } | 1924 } |
| 1909 | 1925 |
| 1910 bool ResourceDispatcherHostImpl::HasSufficientResourcesForRequest( | 1926 bool ResourceDispatcherHostImpl::HasSufficientResourcesForRequest( |
| 1911 net::URLRequest* request) { | 1927 net::URLRequest* request) { |
| 1912 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); | 1928 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request); |
| 1913 OustandingRequestsStats stats = IncrementOutstandingRequestsCount(1, info); | 1929 OustandingRequestsStats stats = IncrementOutstandingRequestsCount(1, info); |
| 1914 | 1930 |
| 1915 if (stats.num_requests > max_num_in_flight_requests_per_process_) | 1931 if (stats.num_requests > max_num_in_flight_requests_per_process_) |
| 1916 return false; | 1932 return false; |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2626 &throttles); | 2642 &throttles); |
| 2627 if (!throttles.empty()) { | 2643 if (!throttles.empty()) { |
| 2628 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2644 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
| 2629 std::move(throttles))); | 2645 std::move(throttles))); |
| 2630 } | 2646 } |
| 2631 } | 2647 } |
| 2632 return handler; | 2648 return handler; |
| 2633 } | 2649 } |
| 2634 | 2650 |
| 2635 } // namespace content | 2651 } // namespace content |
| OLD | NEW |