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

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

Issue 1230133005: Fix Resource Priorities and Scheduling (Chrome Side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from review feedback Created 5 years, 4 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
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 "content/browser/loader/resource_scheduler.h"
6
5 #include <set> 7 #include <set>
6 8
7 #include "content/browser/loader/resource_scheduler.h"
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"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "content/common/resource_messages.h" 15 #include "content/common/resource_messages.h"
16 #include "content/browser/loader/resource_message_delegate.h" 16 #include "content/browser/loader/resource_message_delegate.h"
17 #include "content/public/browser/resource_controller.h" 17 #include "content/public/browser/resource_controller.h"
18 #include "content/public/browser/resource_request_info.h" 18 #include "content/public/browser/resource_request_info.h"
(...skipping 11 matching lines...) Expand all
30 namespace { 30 namespace {
31 31
32 // Field trial constants 32 // Field trial constants
33 const char kThrottleCoalesceFieldTrial[] = "RequestThrottlingAndCoalescing"; 33 const char kThrottleCoalesceFieldTrial[] = "RequestThrottlingAndCoalescing";
34 const char kThrottleCoalesceFieldTrialThrottle[] = "Throttle"; 34 const char kThrottleCoalesceFieldTrialThrottle[] = "Throttle";
35 const char kThrottleCoalesceFieldTrialCoalesce[] = "Coalesce"; 35 const char kThrottleCoalesceFieldTrialCoalesce[] = "Coalesce";
36 36
37 const char kRequestLimitFieldTrial[] = "OutstandingRequestLimiting"; 37 const char kRequestLimitFieldTrial[] = "OutstandingRequestLimiting";
38 const char kRequestLimitFieldTrialGroupPrefix[] = "Limit"; 38 const char kRequestLimitFieldTrialGroupPrefix[] = "Limit";
39 39
40 const char kResourcePrioritiesFieldTrial[] = "ResourcePriorities";
41
40 // Post ResourceScheduler histograms of the following forms: 42 // Post ResourceScheduler histograms of the following forms:
41 // If |histogram_suffix| is NULL or the empty string: 43 // If |histogram_suffix| is NULL or the empty string:
42 // ResourceScheduler.base_name.histogram_name 44 // ResourceScheduler.base_name.histogram_name
43 // Else: 45 // Else:
44 // ResourceScheduler.base_name.histogram_name.histogram_suffix 46 // ResourceScheduler.base_name.histogram_name.histogram_suffix
45 void PostHistogram(const char* base_name, 47 void PostHistogram(const char* base_name,
46 const char* histogram_name, 48 const char* histogram_name,
47 const char* histogram_suffix, 49 const char* histogram_suffix,
48 base::TimeDelta time) { 50 base::TimeDelta time) {
49 std::string histogram = 51 std::string histogram =
(...skipping 17 matching lines...) Expand all
67 else if (num_clients <= 15) 69 else if (num_clients <= 15)
68 return "Max15Clients"; 70 return "Max15Clients";
69 else if (num_clients <= 30) 71 else if (num_clients <= 30)
70 return "Max30Clients"; 72 return "Max30Clients";
71 return "Over30Clients"; 73 return "Over30Clients";
72 } 74 }
73 75
74 } // namespace 76 } // namespace
75 77
76 static const size_t kCoalescedTimerPeriod = 5000; 78 static const size_t kCoalescedTimerPeriod = 5000;
77 static const size_t kMaxNumDelayableRequestsPerClient = 10; 79 static const size_t kDefaultMaxNumDelayableRequestsPerClient = 10;
78 static const size_t kMaxNumDelayableRequestsPerHost = 6; 80 static const size_t kMaxNumDelayableRequestsPerHost = 6;
79 static const size_t kMaxNumThrottledRequestsPerClient = 1; 81 static const size_t kMaxNumThrottledRequestsPerClient = 1;
82 static const size_t kDefaultMaxNumDelayableWhileLayoutBlocking = 1;
83 static const net::RequestPriority
84 kDefaultLayoutBlockingPriorityThreshold = net::LOW;
80 85
81 struct ResourceScheduler::RequestPriorityParams { 86 struct ResourceScheduler::RequestPriorityParams {
82 RequestPriorityParams() 87 RequestPriorityParams()
83 : priority(net::DEFAULT_PRIORITY), 88 : priority(net::DEFAULT_PRIORITY),
84 intra_priority(0) { 89 intra_priority(0) {
85 } 90 }
86 91
87 RequestPriorityParams(net::RequestPriority priority, int intra_priority) 92 RequestPriorityParams(net::RequestPriority priority, int intra_priority)
88 : priority(priority), 93 : priority(priority),
89 intra_priority(intra_priority) { 94 intra_priority(intra_priority) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // Each client represents a tab. 306 // Each client represents a tab.
302 class ResourceScheduler::Client { 307 class ResourceScheduler::Client {
303 public: 308 public:
304 explicit Client(ResourceScheduler* scheduler, 309 explicit Client(ResourceScheduler* scheduler,
305 bool is_visible, 310 bool is_visible,
306 bool is_audible) 311 bool is_audible)
307 : is_audible_(is_audible), 312 : is_audible_(is_audible),
308 is_visible_(is_visible), 313 is_visible_(is_visible),
309 is_loaded_(false), 314 is_loaded_(false),
310 is_paused_(false), 315 is_paused_(false),
311 has_body_(false), 316 has_html_body_(false),
312 using_spdy_proxy_(false), 317 using_spdy_proxy_(false),
313 load_started_time_(base::TimeTicks::Now()), 318 load_started_time_(base::TimeTicks::Now()),
314 scheduler_(scheduler), 319 scheduler_(scheduler),
315 in_flight_delayable_count_(0), 320 in_flight_delayable_count_(0),
316 total_layout_blocking_count_(0), 321 total_layout_blocking_count_(0),
317 throttle_state_(ResourceScheduler::THROTTLED) {} 322 throttle_state_(ResourceScheduler::THROTTLED) {
323 }
318 324
319 ~Client() { 325 ~Client() {
320 // Update to default state and pause to ensure the scheduler has a 326 // Update to default state and pause to ensure the scheduler has a
321 // correct count of relevant types of clients. 327 // correct count of relevant types of clients.
322 is_visible_ = false; 328 is_visible_ = false;
323 is_audible_ = false; 329 is_audible_ = false;
324 is_paused_ = true; 330 is_paused_ = true;
325 UpdateThrottleState(); 331 UpdateThrottleState();
326 } 332 }
327 333
(...skipping 15 matching lines...) Expand all
343 EraseInFlightRequest(request); 349 EraseInFlightRequest(request);
344 350
345 // Removing this request may have freed up another to load. 351 // Removing this request may have freed up another to load.
346 LoadAnyStartablePendingRequests(); 352 LoadAnyStartablePendingRequests();
347 } 353 }
348 } 354 }
349 355
350 RequestSet StartAndRemoveAllRequests() { 356 RequestSet StartAndRemoveAllRequests() {
351 // First start any pending requests so that they will be moved into 357 // First start any pending requests so that they will be moved into
352 // in_flight_requests_. This may exceed the limits 358 // in_flight_requests_. This may exceed the limits
353 // kMaxNumDelayableRequestsPerClient, kMaxNumDelayableRequestsPerHost and 359 // kDefaultMaxNumDelayableRequestsPerClient, kMaxNumDelayableRequestsPerHost
354 // kMaxNumThrottledRequestsPerClient, so this method must not do anything 360 // and kMaxNumThrottledRequestsPerClient, so this method must not do
355 // that depends on those limits before calling ClearInFlightRequests() 361 // anything that depends on those limits before calling
356 // below. 362 // ClearInFlightRequests() below.
357 while (!pending_requests_.IsEmpty()) { 363 while (!pending_requests_.IsEmpty()) {
358 ScheduledResourceRequest* request = 364 ScheduledResourceRequest* request =
359 *pending_requests_.GetNextHighestIterator(); 365 *pending_requests_.GetNextHighestIterator();
360 pending_requests_.Erase(request); 366 pending_requests_.Erase(request);
361 // StartRequest() may modify pending_requests_. TODO(ricea): Does it? 367 // StartRequest() may modify pending_requests_. TODO(ricea): Does it?
362 StartRequest(request); 368 StartRequest(request);
363 } 369 }
364 RequestSet unowned_requests; 370 RequestSet unowned_requests;
365 for (RequestSet::iterator it = in_flight_requests_.begin(); 371 for (RequestSet::iterator it = in_flight_requests_.begin();
366 it != in_flight_requests_.end(); ++it) { 372 it != in_flight_requests_.end(); ++it) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 scheduler_->DecrementActiveClientsLoading(); 469 scheduler_->DecrementActiveClientsLoading();
464 } 470 }
465 if (throttle_state_ == COALESCED) { 471 if (throttle_state_ == COALESCED) {
466 scheduler_->IncrementCoalescedClients(); 472 scheduler_->IncrementCoalescedClients();
467 } else if (old_throttle_state == COALESCED) { 473 } else if (old_throttle_state == COALESCED) {
468 scheduler_->DecrementCoalescedClients(); 474 scheduler_->DecrementCoalescedClients();
469 } 475 }
470 } 476 }
471 477
472 void OnNavigate() { 478 void OnNavigate() {
473 has_body_ = false; 479 has_html_body_ = false;
474 is_loaded_ = false; 480 is_loaded_ = false;
475 } 481 }
476 482
477 void OnWillInsertBody() { 483 void OnWillInsertBody() {
478 has_body_ = true; 484 has_html_body_ = true;
479 LoadAnyStartablePendingRequests(); 485 LoadAnyStartablePendingRequests();
480 } 486 }
481 487
482 void OnReceivedSpdyProxiedHttpResponse() { 488 void OnReceivedSpdyProxiedHttpResponse() {
483 if (!using_spdy_proxy_) { 489 if (!using_spdy_proxy_) {
484 using_spdy_proxy_ = true; 490 using_spdy_proxy_ = true;
485 LoadAnyStartablePendingRequests(); 491 LoadAnyStartablePendingRequests();
486 } 492 }
487 } 493 }
488 494
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 request->set_classification(classification); 622 request->set_classification(classification);
617 DCHECK_EQ( 623 DCHECK_EQ(
618 CountRequestsWithClassification(IN_FLIGHT_DELAYABLE_REQUEST, false), 624 CountRequestsWithClassification(IN_FLIGHT_DELAYABLE_REQUEST, false),
619 in_flight_delayable_count_); 625 in_flight_delayable_count_);
620 DCHECK_EQ(CountRequestsWithClassification(LAYOUT_BLOCKING_REQUEST, true), 626 DCHECK_EQ(CountRequestsWithClassification(LAYOUT_BLOCKING_REQUEST, true),
621 total_layout_blocking_count_); 627 total_layout_blocking_count_);
622 } 628 }
623 629
624 RequestClassification ClassifyRequest(ScheduledResourceRequest* request) { 630 RequestClassification ClassifyRequest(ScheduledResourceRequest* request) {
625 // If a request is already marked as layout-blocking make sure to keep the 631 // If a request is already marked as layout-blocking make sure to keep the
626 // classification across redirects unless the priority was lowered. 632 // classification across redirects.
627 if (request->classification() == LAYOUT_BLOCKING_REQUEST && 633 if (request->classification() == LAYOUT_BLOCKING_REQUEST) {
628 request->url_request()->priority() > net::LOW) {
629 return LAYOUT_BLOCKING_REQUEST; 634 return LAYOUT_BLOCKING_REQUEST;
630 } 635 }
mmenke 2015/08/12 17:30:08 nit: Remove braces, to be more consistent with th
Pat Meenan 2015/08/13 12:11:03 Done.
631 636
632 if (!has_body_ && request->url_request()->priority() > net::LOW) 637 if (!has_html_body_ &&
638 request->url_request()->priority() >
639 scheduler_->layout_blocking_priority_threshold()) {
633 return LAYOUT_BLOCKING_REQUEST; 640 return LAYOUT_BLOCKING_REQUEST;
641 }
634 642
635 if (request->url_request()->priority() < net::LOW) { 643 if (request->url_request()->priority() <
644 scheduler_->layout_blocking_priority_threshold()) {
636 net::HostPortPair host_port_pair = 645 net::HostPortPair host_port_pair =
637 net::HostPortPair::FromURL(request->url_request()->url()); 646 net::HostPortPair::FromURL(request->url_request()->url());
638 net::HttpServerProperties& http_server_properties = 647 net::HttpServerProperties& http_server_properties =
639 *request->url_request()->context()->http_server_properties(); 648 *request->url_request()->context()->http_server_properties();
640 if (!http_server_properties.SupportsRequestPriority(host_port_pair) && 649 if (!http_server_properties.SupportsRequestPriority(host_port_pair) &&
641 ContainsKey(in_flight_requests_, request)) { 650 ContainsKey(in_flight_requests_, request)) {
642 return IN_FLIGHT_DELAYABLE_REQUEST; 651 return IN_FLIGHT_DELAYABLE_REQUEST;
643 } 652 }
mmenke 2015/08/12 17:30:08 Can we add two more classifications here? DELAYAB
Pat Meenan 2015/08/13 12:11:03 Would you want them broken out into two flags (in-
644 } 653 }
645 return NORMAL_REQUEST; 654 return NORMAL_REQUEST;
646 } 655 }
647 656
648 bool ShouldKeepSearching( 657 bool ShouldKeepSearching(
649 const net::HostPortPair& active_request_host) const { 658 const net::HostPortPair& active_request_host) const {
650 size_t same_host_count = 0; 659 size_t same_host_count = 0;
651 for (RequestSet::const_iterator it = in_flight_requests_.begin(); 660 for (RequestSet::const_iterator it = in_flight_requests_.begin();
652 it != in_flight_requests_.end(); ++it) { 661 it != in_flight_requests_.end(); ++it) {
653 net::HostPortPair host_port_pair = 662 net::HostPortPair host_port_pair =
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 771 }
763 772
764 if (throttle_state_ == THROTTLED && 773 if (throttle_state_ == THROTTLED &&
765 in_flight_requests_.size() >= kMaxNumThrottledRequestsPerClient) { 774 in_flight_requests_.size() >= kMaxNumThrottledRequestsPerClient) {
766 // There may still be request-priority-capable requests that should be 775 // There may still be request-priority-capable requests that should be
767 // issued. 776 // issued.
768 return DO_NOT_START_REQUEST_AND_KEEP_SEARCHING; 777 return DO_NOT_START_REQUEST_AND_KEEP_SEARCHING;
769 } 778 }
770 779
771 // High-priority and layout-blocking requests. 780 // High-priority and layout-blocking requests.
772 if (url_request.priority() >= net::LOW) { 781 if (url_request.priority() >=
782 scheduler_->layout_blocking_priority_threshold()) {
773 return START_REQUEST; 783 return START_REQUEST;
774 } 784 }
775 785
776 if (in_flight_delayable_count_ >= kMaxNumDelayableRequestsPerClient) { 786 if (in_flight_delayable_count_ >=
787 scheduler_->max_num_delayable_requests()) {
777 return DO_NOT_START_REQUEST_AND_STOP_SEARCHING; 788 return DO_NOT_START_REQUEST_AND_STOP_SEARCHING;
778 } 789 }
779 790
780 if (ShouldKeepSearching(host_port_pair)) { 791 if (ShouldKeepSearching(host_port_pair)) {
781 // There may be other requests for other hosts we'd allow, 792 // There may be other requests for other hosts we'd allow,
782 // so keep checking. 793 // so keep checking.
783 return DO_NOT_START_REQUEST_AND_KEEP_SEARCHING; 794 return DO_NOT_START_REQUEST_AND_KEEP_SEARCHING;
784 } 795 }
785 796
786 bool have_immediate_requests_in_flight = 797 // Layout-blocking phase of resource loading.
787 in_flight_requests_.size() > in_flight_delayable_count_; 798 if (!has_html_body_ || total_layout_blocking_count_ != 0) {
788 if (have_immediate_requests_in_flight && 799 size_t non_delayable_requests_in_flight_count =
789 (!has_body_ || total_layout_blocking_count_ != 0) && 800 in_flight_requests_.size() - in_flight_delayable_count_;
790 // Do not allow a low priority request through in parallel if 801 if (scheduler_->enable_layout_blocking_threshold()) {
791 // we are in a limit field trial. 802 if (non_delayable_requests_in_flight_count >
792 (scheduler_->limit_outstanding_requests() || 803 scheduler_->in_flight_layout_blocking_threshold()) {
793 in_flight_delayable_count_ != 0)) { 804 // Too many higher priority in-flight requests to allow lower priority
794 return DO_NOT_START_REQUEST_AND_STOP_SEARCHING; 805 // requests through.
806 return DO_NOT_START_REQUEST_AND_STOP_SEARCHING;
807 }
808 if (in_flight_requests_.size() > 0 &&
mmenke 2015/08/12 17:30:08 I think we can remove this line - if in_flight_req
mmenke 2015/08/12 17:33:59 Oh, right...the no body yet case. Think I forgot
Pat Meenan 2015/08/13 12:11:03 Not sure if it helps any but I beefed up the comme
809 (scheduler_->limit_outstanding_requests() ||
810 in_flight_delayable_count_ >=
811 scheduler_->max_num_delayable_while_layout_blocking())) {
812 // Block the request if at least one request is in flight and the
813 // number of in-flight delayable requests has hit the configured
814 // limit.
815 return DO_NOT_START_REQUEST_AND_STOP_SEARCHING;
816 }
817 } else if (non_delayable_requests_in_flight_count > 0 &&
818 (scheduler_->limit_outstanding_requests() ||
819 in_flight_delayable_count_ >=
820 scheduler_->max_num_delayable_while_layout_blocking())) {
821 // If there are no high-priority requests in flight the floodgates open.
822 // If there are high-priority requests in-flight then limit the number
823 // of lower-priority requests (or zero if a limit field trial is
824 // active).
825 return DO_NOT_START_REQUEST_AND_STOP_SEARCHING;
826 }
795 } 827 }
796 828
797 return START_REQUEST; 829 return START_REQUEST;
798 } 830 }
799 831
800 void LoadAnyStartablePendingRequests() { 832 void LoadAnyStartablePendingRequests() {
801 // We iterate through all the pending requests, starting with the highest 833 // We iterate through all the pending requests, starting with the highest
802 // priority one. For each entry, one of three things can happen: 834 // priority one. For each entry, one of three things can happen:
803 // 1) We start the request, remove it from the list, and keep checking. 835 // 1) We start the request, remove it from the list, and keep checking.
804 // 2) We do NOT start the request, but ShouldStartRequest() signals us that 836 // 2) We do NOT start the request, but ShouldStartRequest() signals us that
(...skipping 26 matching lines...) Expand all
831 DCHECK(query_result == DO_NOT_START_REQUEST_AND_STOP_SEARCHING); 863 DCHECK(query_result == DO_NOT_START_REQUEST_AND_STOP_SEARCHING);
832 break; 864 break;
833 } 865 }
834 } 866 }
835 } 867 }
836 868
837 bool is_audible_; 869 bool is_audible_;
838 bool is_visible_; 870 bool is_visible_;
839 bool is_loaded_; 871 bool is_loaded_;
840 bool is_paused_; 872 bool is_paused_;
841 bool has_body_; 873 // Tracks if the main HTML parser has reached the body which marks the end of
874 // layout-blocking resources.
875 bool has_html_body_;
842 bool using_spdy_proxy_; 876 bool using_spdy_proxy_;
843 RequestQueue pending_requests_; 877 RequestQueue pending_requests_;
844 RequestSet in_flight_requests_; 878 RequestSet in_flight_requests_;
845 base::TimeTicks load_started_time_; 879 base::TimeTicks load_started_time_;
846 // The last time the client switched state between active and background. 880 // The last time the client switched state between active and background.
847 base::TimeTicks last_active_switch_time_; 881 base::TimeTicks last_active_switch_time_;
848 ResourceScheduler* scheduler_; 882 ResourceScheduler* scheduler_;
849 // The number of delayable in-flight requests. 883 // The number of delayable in-flight requests.
850 size_t in_flight_delayable_count_; 884 size_t in_flight_delayable_count_;
851 // The number of layout-blocking in-flight requests. 885 // The number of layout-blocking in-flight requests.
852 size_t total_layout_blocking_count_; 886 size_t total_layout_blocking_count_;
853 ResourceScheduler::ClientThrottleState throttle_state_; 887 ResourceScheduler::ClientThrottleState throttle_state_;
854 }; 888 };
855 889
856 ResourceScheduler::ResourceScheduler() 890 ResourceScheduler::ResourceScheduler()
857 : should_coalesce_(false), 891 : should_coalesce_(false),
858 should_throttle_(false), 892 should_throttle_(false),
859 active_clients_loading_(0), 893 active_clients_loading_(0),
860 coalesced_clients_(0), 894 coalesced_clients_(0),
861 limit_outstanding_requests_(false), 895 limit_outstanding_requests_(false),
862 outstanding_request_limit_(0), 896 outstanding_request_limit_(0),
897 layout_blocking_priority_threshold_(
898 kDefaultLayoutBlockingPriorityThreshold),
899 enable_layout_blocking_threshold_(false),
900 in_flight_layout_blocking_threshold_(0),
901 max_num_delayable_while_layout_blocking_(
902 kDefaultMaxNumDelayableWhileLayoutBlocking),
903 max_num_delayable_requests_(kDefaultMaxNumDelayableRequestsPerClient),
863 coalescing_timer_(new base::Timer(true /* retain_user_task */, 904 coalescing_timer_(new base::Timer(true /* retain_user_task */,
864 true /* is_repeating */)) { 905 true /* is_repeating */)) {
865 std::string throttling_trial_group = 906 std::string throttling_trial_group =
866 base::FieldTrialList::FindFullName(kThrottleCoalesceFieldTrial); 907 base::FieldTrialList::FindFullName(kThrottleCoalesceFieldTrial);
867 if (throttling_trial_group == kThrottleCoalesceFieldTrialThrottle) { 908 if (throttling_trial_group == kThrottleCoalesceFieldTrialThrottle) {
868 should_throttle_ = true; 909 should_throttle_ = true;
869 } else if (throttling_trial_group == kThrottleCoalesceFieldTrialCoalesce) { 910 } else if (throttling_trial_group == kThrottleCoalesceFieldTrialCoalesce) {
870 should_coalesce_ = true; 911 should_coalesce_ = true;
871 should_throttle_ = true; 912 should_throttle_ = true;
872 } 913 }
873 914
874 std::string outstanding_limit_trial_group = 915 std::string outstanding_limit_trial_group =
875 base::FieldTrialList::FindFullName(kRequestLimitFieldTrial); 916 base::FieldTrialList::FindFullName(kRequestLimitFieldTrial);
876 std::vector<std::string> split_group( 917 std::vector<std::string> split_group(
877 base::SplitString(outstanding_limit_trial_group, "=", 918 base::SplitString(outstanding_limit_trial_group, "=",
878 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL)); 919 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL));
879 int outstanding_limit = 0; 920 int outstanding_limit = 0;
880 if (split_group.size() == 2 && 921 if (split_group.size() == 2 &&
881 split_group[0] == kRequestLimitFieldTrialGroupPrefix && 922 split_group[0] == kRequestLimitFieldTrialGroupPrefix &&
882 base::StringToInt(split_group[1], &outstanding_limit) && 923 base::StringToInt(split_group[1], &outstanding_limit) &&
883 outstanding_limit > 0) { 924 outstanding_limit > 0) {
884 limit_outstanding_requests_ = true; 925 limit_outstanding_requests_ = true;
885 outstanding_request_limit_ = outstanding_limit; 926 outstanding_request_limit_ = outstanding_limit;
886 } 927 }
928
929 // Set up the ResourceScheduling field trial options.
930 // The field trial parameters are also encoded into the group name since
931 // the variations component is not available from here and plumbing the
932 // options through the code is overkill for a short experiment.
933 //
934 // The group name encoding looks like this:
935 // <descriptiveName>_ABCDE_E2_F_G
936 // A - fetchDeferLateScripts (1 for true, 0 for false)
937 // B - fetchIncreaseFontPriority (1 for true, 0 for false)
938 // C - fetchIncreaseAsyncScriptPriority (1 for true, 0 for false)
939 // D - fetchIncreasePriorities (1 for true, 0 for false)
940 // E - fetchEnableLayoutBlockingThreshold (1 for true, 0 for false)
941 // E2 - fetchLayoutBlockingThreshold (Numeric)
942 // F - fetchMaxNumDelayableWhileLayoutBlocking (Numeric)
943 // G - fetchMaxNumDelayableRequests (Numeric)
944 std::string resource_priorities_trial_group =
945 base::FieldTrialList::FindFullName(kResourcePrioritiesFieldTrial);
946 std::vector<std::string> resource_priorities_split_group(
947 base::SplitString(resource_priorities_trial_group, "_",
948 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL));
949 if (resource_priorities_split_group.size() == 5 &&
950 resource_priorities_split_group[1].length() == 5) {
951 // fetchIncreasePriorities
952 if (resource_priorities_split_group[1].at(3) == '1')
953 layout_blocking_priority_threshold_ = net::MEDIUM;
954 enable_layout_blocking_threshold_ =
955 resource_priorities_split_group[1].at(4) == '1';
956 size_t numeric_value = 0;
957 if (base::StringToSizeT(resource_priorities_split_group[2], &numeric_value))
958 in_flight_layout_blocking_threshold_ = numeric_value;
959 if (base::StringToSizeT(resource_priorities_split_group[3], &numeric_value))
960 max_num_delayable_while_layout_blocking_ = numeric_value;
961 if (base::StringToSizeT(resource_priorities_split_group[4], &numeric_value))
962 max_num_delayable_requests_ = numeric_value;
963 }
887 } 964 }
888 965
889 ResourceScheduler::~ResourceScheduler() { 966 ResourceScheduler::~ResourceScheduler() {
890 DCHECK(unowned_requests_.empty()); 967 DCHECK(unowned_requests_.empty());
891 DCHECK(client_map_.empty()); 968 DCHECK(client_map_.empty());
892 } 969 }
893 970
894 void ResourceScheduler::SetThrottleOptionsForTesting(bool should_throttle, 971 void ResourceScheduler::SetThrottleOptionsForTesting(bool should_throttle,
895 bool should_coalesce) { 972 bool should_coalesce) {
896 should_coalesce_ = should_coalesce; 973 should_coalesce_ = should_coalesce;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 client->ReprioritizeRequest( 1279 client->ReprioritizeRequest(
1203 request, old_priority_params, new_priority_params); 1280 request, old_priority_params, new_priority_params);
1204 } 1281 }
1205 1282
1206 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( 1283 ResourceScheduler::ClientId ResourceScheduler::MakeClientId(
1207 int child_id, int route_id) { 1284 int child_id, int route_id) {
1208 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; 1285 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id;
1209 } 1286 }
1210 1287
1211 } // namespace content 1288 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698