| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 // Signals from the IO thread | 81 // Signals from the IO thread |
| 82 | 82 |
| 83 // Called when we received a response to a http request that was served | 83 // Called when we received a response to a http request that was served |
| 84 // from a proxy using SPDY. | 84 // from a proxy using SPDY. |
| 85 void OnReceivedSpdyProxiedHttpResponse(int child_id, int route_id); | 85 void OnReceivedSpdyProxiedHttpResponse(int child_id, int route_id); |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 class RequestQueue; | 88 class RequestQueue; |
| 89 class ScheduledResourceRequest; | 89 class ScheduledResourceRequest; |
| 90 struct ScheduledResourceSorter { |
| 91 bool operator()(const ScheduledResourceRequest* a, |
| 92 const ScheduledResourceRequest* b) const; |
| 93 }; |
| 90 struct Client; | 94 struct Client; |
| 91 | 95 |
| 92 typedef int64 ClientId; | 96 typedef int64 ClientId; |
| 93 typedef std::map<ClientId, Client*> ClientMap; | 97 typedef std::map<ClientId, Client*> ClientMap; |
| 94 typedef std::set<ScheduledResourceRequest*> RequestSet; | 98 typedef std::set<ScheduledResourceRequest*> RequestSet; |
| 95 | 99 |
| 96 // Called when a ScheduledResourceRequest is destroyed. | 100 // Called when a ScheduledResourceRequest is destroyed. |
| 97 void RemoveRequest(ScheduledResourceRequest* request); | 101 void RemoveRequest(ScheduledResourceRequest* request); |
| 98 | 102 |
| 99 // Unthrottles the |request| and adds it to |client|. | 103 // Unthrottles the |request| and adds it to |client|. |
| 100 void StartRequest(ScheduledResourceRequest* request, Client* client); | 104 void StartRequest(ScheduledResourceRequest* request, Client* client); |
| 101 | 105 |
| 102 // Update the queue position for |request|, possibly causing it to start | 106 // Update the queue position for |request|, possibly causing it to start |
| 103 // loading. | 107 // loading. |
| 104 // | 108 // |
| 105 // Queues are maintained for each priority level. When |request| is | 109 // Queues are maintained for each priority level. When |request| is |
| 106 // reprioritized, it will move to the end of the queue for that priority | 110 // reprioritized, it will move to the end of the queue for that priority |
| 107 // level. | 111 // level. |
| 108 void ReprioritizeRequest(ScheduledResourceRequest* request, | 112 void ReprioritizeRequest(ScheduledResourceRequest* request, |
| 109 net::RequestPriority new_priority); | 113 net::RequestPriority new_priority, |
| 114 int intra_priority_value); |
| 110 | 115 |
| 111 // Attempts to load any pending requests in |client|, based on the | 116 // Attempts to load any pending requests in |client|, based on the |
| 112 // results of ShouldStartRequest(). | 117 // results of ShouldStartRequest(). |
| 113 void LoadAnyStartablePendingRequests(Client* client); | 118 void LoadAnyStartablePendingRequests(Client* client); |
| 114 | 119 |
| 115 // Returns the number of requests with priority < LOW that are currently in | 120 // Returns the number of requests with priority < LOW that are currently in |
| 116 // flight. | 121 // flight. |
| 117 void GetNumDelayableRequestsInFlight( | 122 void GetNumDelayableRequestsInFlight( |
| 118 Client* client, | 123 Client* client, |
| 119 const net::HostPortPair& active_request_host, | 124 const net::HostPortPair& active_request_host, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 134 // Returns the client ID for the given |child_id| and |route_id| combo. | 139 // Returns the client ID for the given |child_id| and |route_id| combo. |
| 135 ClientId MakeClientId(int child_id, int route_id); | 140 ClientId MakeClientId(int child_id, int route_id); |
| 136 | 141 |
| 137 ClientMap client_map_; | 142 ClientMap client_map_; |
| 138 RequestSet unowned_requests_; | 143 RequestSet unowned_requests_; |
| 139 }; | 144 }; |
| 140 | 145 |
| 141 } // namespace content | 146 } // namespace content |
| 142 | 147 |
| 143 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ | 148 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ |
| OLD | NEW |