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 #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/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 CountRequestsWithClassification(IN_FLIGHT_DELAYABLE_REQUEST, false), | 504 CountRequestsWithClassification(IN_FLIGHT_DELAYABLE_REQUEST, false), |
| 505 in_flight_delayable_count_); | 505 in_flight_delayable_count_); |
| 506 DCHECK_EQ(CountRequestsWithClassification(LAYOUT_BLOCKING_REQUEST, true), | 506 DCHECK_EQ(CountRequestsWithClassification(LAYOUT_BLOCKING_REQUEST, true), |
| 507 total_layout_blocking_count_); | 507 total_layout_blocking_count_); |
| 508 } | 508 } |
| 509 | 509 |
| 510 RequestClassification ClassifyRequest(ScheduledResourceRequest* request) { | 510 RequestClassification ClassifyRequest(ScheduledResourceRequest* request) { |
| 511 // If a request is already marked as layout-blocking make sure to keep the | 511 // If a request is already marked as layout-blocking make sure to keep the |
| 512 // classification across redirects unless the priority was lowered. | 512 // classification across redirects unless the priority was lowered. |
| 513 if (request->classification() == LAYOUT_BLOCKING_REQUEST && | 513 if (request->classification() == LAYOUT_BLOCKING_REQUEST && |
| 514 request->url_request()->priority() >= net::LOW) { | 514 request->url_request()->priority() > net::LOW) { |
| 515 return LAYOUT_BLOCKING_REQUEST; | 515 return LAYOUT_BLOCKING_REQUEST; |
| 516 } | 516 } |
| 517 | 517 |
| 518 if (!has_body_ && request->url_request()->priority() >= net::LOW) | 518 if (!has_body_ && request->url_request()->priority() > net::LOW) |
| 519 return LAYOUT_BLOCKING_REQUEST; | 519 return LAYOUT_BLOCKING_REQUEST; |
| 520 | 520 |
| 521 if (request->url_request()->priority() < net::LOW) { | 521 if (request->url_request()->priority() < net::LOW) { |
| 522 net::HostPortPair host_port_pair = | 522 net::HostPortPair host_port_pair = |
| 523 net::HostPortPair::FromURL(request->url_request()->url()); | 523 net::HostPortPair::FromURL(request->url_request()->url()); |
| 524 net::HttpServerProperties& http_server_properties = | 524 net::HttpServerProperties& http_server_properties = |
| 525 *request->url_request()->context()->http_server_properties(); | 525 *request->url_request()->context()->http_server_properties(); |
| 526 if (!http_server_properties.SupportsSpdy(host_port_pair) && | 526 if (!http_server_properties.SupportsSpdy(host_port_pair) && |
| 527 ContainsKey(in_flight_requests_, request)) { | 527 ContainsKey(in_flight_requests_, request)) { |
| 528 return IN_FLIGHT_DELAYABLE_REQUEST; | 528 return IN_FLIGHT_DELAYABLE_REQUEST; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 559 // 1. Non-delayable requests: | 559 // 1. Non-delayable requests: |
| 560 // * Synchronous requests. | 560 // * Synchronous requests. |
| 561 // * Non-HTTP[S] requests. | 561 // * Non-HTTP[S] requests. |
| 562 // | 562 // |
| 563 // 2. Requests to SPDY-capable origin servers. | 563 // 2. Requests to SPDY-capable origin servers. |
| 564 // | 564 // |
| 565 // 3. High-priority requests: | 565 // 3. High-priority requests: |
| 566 // * Higher priority requests (>= net::LOW). | 566 // * Higher priority requests (>= net::LOW). |
| 567 // | 567 // |
| 568 // 4. Layout-blocking requests: | 568 // 4. Layout-blocking requests: |
| 569 // * High-priority requests initiated before the renderer has a <body>. | 569 // * High-priority requests (> net::LOW) initiated before the renderer has |
| 570 // a <body>. | |
| 570 // | 571 // |
| 571 // 5. Low priority requests | 572 // 5. Low priority requests |
| 572 // | 573 // |
| 573 // The following rules are followed: | 574 // The following rules are followed: |
| 574 // | 575 // |
| 575 // ACTIVE_AND_LOADING and UNTHROTTLED Clients follow these rules: | 576 // ACTIVE_AND_LOADING and UNTHROTTLED Clients follow these rules: |
| 576 // * Non-delayable, High-priority and SPDY capable requests are issued | 577 // * Non-delayable, High-priority and SPDY capable requests are issued |
| 577 // immediately. | 578 // immediately. |
| 578 // * Low priority requests are delayable. | 579 // * Low priority requests are delayable. |
| 579 // * Allow one delayable request to load at a time while layout-blocking | 580 // * Allow one delayable request to load at a time while layout-blocking |
| 580 // requests are loading. | 581 // requests are loading or the body tag has not yet been parsed. |
| 581 // * If no high priority or layout-blocking requests are in flight, start | 582 // * If no high priority or layout-blocking requests are in flight, start |
| 582 // loading delayable requests. | 583 // loading delayable requests. |
| 583 // * Never exceed 10 delayable requests in flight per client. | 584 // * Never exceed 10 delayable requests in flight per client. |
| 584 // * Never exceed 6 delayable requests for a given host. | 585 // * Never exceed 6 delayable requests for a given host. |
| 585 // | 586 // |
| 586 // THROTTLED Clients follow these rules: | 587 // THROTTLED Clients follow these rules: |
| 587 // * Non-delayable and SPDY-capable requests are issued immediately. | 588 // * Non-delayable and SPDY-capable requests are issued immediately. |
| 588 // * At most one non-SPDY request will be issued per THROTTLED Client | 589 // * At most one non-SPDY request will be issued per THROTTLED Client |
| 589 // * If no high priority requests are in flight, start loading low priority | 590 // * If no high priority requests are in flight, start loading low priority |
| 590 // requests. | 591 // requests. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 | 650 |
| 650 if (ShouldKeepSearching(host_port_pair)) { | 651 if (ShouldKeepSearching(host_port_pair)) { |
| 651 // There may be other requests for other hosts we'd allow, | 652 // There may be other requests for other hosts we'd allow, |
| 652 // so keep checking. | 653 // so keep checking. |
| 653 return DO_NOT_START_REQUEST_AND_KEEP_SEARCHING; | 654 return DO_NOT_START_REQUEST_AND_KEEP_SEARCHING; |
| 654 } | 655 } |
| 655 | 656 |
| 656 bool have_immediate_requests_in_flight = | 657 bool have_immediate_requests_in_flight = |
| 657 in_flight_requests_.size() > in_flight_delayable_count_; | 658 in_flight_requests_.size() > in_flight_delayable_count_; |
| 658 if (have_immediate_requests_in_flight && | 659 if (have_immediate_requests_in_flight && |
| 659 total_layout_blocking_count_ != 0 && | 660 (!has_body_ || total_layout_blocking_count_ != 0) && |
|
mmenke
2014/10/16 15:59:01
Oh, may want a unit test for this.
Pat Meenan
2014/10/16 16:50:07
Done.
| |
| 660 in_flight_delayable_count_ != 0) { | 661 in_flight_delayable_count_ != 0) { |
| 661 return DO_NOT_START_REQUEST_AND_STOP_SEARCHING; | 662 return DO_NOT_START_REQUEST_AND_STOP_SEARCHING; |
| 662 } | 663 } |
| 663 | 664 |
| 664 return START_REQUEST; | 665 return START_REQUEST; |
| 665 } | 666 } |
| 666 | 667 |
| 667 void LoadAnyStartablePendingRequests() { | 668 void LoadAnyStartablePendingRequests() { |
| 668 // We iterate through all the pending requests, starting with the highest | 669 // We iterate through all the pending requests, starting with the highest |
| 669 // priority one. For each entry, one of three things can happen: | 670 // priority one. For each entry, one of three things can happen: |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1034 client->ReprioritizeRequest( | 1035 client->ReprioritizeRequest( |
| 1035 request, old_priority_params, new_priority_params); | 1036 request, old_priority_params, new_priority_params); |
| 1036 } | 1037 } |
| 1037 | 1038 |
| 1038 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( | 1039 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( |
| 1039 int child_id, int route_id) { | 1040 int child_id, int route_id) { |
| 1040 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; | 1041 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; |
| 1041 } | 1042 } |
| 1042 | 1043 |
| 1043 } // namespace content | 1044 } // namespace content |
| OLD | NEW |