Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: content/browser/loader/resource_scheduler.cc

Issue 893693002: Fix bug where requests to QUIC servers were throttled by the resource scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/http/http_server_properties.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <set> 5 #include <set>
6 6
7 #include "content/browser/loader/resource_scheduler.h" 7 #include "content/browser/loader/resource_scheduler.h"
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 class ResourceScheduler::Client { 295 class ResourceScheduler::Client {
296 public: 296 public:
297 explicit Client(ResourceScheduler* scheduler, 297 explicit Client(ResourceScheduler* scheduler,
298 bool is_visible, 298 bool is_visible,
299 bool is_audible) 299 bool is_audible)
300 : is_audible_(is_audible), 300 : is_audible_(is_audible),
301 is_visible_(is_visible), 301 is_visible_(is_visible),
302 is_loaded_(false), 302 is_loaded_(false),
303 is_paused_(false), 303 is_paused_(false),
304 has_body_(false), 304 has_body_(false),
305 using_spdy_proxy_(false), 305 using_spdy_proxy_(false),
mmenke 2015/01/30 22:04:16 Is there a QUIC proxy being worked on?
Ryan Hamilton 2015/01/30 22:53:47 Yes, it's just getting started. We'll need to make
306 load_started_time_(base::TimeTicks::Now()), 306 load_started_time_(base::TimeTicks::Now()),
307 scheduler_(scheduler), 307 scheduler_(scheduler),
308 in_flight_delayable_count_(0), 308 in_flight_delayable_count_(0),
309 total_layout_blocking_count_(0), 309 total_layout_blocking_count_(0),
310 throttle_state_(ResourceScheduler::THROTTLED) {} 310 throttle_state_(ResourceScheduler::THROTTLED) {}
311 311
312 ~Client() { 312 ~Client() {
313 // Update to default state and pause to ensure the scheduler has a 313 // Update to default state and pause to ensure the scheduler has a
314 // correct count of relevant types of clients. 314 // correct count of relevant types of clients.
315 is_visible_ = false; 315 is_visible_ = false;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 } 466 }
467 } 467 }
468 468
469 void ReprioritizeRequest(ScheduledResourceRequest* request, 469 void ReprioritizeRequest(ScheduledResourceRequest* request,
470 RequestPriorityParams old_priority_params, 470 RequestPriorityParams old_priority_params,
471 RequestPriorityParams new_priority_params) { 471 RequestPriorityParams new_priority_params) {
472 request->url_request()->SetPriority(new_priority_params.priority); 472 request->url_request()->SetPriority(new_priority_params.priority);
473 request->set_request_priority_params(new_priority_params); 473 request->set_request_priority_params(new_priority_params);
474 if (!pending_requests_.IsQueued(request)) { 474 if (!pending_requests_.IsQueued(request)) {
475 DCHECK(ContainsKey(in_flight_requests_, request)); 475 DCHECK(ContainsKey(in_flight_requests_, request));
476 // The priority and SPDY support may have changed, so update the 476 // The priority and SPDY support may have changed, so update the
mmenke 2015/01/30 22:04:16 This now applies to QUIC, too.
Ryan Hamilton 2015/01/30 22:53:47 Done.
477 // delayable count. 477 // delayable count.
478 SetRequestClassification(request, ClassifyRequest(request)); 478 SetRequestClassification(request, ClassifyRequest(request));
479 // Request has already started. 479 // Request has already started.
480 return; 480 return;
481 } 481 }
482 482
483 pending_requests_.Erase(request); 483 pending_requests_.Erase(request);
484 pending_requests_.Insert(request); 484 pending_requests_.Insert(request);
485 485
486 if (new_priority_params.priority > old_priority_params.priority) { 486 if (new_priority_params.priority > old_priority_params.priority) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 } 610 }
611 611
612 if (!has_body_ && request->url_request()->priority() > net::LOW) 612 if (!has_body_ && request->url_request()->priority() > net::LOW)
613 return LAYOUT_BLOCKING_REQUEST; 613 return LAYOUT_BLOCKING_REQUEST;
614 614
615 if (request->url_request()->priority() < net::LOW) { 615 if (request->url_request()->priority() < net::LOW) {
616 net::HostPortPair host_port_pair = 616 net::HostPortPair host_port_pair =
617 net::HostPortPair::FromURL(request->url_request()->url()); 617 net::HostPortPair::FromURL(request->url_request()->url());
618 net::HttpServerProperties& http_server_properties = 618 net::HttpServerProperties& http_server_properties =
619 *request->url_request()->context()->http_server_properties(); 619 *request->url_request()->context()->http_server_properties();
620 if (!http_server_properties.SupportsSpdy(host_port_pair) && 620 if (!http_server_properties.SupportsRequestPriority(host_port_pair) &&
621 ContainsKey(in_flight_requests_, request)) { 621 ContainsKey(in_flight_requests_, request)) {
622 return IN_FLIGHT_DELAYABLE_REQUEST; 622 return IN_FLIGHT_DELAYABLE_REQUEST;
623 } 623 }
624 } 624 }
625 return NORMAL_REQUEST; 625 return NORMAL_REQUEST;
626 } 626 }
627 627
628 bool ShouldKeepSearching( 628 bool ShouldKeepSearching(
629 const net::HostPortPair& active_request_host) const { 629 const net::HostPortPair& active_request_host) const {
630 size_t same_host_count = 0; 630 size_t same_host_count = 0;
(...skipping 30 matching lines...) Expand all
661 // 661 //
662 // 4. Layout-blocking requests: 662 // 4. Layout-blocking requests:
663 // * High-priority requests (> net::LOW) initiated before the renderer has 663 // * High-priority requests (> net::LOW) initiated before the renderer has
664 // a <body>. 664 // a <body>.
665 // 665 //
666 // 5. Low priority requests 666 // 5. Low priority requests
667 // 667 //
668 // The following rules are followed: 668 // The following rules are followed:
669 // 669 //
670 // ACTIVE_AND_LOADING and UNTHROTTLED Clients follow these rules: 670 // ACTIVE_AND_LOADING and UNTHROTTLED Clients follow these rules:
671 // * Non-delayable, High-priority and SPDY capable requests are issued 671 // * Non-delayable, High-priority and SPDY capable requests are issued
mmenke 2015/01/30 22:04:16 This now applies to QUIC, too
Ryan Hamilton 2015/01/30 22:53:47 Done.
672 // immediately. 672 // immediately.
673 // * Low priority requests are delayable. 673 // * Low priority requests are delayable.
674 // * Allow one delayable request to load at a time while layout-blocking 674 // * Allow one delayable request to load at a time while layout-blocking
675 // requests are loading or the body tag has not yet been parsed. 675 // requests are loading or the body tag has not yet been parsed.
676 // * If no high priority or layout-blocking requests are in flight, start 676 // * If no high priority or layout-blocking requests are in flight, start
677 // loading delayable requests. 677 // loading delayable requests.
678 // * Never exceed 10 delayable requests in flight per client. 678 // * Never exceed 10 delayable requests in flight per client.
679 // * Never exceed 6 delayable requests for a given host. 679 // * Never exceed 6 delayable requests for a given host.
680 // 680 //
681 // THROTTLED Clients follow these rules: 681 // THROTTLED Clients follow these rules:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 if (using_spdy_proxy_ && url_request.url().SchemeIs(url::kHttpScheme)) { 714 if (using_spdy_proxy_ && url_request.url().SchemeIs(url::kHttpScheme)) {
715 return START_REQUEST; 715 return START_REQUEST;
716 } 716 }
717 717
718 net::HostPortPair host_port_pair = 718 net::HostPortPair host_port_pair =
719 net::HostPortPair::FromURL(url_request.url()); 719 net::HostPortPair::FromURL(url_request.url());
720 net::HttpServerProperties& http_server_properties = 720 net::HttpServerProperties& http_server_properties =
721 *url_request.context()->http_server_properties(); 721 *url_request.context()->http_server_properties();
722 722
723 // TODO(willchan): We should really improve this algorithm as described in 723 // TODO(willchan): We should really improve this algorithm as described in
724 // crbug.com/164101. Also, theoretically we should not count a SPDY request 724 // crbug.com/164101. Also, theoretically we should not count a SPDY request
mmenke 2015/01/30 22:04:16 This now applies to QUIC, too
Ryan Hamilton 2015/01/30 22:53:47 Done.
725 // against the delayable requests limit. 725 // against the delayable requests limit.
726 if (http_server_properties.SupportsSpdy(host_port_pair)) { 726 if (http_server_properties.SupportsRequestPriority(host_port_pair)) {
727 return START_REQUEST; 727 return START_REQUEST;
728 } 728 }
729 729
730 if (throttle_state_ == THROTTLED && 730 if (throttle_state_ == THROTTLED &&
731 in_flight_requests_.size() >= kMaxNumThrottledRequestsPerClient) { 731 in_flight_requests_.size() >= kMaxNumThrottledRequestsPerClient) {
732 // There may still be SPDY-capable requests that should be issued. 732 // There may still be SPDY-capable requests that should be issued.
733 return DO_NOT_START_REQUEST_AND_KEEP_SEARCHING; 733 return DO_NOT_START_REQUEST_AND_KEEP_SEARCHING;
734 } 734 }
735 735
736 // High-priority and layout-blocking requests. 736 // High-priority and layout-blocking requests.
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 client->ReprioritizeRequest( 1140 client->ReprioritizeRequest(
1141 request, old_priority_params, new_priority_params); 1141 request, old_priority_params, new_priority_params);
1142 } 1142 }
1143 1143
1144 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( 1144 ResourceScheduler::ClientId ResourceScheduler::MakeClientId(
1145 int child_id, int route_id) { 1145 int child_id, int route_id) {
1146 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; 1146 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id;
1147 } 1147 }
1148 1148
1149 } // namespace content 1149 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | net/http/http_server_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698