| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 // Requests that this ResourceScheduler schedule, and eventually loads, the | 105 // Requests that this ResourceScheduler schedule, and eventually loads, the |
| 106 // specified |url_request|. Caller should delete the returned ResourceThrottle | 106 // specified |url_request|. Caller should delete the returned ResourceThrottle |
| 107 // when the load completes or is canceled. | 107 // when the load completes or is canceled. |
| 108 scoped_ptr<ResourceThrottle> ScheduleRequest( | 108 scoped_ptr<ResourceThrottle> ScheduleRequest( |
| 109 int child_id, int route_id, net::URLRequest* url_request); | 109 int child_id, int route_id, net::URLRequest* url_request); |
| 110 | 110 |
| 111 // Signals from the UI thread, posted as tasks on the IO thread: | 111 // Signals from the UI thread, posted as tasks on the IO thread: |
| 112 | 112 |
| 113 // Called when a renderer is created. | 113 // Called when a renderer is created. |
| 114 void OnClientCreated(int child_id, int route_id, bool is_visible); | 114 void OnClientCreated(int child_id, |
| 115 int route_id, |
| 116 bool is_visible, |
| 117 bool is_audible); |
| 115 | 118 |
| 116 // Called when a renderer is destroyed. | 119 // Called when a renderer is destroyed. |
| 117 void OnClientDeleted(int child_id, int route_id); | 120 void OnClientDeleted(int child_id, int route_id); |
| 118 | 121 |
| 119 // Called when a renderer stops or restarts loading. | 122 // Called when a renderer stops or restarts loading. |
| 120 void OnLoadingStateChanged(int child_id, int route_id, bool is_loaded); | 123 void OnLoadingStateChanged(int child_id, int route_id, bool is_loaded); |
| 121 | 124 |
| 122 // Called when a Client is shown or hidden. | 125 // Called when a Client is shown or hidden. |
| 123 void OnVisibilityChanged(int child_id, int route_id, bool is_visible); | 126 void OnVisibilityChanged(int child_id, int route_id, bool is_visible); |
| 124 | 127 |
| 128 // Called when a Client starts or stops playing audio. |
| 129 void OnAudibilityChanged(int child_id, int route_id, bool is_audible); |
| 130 |
| 125 // Signals from IPC messages directly from the renderers: | 131 // Signals from IPC messages directly from the renderers: |
| 126 | 132 |
| 127 // Called when a client navigates to a new main document. | 133 // Called when a client navigates to a new main document. |
| 128 void OnNavigate(int child_id, int route_id); | 134 void OnNavigate(int child_id, int route_id); |
| 129 | 135 |
| 130 // Called when the client has parsed the <body> element. This is a signal that | 136 // Called when the client has parsed the <body> element. This is a signal that |
| 131 // resource loads won't interfere with first paint. | 137 // resource loads won't interfere with first paint. |
| 132 void OnWillInsertBody(int child_id, int route_id); | 138 void OnWillInsertBody(int child_id, int route_id); |
| 133 | 139 |
| 134 // Signals from the IO thread: | 140 // Signals from the IO thread: |
| 135 | 141 |
| 136 // Called when we received a response to a http request that was served | 142 // Called when we received a response to a http request that was served |
| 137 // from a proxy using SPDY. | 143 // from a proxy using SPDY. |
| 138 void OnReceivedSpdyProxiedHttpResponse(int child_id, int route_id); | 144 void OnReceivedSpdyProxiedHttpResponse(int child_id, int route_id); |
| 139 | 145 |
| 140 // Client functions: | 146 // Client functions: |
| 141 | 147 |
| 142 // Called to check if all user observable tabs have completed loading. | 148 // Called to check if all user observable tabs have completed loading. |
| 143 bool active_clients_loaded() const { return active_clients_loading_ == 0; } | 149 bool active_clients_loaded() const { return active_clients_loading_ == 0; } |
| 144 | 150 |
| 145 // Called when a Client starts or stops playing audio. | |
| 146 void OnAudibilityChanged(int child_id, int route_id, bool is_audible); | |
| 147 | |
| 148 bool IsClientVisibleForTesting(int child_id, int route_id); | 151 bool IsClientVisibleForTesting(int child_id, int route_id); |
| 149 | 152 |
| 150 private: | 153 private: |
| 151 class RequestQueue; | 154 class RequestQueue; |
| 152 class ScheduledResourceRequest; | 155 class ScheduledResourceRequest; |
| 153 struct RequestPriorityParams; | 156 struct RequestPriorityParams; |
| 154 struct ScheduledResourceSorter { | 157 struct ScheduledResourceSorter { |
| 155 bool operator()(const ScheduledResourceRequest* a, | 158 bool operator()(const ScheduledResourceRequest* a, |
| 156 const ScheduledResourceRequest* b) const; | 159 const ScheduledResourceRequest* b) const; |
| 157 }; | 160 }; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 size_t active_clients_loading_; | 210 size_t active_clients_loading_; |
| 208 size_t coalesced_clients_; | 211 size_t coalesced_clients_; |
| 209 // This is a repeating timer to initiate requests on COALESCED Clients. | 212 // This is a repeating timer to initiate requests on COALESCED Clients. |
| 210 scoped_ptr<base::Timer> coalescing_timer_; | 213 scoped_ptr<base::Timer> coalescing_timer_; |
| 211 RequestSet unowned_requests_; | 214 RequestSet unowned_requests_; |
| 212 }; | 215 }; |
| 213 | 216 |
| 214 } // namespace content | 217 } // namespace content |
| 215 | 218 |
| 216 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ | 219 #endif // CONTENT_BROWSER_LOADER_RESOURCE_SCHEDULER_H_ |
| OLD | NEW |