Chromium Code Reviews| 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 URLRequest; | 20 class URLRequest; |
| 21 class HostPortPair; | |
|
James Simonsen
2013/11/13 01:26:23
Alphabetize.
oystein (OOO til 10th of July)
2013/11/14 00:19:07
Done.
| |
| 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: |
| 30 // 1. Requests to start, cancel, or finish fetching a resource. | 31 // 1. Requests to start, cancel, or finish fetching a resource. |
| (...skipping 69 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(Client* client, |
| 112 net::HostPortPair* active_request_host, | |
| 113 size_t* total_delayable, | |
| 114 size_t* total_for_active_host) const; | |
| 115 | |
| 116 enum ShouldStartReqResult { | |
| 117 kDoNotStartRequest_StopSearching = -2, | |
|
James Simonsen
2013/11/13 01:26:23
Is this proper style now? net/ uses all caps for e
oystein (OOO til 10th of July)
2013/11/14 00:19:07
Changed; but this seems super inconsistent right n
James Simonsen
2013/11/14 19:22:43
I don't have a preference. We should just follow w
oystein (OOO til 10th of July)
2013/11/14 19:51:49
Done.
| |
| 118 kDoNotStartRequest_KeepSearching = -1, | |
| 119 kStartRequest = 1, | |
| 120 }; | |
| 111 | 121 |
| 112 // Returns true if the request should start. This is the core scheduling | 122 // Returns true if the request should start. This is the core scheduling |
| 113 // algorithm. | 123 // algorithm. |
| 114 bool ShouldStartRequest(ScheduledResourceRequest* request, | 124 ShouldStartReqResult ShouldStartRequest(ScheduledResourceRequest* request, |
| 115 Client* client) const; | 125 Client* client) const; |
| 116 | 126 |
| 117 // Returns the client ID for the given |child_id| and |route_id| combo. | 127 // Returns the client ID for the given |child_id| and |route_id| combo. |
| 118 ClientId MakeClientId(int child_id, int route_id); | 128 ClientId MakeClientId(int child_id, int route_id); |
| 119 | 129 |
| 120 ClientMap client_map_; | 130 ClientMap client_map_; |
| 121 RequestSet unowned_requests_; | 131 RequestSet unowned_requests_; |
| 122 }; | 132 }; |
| 123 | 133 |
| 124 } // namespace content | 134 } // namespace content |
| 125 | 135 |
| 126 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ | 136 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ |
| OLD | NEW |