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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "net/base/priority_queue.h" | 16 #include "net/base/priority_queue.h" |
17 #include "net/base/request_priority.h" | 17 #include "net/base/request_priority.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
| 20 class HostPortPair; |
20 class URLRequest; | 21 class URLRequest; |
21 } | 22 } |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 class ResourceThrottle; | 25 class ResourceThrottle; |
25 | 26 |
26 // There is one ResourceScheduler. All renderer-initiated HTTP requests are | 27 // There is one ResourceScheduler. All renderer-initiated HTTP requests are |
27 // expected to pass through it. | 28 // expected to pass through it. |
28 // | 29 // |
29 // There are two types of input to the scheduler: | 30 // There are two types of input to the scheduler: |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // level. | 101 // level. |
101 void ReprioritizeRequest(ScheduledResourceRequest* request, | 102 void ReprioritizeRequest(ScheduledResourceRequest* request, |
102 net::RequestPriority new_priority); | 103 net::RequestPriority new_priority); |
103 | 104 |
104 // Attempts to load any pending requests in |client|, based on the | 105 // Attempts to load any pending requests in |client|, based on the |
105 // results of ShouldStartRequest(). | 106 // results of ShouldStartRequest(). |
106 void LoadAnyStartablePendingRequests(Client* client); | 107 void LoadAnyStartablePendingRequests(Client* client); |
107 | 108 |
108 // Returns the number of requests with priority < LOW that are currently in | 109 // Returns the number of requests with priority < LOW that are currently in |
109 // flight. | 110 // flight. |
110 size_t GetNumDelayableRequestsInFlight(Client* client) const; | 111 void GetNumDelayableRequestsInFlight( |
| 112 Client* client, |
| 113 const net::HostPortPair& active_request_host, |
| 114 size_t* total_delayable, |
| 115 size_t* total_for_active_host) const; |
| 116 |
| 117 enum ShouldStartReqResult { |
| 118 DO_NOT_START_REQUEST_AND_STOP_SEARCHING = -2, |
| 119 DO_NOT_START_REQUEST_AND_KEEP_SEARCHING = -1, |
| 120 START_REQUEST = 1, |
| 121 }; |
111 | 122 |
112 // Returns true if the request should start. This is the core scheduling | 123 // Returns true if the request should start. This is the core scheduling |
113 // algorithm. | 124 // algorithm. |
114 bool ShouldStartRequest(ScheduledResourceRequest* request, | 125 ShouldStartReqResult ShouldStartRequest(ScheduledResourceRequest* request, |
115 Client* client) const; | 126 Client* client) const; |
116 | 127 |
117 // Returns the client ID for the given |child_id| and |route_id| combo. | 128 // Returns the client ID for the given |child_id| and |route_id| combo. |
118 ClientId MakeClientId(int child_id, int route_id); | 129 ClientId MakeClientId(int child_id, int route_id); |
119 | 130 |
120 ClientMap client_map_; | 131 ClientMap client_map_; |
121 RequestSet unowned_requests_; | 132 RequestSet unowned_requests_; |
122 }; | 133 }; |
123 | 134 |
124 } // namespace content | 135 } // namespace content |
125 | 136 |
126 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ | 137 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ |
OLD | NEW |