| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <set> | 13 #include <set> |
| 14 | 14 |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/threading/non_thread_safe.h" | 17 #include "base/sequence_checker.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "net/base/priority_queue.h" | 19 #include "net/base/priority_queue.h" |
| 20 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
| 21 | 21 |
| 22 namespace net { | 22 namespace net { |
| 23 class URLRequest; | 23 class URLRequest; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 class ResourceThrottle; | 27 class ResourceThrottle; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 45 // Each Client may have many Requests in flight. Requests are uniquely | 45 // Each Client may have many Requests in flight. Requests are uniquely |
| 46 // identified within a Client by its ScheduledResourceRequest. | 46 // identified within a Client by its ScheduledResourceRequest. |
| 47 // | 47 // |
| 48 // Users should call ScheduleRequest() to notify this ResourceScheduler of a new | 48 // Users should call ScheduleRequest() to notify this ResourceScheduler of a new |
| 49 // request. The returned ResourceThrottle should be destroyed when the load | 49 // request. The returned ResourceThrottle should be destroyed when the load |
| 50 // finishes or is canceled, before the net::URLRequest. | 50 // finishes or is canceled, before the net::URLRequest. |
| 51 // | 51 // |
| 52 // The scheduler may defer issuing the request via the ResourceThrottle | 52 // The scheduler may defer issuing the request via the ResourceThrottle |
| 53 // interface or it may alter the request's priority by calling set_priority() on | 53 // interface or it may alter the request's priority by calling set_priority() on |
| 54 // the URLRequest. | 54 // the URLRequest. |
| 55 class CONTENT_EXPORT ResourceScheduler : public base::NonThreadSafe { | 55 class CONTENT_EXPORT ResourceScheduler { |
| 56 public: | 56 public: |
| 57 ResourceScheduler(); | 57 ResourceScheduler(); |
| 58 ~ResourceScheduler(); | 58 ~ResourceScheduler(); |
| 59 | 59 |
| 60 // Requests that this ResourceScheduler schedule, and eventually loads, the | 60 // Requests that this ResourceScheduler schedule, and eventually loads, the |
| 61 // specified |url_request|. Caller should delete the returned ResourceThrottle | 61 // specified |url_request|. Caller should delete the returned ResourceThrottle |
| 62 // when the load completes or is canceled, before |url_request| is deleted. | 62 // when the load completes or is canceled, before |url_request| is deleted. |
| 63 std::unique_ptr<ResourceThrottle> ScheduleRequest( | 63 std::unique_ptr<ResourceThrottle> ScheduleRequest( |
| 64 int child_id, | 64 int child_id, |
| 65 int route_id, | 65 int route_id, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 // True if requests to servers that support priorities (e.g., H2/QUIC) can | 144 // True if requests to servers that support priorities (e.g., H2/QUIC) can |
| 145 // be delayed. | 145 // be delayed. |
| 146 bool priority_requests_delayable_; | 146 bool priority_requests_delayable_; |
| 147 | 147 |
| 148 // True if the scheduler should yield between several successive calls to | 148 // True if the scheduler should yield between several successive calls to |
| 149 // start resource requests. | 149 // start resource requests. |
| 150 bool yielding_scheduler_enabled_; | 150 bool yielding_scheduler_enabled_; |
| 151 int max_requests_before_yielding_; | 151 int max_requests_before_yielding_; |
| 152 | 152 |
| 153 SEQUENCE_CHECKER(sequence_checker_); |
| 154 |
| 153 DISALLOW_COPY_AND_ASSIGN(ResourceScheduler); | 155 DISALLOW_COPY_AND_ASSIGN(ResourceScheduler); |
| 154 }; | 156 }; |
| 155 | 157 |
| 156 } // namespace content | 158 } // namespace content |
| 157 | 159 |
| 158 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ | 160 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ |
| OLD | NEW |