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

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

Issue 1230133005: Fix Resource Priorities and Scheduling (Chrome Side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switched the request classification to a bitfield of attributes 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 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ 5 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_
6 #define CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ 6 #define CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 THROTTLED, 71 THROTTLED,
72 // Observable (active) loaded client or 72 // Observable (active) loaded client or
73 // Loading background client, all observable clients loaded. 73 // Loading background client, all observable clients loaded.
74 // Note that clients which would be COALESCED are UNTHROTTLED until 74 // Note that clients which would be COALESCED are UNTHROTTLED until
75 // coalescing is turned on. 75 // coalescing is turned on.
76 UNTHROTTLED, 76 UNTHROTTLED,
77 // Observable (active) loading client. 77 // Observable (active) loading client.
78 ACTIVE_AND_LOADING, 78 ACTIVE_AND_LOADING,
79 }; 79 };
80 80
81 enum RequestClassification {
82 NORMAL_REQUEST,
83 // Low priority in-flight requests
84 IN_FLIGHT_DELAYABLE_REQUEST,
85 // High-priority requests received before the renderer has a <body>
86 LAYOUT_BLOCKING_REQUEST,
87 };
88
89 ResourceScheduler(); 81 ResourceScheduler();
90 ~ResourceScheduler(); 82 ~ResourceScheduler();
91 83
92 // Use a mock timer when testing. 84 // Use a mock timer when testing.
93 void set_timer_for_testing(scoped_ptr<base::Timer> timer) { 85 void set_timer_for_testing(scoped_ptr<base::Timer> timer) {
94 coalescing_timer_.reset(timer.release()); 86 coalescing_timer_.reset(timer.release());
95 } 87 }
96 88
97 // TODO(aiolos): Remove when throttling and coalescing have landed 89 // TODO(aiolos): Remove when throttling and coalescing have landed
98 void SetThrottleOptionsForTesting(bool should_throttle, bool should_coalesce); 90 void SetThrottleOptionsForTesting(bool should_throttle, bool should_coalesce);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 bool limit_outstanding_requests() const { 150 bool limit_outstanding_requests() const {
159 return limit_outstanding_requests_; 151 return limit_outstanding_requests_;
160 } 152 }
161 153
162 // Returns the outstanding request limit. Only valid if 154 // Returns the outstanding request limit. Only valid if
163 // |IsLimitingOutstandingRequests()|. 155 // |IsLimitingOutstandingRequests()|.
164 size_t outstanding_request_limit() const { 156 size_t outstanding_request_limit() const {
165 return outstanding_request_limit_; 157 return outstanding_request_limit_;
166 } 158 }
167 159
160 // Returns the priority level above which resources are considered
161 // layout-blocking if the html_body has not started. It is also the threshold
162 // below which resources are considered delayable (and for completeness,
163 // a request that matches the threshold level is a high-priority but not
164 // layout-blocking request).
165 net::RequestPriority non_delayable_threshold() const {
166 return non_delayable_threshold_;
167 }
168
169 // Returns true if all delayable requests should be blocked while at least
170 // in_flight_layout_blocking_threshold() layout-blocking requests are
171 // in-flight during the layout-blocking phase of loading.
172 bool enable_in_flight_non_delayable_threshold() const {
173 return enable_in_flight_non_delayable_threshold_;
174 }
175
176 // Returns the number of in-flight layout-blocking requests above which
177 // all delayable requests should be blocked when
178 // enable_layout_blocking_threshold is set.
179 size_t in_flight_non_delayable_threshold() const {
180 return in_flight_non_delayable_threshold_;
181 }
182
183 // Returns the maximum number of delayable requests to allow be in-flight
184 // at any point in time while in the layout-blocking phase of loading.
185 size_t max_num_delayable_while_layout_blocking() const {
186 return max_num_delayable_while_layout_blocking_;
187 }
188
189 // Returns the maximum number of delayable requests to all be in-flight at
190 // any point in time (across all hosts).
191 size_t max_num_delayable_requests() const {
192 return max_num_delayable_requests_;
193 }
194
168 enum ClientState { 195 enum ClientState {
169 // Observable client. 196 // Observable client.
170 ACTIVE, 197 ACTIVE,
171 // Non-observable client. 198 // Non-observable client.
172 BACKGROUND, 199 BACKGROUND,
173 // No client found. 200 // No client found.
174 UNKNOWN, 201 UNKNOWN,
175 }; 202 };
176 203
177 class RequestQueue; 204 class RequestQueue;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // Returns the client for the given |child_id| and |route_id| combo. 258 // Returns the client for the given |child_id| and |route_id| combo.
232 Client* GetClient(int child_id, int route_id); 259 Client* GetClient(int child_id, int route_id);
233 260
234 bool should_coalesce_; 261 bool should_coalesce_;
235 bool should_throttle_; 262 bool should_throttle_;
236 ClientMap client_map_; 263 ClientMap client_map_;
237 size_t active_clients_loading_; 264 size_t active_clients_loading_;
238 size_t coalesced_clients_; 265 size_t coalesced_clients_;
239 bool limit_outstanding_requests_; 266 bool limit_outstanding_requests_;
240 size_t outstanding_request_limit_; 267 size_t outstanding_request_limit_;
268 net::RequestPriority non_delayable_threshold_;
269 bool enable_in_flight_non_delayable_threshold_;
270 size_t in_flight_non_delayable_threshold_;
271 size_t max_num_delayable_while_layout_blocking_;
272 size_t max_num_delayable_requests_;
241 // This is a repeating timer to initiate requests on COALESCED Clients. 273 // This is a repeating timer to initiate requests on COALESCED Clients.
242 scoped_ptr<base::Timer> coalescing_timer_; 274 scoped_ptr<base::Timer> coalescing_timer_;
243 RequestSet unowned_requests_; 275 RequestSet unowned_requests_;
244 }; 276 };
245 277
246 } // namespace content 278 } // namespace content
247 279
248 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ 280 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698