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 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // Returns true if at least one client is currently loading. | 98 // Returns true if at least one client is currently loading. |
99 bool HasLoadingClients() const; | 99 bool HasLoadingClients() const; |
100 | 100 |
101 // Update the priority for |request|. Modifies request->priority(), and may | 101 // Update the priority for |request|. Modifies request->priority(), and may |
102 // start the request loading if it wasn't already started. | 102 // start the request loading if it wasn't already started. |
103 void ReprioritizeRequest(net::URLRequest* request, | 103 void ReprioritizeRequest(net::URLRequest* request, |
104 net::RequestPriority new_priority, | 104 net::RequestPriority new_priority, |
105 int intra_priority_value); | 105 int intra_priority_value); |
106 | 106 |
107 private: | 107 private: |
108 // Returns true if limiting of outstanding requests is enabled. | |
109 bool limit_outstanding_requests() const { | |
110 return limit_outstanding_requests_; | |
111 } | |
112 | |
113 // Returns the outstanding request limit. Only valid if | |
114 // |IsLimitingOutstandingRequests()|. | |
115 size_t outstanding_request_limit() const { | |
116 return outstanding_request_limit_; | |
117 } | |
118 | |
119 // Returns the maximum number of delayable requests to all be in-flight at | 108 // Returns the maximum number of delayable requests to all be in-flight at |
120 // any point in time (across all hosts). | 109 // any point in time (across all hosts). |
121 size_t max_num_delayable_requests() const { | 110 size_t max_num_delayable_requests() const { |
122 return max_num_delayable_requests_; | 111 return max_num_delayable_requests_; |
123 } | 112 } |
124 | 113 |
125 class RequestQueue; | 114 class RequestQueue; |
126 class ScheduledResourceRequest; | 115 class ScheduledResourceRequest; |
127 struct RequestPriorityParams; | 116 struct RequestPriorityParams; |
128 struct ScheduledResourceSorter { | 117 struct ScheduledResourceSorter { |
129 bool operator()(const ScheduledResourceRequest* a, | 118 bool operator()(const ScheduledResourceRequest* a, |
130 const ScheduledResourceRequest* b) const; | 119 const ScheduledResourceRequest* b) const; |
131 }; | 120 }; |
132 class Client; | 121 class Client; |
133 | 122 |
134 typedef int64_t ClientId; | 123 typedef int64_t ClientId; |
135 typedef std::map<ClientId, Client*> ClientMap; | 124 typedef std::map<ClientId, Client*> ClientMap; |
136 typedef std::set<ScheduledResourceRequest*> RequestSet; | 125 typedef std::set<ScheduledResourceRequest*> RequestSet; |
137 | 126 |
138 // Called when a ScheduledResourceRequest is destroyed. | 127 // Called when a ScheduledResourceRequest is destroyed. |
139 void RemoveRequest(ScheduledResourceRequest* request); | 128 void RemoveRequest(ScheduledResourceRequest* request); |
140 | 129 |
141 // Returns the client ID for the given |child_id| and |route_id| combo. | 130 // Returns the client ID for the given |child_id| and |route_id| combo. |
142 ClientId MakeClientId(int child_id, int route_id); | 131 ClientId MakeClientId(int child_id, int route_id); |
143 | 132 |
144 // Returns the client for the given |child_id| and |route_id| combo. | 133 // Returns the client for the given |child_id| and |route_id| combo. |
145 Client* GetClient(int child_id, int route_id); | 134 Client* GetClient(int child_id, int route_id); |
146 | 135 |
147 ClientMap client_map_; | 136 ClientMap client_map_; |
148 bool limit_outstanding_requests_; | |
149 size_t outstanding_request_limit_; | |
150 size_t max_num_delayable_requests_; | 137 size_t max_num_delayable_requests_; |
151 RequestSet unowned_requests_; | 138 RequestSet unowned_requests_; |
152 | 139 |
153 DISALLOW_COPY_AND_ASSIGN(ResourceScheduler); | 140 DISALLOW_COPY_AND_ASSIGN(ResourceScheduler); |
154 }; | 141 }; |
155 | 142 |
156 } // namespace content | 143 } // namespace content |
157 | 144 |
158 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ | 145 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ |
OLD | NEW |