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 "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "content/public/browser/web_contents.h" |
17 #include "net/base/priority_queue.h" | 18 #include "net/base/priority_queue.h" |
18 #include "net/base/request_priority.h" | 19 #include "net/base/request_priority.h" |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 class HostPortPair; | 22 class HostPortPair; |
22 class URLRequest; | 23 class URLRequest; |
23 } | 24 } |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 class ResourceThrottle; | 27 class ResourceThrottle; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 97 |
97 // Requests that this ResourceScheduler schedule, and eventually loads, the | 98 // Requests that this ResourceScheduler schedule, and eventually loads, the |
98 // specified |url_request|. Caller should delete the returned ResourceThrottle | 99 // specified |url_request|. Caller should delete the returned ResourceThrottle |
99 // when the load completes or is canceled. | 100 // when the load completes or is canceled. |
100 scoped_ptr<ResourceThrottle> ScheduleRequest( | 101 scoped_ptr<ResourceThrottle> ScheduleRequest( |
101 int child_id, int route_id, net::URLRequest* url_request); | 102 int child_id, int route_id, net::URLRequest* url_request); |
102 | 103 |
103 // Signals from the UI thread, posted as tasks on the IO thread: | 104 // Signals from the UI thread, posted as tasks on the IO thread: |
104 | 105 |
105 // Called when a renderer is created. | 106 // Called when a renderer is created. |
106 void OnClientCreated(int child_id, int route_id); | 107 void OnClientCreated(int child_id, |
| 108 int route_id, |
| 109 WebContents* web_contents); |
107 | 110 |
108 // Called when a renderer is destroyed. | 111 // Called when a renderer is destroyed. |
109 void OnClientDeleted(int child_id, int route_id); | 112 void OnClientDeleted(int child_id, int route_id); |
110 | 113 |
111 // Signals from IPC messages directly from the renderers: | 114 // Signals from IPC messages directly from the renderers: |
112 | 115 |
113 // Called when a client navigates to a new main document. | 116 // Called when a client navigates to a new main document. |
114 void OnNavigate(int child_id, int route_id); | 117 void OnNavigate(int child_id, int route_id); |
115 | 118 |
116 // Called when the client has parsed the <body> element. This is a signal that | 119 // Called when the client has parsed the <body> element. This is a signal that |
(...skipping 12 matching lines...) Expand all Loading... |
129 bool active_clients_loaded() const { return active_clients_loading_ == 0; } | 132 bool active_clients_loaded() const { return active_clients_loading_ == 0; } |
130 | 133 |
131 // Called when a Client starts or stops playing audio. | 134 // Called when a Client starts or stops playing audio. |
132 void OnAudibilityChanged(int child_id, int route_id, bool is_audible); | 135 void OnAudibilityChanged(int child_id, int route_id, bool is_audible); |
133 | 136 |
134 // Called when a Client is shown or hidden. | 137 // Called when a Client is shown or hidden. |
135 void OnVisibilityChanged(int child_id, int route_id, bool is_visible); | 138 void OnVisibilityChanged(int child_id, int route_id, bool is_visible); |
136 | 139 |
137 void OnLoadingStateChanged(int child_id, int route_id, bool is_loaded); | 140 void OnLoadingStateChanged(int child_id, int route_id, bool is_loaded); |
138 | 141 |
| 142 bool ClientIsVisible(int child_id, int route_id); |
| 143 |
139 private: | 144 private: |
140 class RequestQueue; | 145 class RequestQueue; |
141 class ScheduledResourceRequest; | 146 class ScheduledResourceRequest; |
142 struct RequestPriorityParams; | 147 struct RequestPriorityParams; |
143 struct ScheduledResourceSorter { | 148 struct ScheduledResourceSorter { |
144 bool operator()(const ScheduledResourceRequest* a, | 149 bool operator()(const ScheduledResourceRequest* a, |
145 const ScheduledResourceRequest* b) const; | 150 const ScheduledResourceRequest* b) const; |
146 }; | 151 }; |
147 class Client; | 152 class Client; |
148 | 153 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 size_t active_clients_loading_; | 201 size_t active_clients_loading_; |
197 size_t coalesced_clients_; | 202 size_t coalesced_clients_; |
198 // This is a repeating timer to initiate requests on COALESCED Clients. | 203 // This is a repeating timer to initiate requests on COALESCED Clients. |
199 scoped_ptr<base::Timer> coalescing_timer_; | 204 scoped_ptr<base::Timer> coalescing_timer_; |
200 RequestSet unowned_requests_; | 205 RequestSet unowned_requests_; |
201 }; | 206 }; |
202 | 207 |
203 } // namespace content | 208 } // namespace content |
204 | 209 |
205 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ | 210 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ |
OLD | NEW |