| 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 #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 Loading... |
| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 bool limit_outstanding_requests() const { | 158 bool limit_outstanding_requests() const { |
| 167 return limit_outstanding_requests_; | 159 return limit_outstanding_requests_; |
| 168 } | 160 } |
| 169 | 161 |
| 170 // Returns the outstanding request limit. Only valid if | 162 // Returns the outstanding request limit. Only valid if |
| 171 // |IsLimitingOutstandingRequests()|. | 163 // |IsLimitingOutstandingRequests()|. |
| 172 size_t outstanding_request_limit() const { | 164 size_t outstanding_request_limit() const { |
| 173 return outstanding_request_limit_; | 165 return outstanding_request_limit_; |
| 174 } | 166 } |
| 175 | 167 |
| 168 // Returns the priority level above which resources are considered |
| 169 // layout-blocking if the html_body has not started. It is also the threshold |
| 170 // below which resources are considered delayable (and for completeness, |
| 171 // a request that matches the threshold level is a high-priority but not |
| 172 // layout-blocking request). |
| 173 net::RequestPriority non_delayable_threshold() const { |
| 174 return non_delayable_threshold_; |
| 175 } |
| 176 |
| 177 // Returns true if all delayable requests should be blocked while at least |
| 178 // in_flight_layout_blocking_threshold() layout-blocking requests are |
| 179 // in-flight during the layout-blocking phase of loading. |
| 180 bool enable_in_flight_non_delayable_threshold() const { |
| 181 return enable_in_flight_non_delayable_threshold_; |
| 182 } |
| 183 |
| 184 // Returns the number of in-flight layout-blocking requests above which |
| 185 // all delayable requests should be blocked when |
| 186 // enable_layout_blocking_threshold is set. |
| 187 size_t in_flight_non_delayable_threshold() const { |
| 188 return in_flight_non_delayable_threshold_; |
| 189 } |
| 190 |
| 191 // Returns the maximum number of delayable requests to allow be in-flight |
| 192 // at any point in time while in the layout-blocking phase of loading. |
| 193 size_t max_num_delayable_while_layout_blocking() const { |
| 194 return max_num_delayable_while_layout_blocking_; |
| 195 } |
| 196 |
| 197 // Returns the maximum number of delayable requests to all be in-flight at |
| 198 // any point in time (across all hosts). |
| 199 size_t max_num_delayable_requests() const { |
| 200 return max_num_delayable_requests_; |
| 201 } |
| 202 |
| 176 enum ClientState { | 203 enum ClientState { |
| 177 // Observable client. | 204 // Observable client. |
| 178 ACTIVE, | 205 ACTIVE, |
| 179 // Non-observable client. | 206 // Non-observable client. |
| 180 BACKGROUND, | 207 BACKGROUND, |
| 181 // No client found. | 208 // No client found. |
| 182 UNKNOWN, | 209 UNKNOWN, |
| 183 }; | 210 }; |
| 184 | 211 |
| 185 class RequestQueue; | 212 class RequestQueue; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // Returns the client for the given |child_id| and |route_id| combo. | 256 // Returns the client for the given |child_id| and |route_id| combo. |
| 230 Client* GetClient(int child_id, int route_id); | 257 Client* GetClient(int child_id, int route_id); |
| 231 | 258 |
| 232 bool should_coalesce_; | 259 bool should_coalesce_; |
| 233 bool should_throttle_; | 260 bool should_throttle_; |
| 234 ClientMap client_map_; | 261 ClientMap client_map_; |
| 235 size_t active_clients_loading_; | 262 size_t active_clients_loading_; |
| 236 size_t coalesced_clients_; | 263 size_t coalesced_clients_; |
| 237 bool limit_outstanding_requests_; | 264 bool limit_outstanding_requests_; |
| 238 size_t outstanding_request_limit_; | 265 size_t outstanding_request_limit_; |
| 266 net::RequestPriority non_delayable_threshold_; |
| 267 bool enable_in_flight_non_delayable_threshold_; |
| 268 size_t in_flight_non_delayable_threshold_; |
| 269 size_t max_num_delayable_while_layout_blocking_; |
| 270 size_t max_num_delayable_requests_; |
| 239 // This is a repeating timer to initiate requests on COALESCED Clients. | 271 // This is a repeating timer to initiate requests on COALESCED Clients. |
| 240 scoped_ptr<base::Timer> coalescing_timer_; | 272 scoped_ptr<base::Timer> coalescing_timer_; |
| 241 RequestSet unowned_requests_; | 273 RequestSet unowned_requests_; |
| 242 | 274 |
| 243 DISALLOW_COPY_AND_ASSIGN(ResourceScheduler); | 275 DISALLOW_COPY_AND_ASSIGN(ResourceScheduler); |
| 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_ |
| OLD | NEW |