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

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

Issue 1732363002: Delay deferring resource requests until after first checking cache and extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove extra paren Created 4 years, 9 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 | no next file » | 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 "content/browser/loader/resource_scheduler.h" 5 #include "content/browser/loader/resource_scheduler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_piece.h" 18 #include "base/strings/string_piece.h"
19 #include "base/strings/string_util.h"
19 #include "base/supports_user_data.h" 20 #include "base/supports_user_data.h"
20 #include "content/common/resource_messages.h" 21 #include "content/common/resource_messages.h"
21 #include "content/public/browser/resource_controller.h" 22 #include "content/public/browser/resource_controller.h"
22 #include "content/public/browser/resource_request_info.h" 23 #include "content/public/browser/resource_request_info.h"
23 #include "content/public/browser/resource_throttle.h" 24 #include "content/public/browser/resource_throttle.h"
24 #include "net/base/host_port_pair.h" 25 #include "net/base/host_port_pair.h"
25 #include "net/base/load_flags.h" 26 #include "net/base/load_flags.h"
26 #include "net/base/request_priority.h" 27 #include "net/base/request_priority.h"
27 #include "net/http/http_server_properties.h" 28 #include "net/http/http_server_properties.h"
28 #include "net/url_request/url_request.h" 29 #include "net/url_request/url_request.h"
(...skipping 15 matching lines...) Expand all
44 const char kResourcePrioritiesFieldTrial[] = "ResourcePriorities"; 45 const char kResourcePrioritiesFieldTrial[] = "ResourcePriorities";
45 46
46 // Flags identifying various attributes of the request that are used 47 // Flags identifying various attributes of the request that are used
47 // when making scheduling decisions. 48 // when making scheduling decisions.
48 using RequestAttributes = uint8_t; 49 using RequestAttributes = uint8_t;
49 const RequestAttributes kAttributeNone = 0x00; 50 const RequestAttributes kAttributeNone = 0x00;
50 const RequestAttributes kAttributeInFlight = 0x01; 51 const RequestAttributes kAttributeInFlight = 0x01;
51 const RequestAttributes kAttributeDelayable = 0x02; 52 const RequestAttributes kAttributeDelayable = 0x02;
52 const RequestAttributes kAttributeLayoutBlocking = 0x04; 53 const RequestAttributes kAttributeLayoutBlocking = 0x04;
53 54
55 bool InDeferAfterCacheExperiment() {
56 std::string experiment =
57 base::FieldTrialList::FindFullName("ResourceSchedulerDeferAfterCache");
58 return base::StartsWith(experiment, "ExperimentYes",
59 base::CompareCase::INSENSITIVE_ASCII);
60 }
61
54 } // namespace 62 } // namespace
55 63
56 static const size_t kDefaultMaxNumDelayableRequestsPerClient = 10; 64 static const size_t kDefaultMaxNumDelayableRequestsPerClient = 10;
57 static const size_t kMaxNumDelayableRequestsPerHost = 6; 65 static const size_t kMaxNumDelayableRequestsPerHost = 6;
58 static const size_t kDefaultMaxNumDelayableWhileLayoutBlocking = 1; 66 static const size_t kDefaultMaxNumDelayableWhileLayoutBlocking = 1;
59 static const net::RequestPriority 67 static const net::RequestPriority
60 kDefaultLayoutBlockingPriorityThreshold = net::LOW; 68 kDefaultLayoutBlockingPriorityThreshold = net::LOW;
61 69
62 struct ResourceScheduler::RequestPriorityParams { 70 struct ResourceScheduler::RequestPriorityParams {
63 RequestPriorityParams() 71 RequestPriorityParams()
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 private: 243 private:
236 ScheduledResourceRequest* const pointer_; 244 ScheduledResourceRequest* const pointer_;
237 245
238 DISALLOW_COPY_AND_ASSIGN(UnownedPointer); 246 DISALLOW_COPY_AND_ASSIGN(UnownedPointer);
239 }; 247 };
240 248
241 static const void* const kUserDataKey; 249 static const void* const kUserDataKey;
242 250
243 // ResourceThrottle interface: 251 // ResourceThrottle interface:
244 void WillStartRequest(bool* defer) override { 252 void WillStartRequest(bool* defer) override {
253 if (InDeferAfterCacheExperiment()) {
254 *defer = false;
255 return;
256 }
245 deferred_ = *defer = !ready_; 257 deferred_ = *defer = !ready_;
246 } 258 }
247 259
260 void WillStartUsingNetwork(bool* defer) override {
261 if (InDeferAfterCacheExperiment()) {
262 deferred_ = *defer = !ready_;
263 return;
264 }
265 *defer = false;
266 }
267
248 const char* GetNameForLogging() const override { return "ResourceScheduler"; } 268 const char* GetNameForLogging() const override { return "ResourceScheduler"; }
249 269
250 const ClientId client_id_; 270 const ClientId client_id_;
251 net::URLRequest* request_; 271 net::URLRequest* request_;
252 bool ready_; 272 bool ready_;
253 bool deferred_; 273 bool deferred_;
254 bool is_async_; 274 bool is_async_;
255 RequestAttributes attributes_; 275 RequestAttributes attributes_;
256 ResourceScheduler* scheduler_; 276 ResourceScheduler* scheduler_;
257 RequestPriorityParams priority_; 277 RequestPriorityParams priority_;
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 client->ReprioritizeRequest(scheduled_resource_request, old_priority_params, 977 client->ReprioritizeRequest(scheduled_resource_request, old_priority_params,
958 new_priority_params); 978 new_priority_params);
959 } 979 }
960 980
961 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( 981 ResourceScheduler::ClientId ResourceScheduler::MakeClientId(
962 int child_id, int route_id) { 982 int child_id, int route_id) {
963 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; 983 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id;
964 } 984 }
965 985
966 } // namespace content 986 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698