| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 7 Copyright (C) 2010 Google Inc. All rights reserved. | 7 Copyright (C) 2010 Google Inc. All rights reserved. |
| 8 | 8 |
| 9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
| 10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ResourceLoadScheduler::scheduleLoad(ResourceLoader* resourceLoader, Resourc
eLoadPriority priority) | 135 void ResourceLoadScheduler::scheduleLoad(ResourceLoader* resourceLoader, Resourc
eLoadPriority priority) |
| 136 { | 136 { |
| 137 ASSERT(resourceLoader); | 137 ASSERT(resourceLoader); |
| 138 ASSERT(priority != ResourceLoadPriorityUnresolved); | 138 ASSERT(priority != ResourceLoadPriorityUnresolved); |
| 139 #if !REQUEST_MANAGEMENT_ENABLED | 139 #if !REQUEST_MANAGEMENT_ENABLED |
| 140 priority = ResourceLoadPriorityHighest; | 140 priority = ResourceLoadPriorityHighest; |
| 141 #endif | 141 #endif |
| 142 | 142 |
| 143 LOG(ResourceLoading, "ResourceLoadScheduler::load resource %p '%s'", resourc
eLoader, resourceLoader->url().string().latin1().data()); | 143 LOG_INFO(ResourceLoading, "ResourceLoadScheduler::load resource %p '%s'", re
sourceLoader, resourceLoader->url().string().latin1().data()); |
| 144 | 144 |
| 145 // If there's a web archive resource for this URL, we don't need to schedule
the load since it will never touch the network. | 145 // If there's a web archive resource for this URL, we don't need to schedule
the load since it will never touch the network. |
| 146 if (resourceLoader->documentLoader()->archiveResourceForURL(resourceLoader->
request().url())) { | 146 if (resourceLoader->documentLoader()->archiveResourceForURL(resourceLoader->
request().url())) { |
| 147 resourceLoader->start(); | 147 resourceLoader->start(); |
| 148 return; | 148 return; |
| 149 } | 149 } |
| 150 | 150 |
| 151 HostInformation* host = hostForURL(resourceLoader->url(), CreateIfNotFound);
| 151 HostInformation* host = hostForURL(resourceLoader->url(), CreateIfNotFound);
|
| 152 bool hadRequests = host->hasRequests(); | 152 bool hadRequests = host->hasRequests(); |
| 153 host->schedule(resourceLoader, priority); | 153 host->schedule(resourceLoader, priority); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 188 |
| 189 if (oldHost->name() == newHost->name()) | 189 if (oldHost->name() == newHost->name()) |
| 190 return; | 190 return; |
| 191 | 191 |
| 192 newHost->addLoadInProgress(resourceLoader); | 192 newHost->addLoadInProgress(resourceLoader); |
| 193 oldHost->remove(resourceLoader); | 193 oldHost->remove(resourceLoader); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void ResourceLoadScheduler::servePendingRequests(ResourceLoadPriority minimumPri
ority) | 196 void ResourceLoadScheduler::servePendingRequests(ResourceLoadPriority minimumPri
ority) |
| 197 { | 197 { |
| 198 LOG(ResourceLoading, "ResourceLoadScheduler::servePendingRequests. m_suspend
PendingRequestsCount=%d", m_suspendPendingRequestsCount); | 198 LOG_INFO(ResourceLoading, "ResourceLoadScheduler::servePendingRequests. m_su
spendPendingRequestsCount=%d", m_suspendPendingRequestsCount); |
| 199 if (isSuspendingPendingRequests()) | 199 if (isSuspendingPendingRequests()) |
| 200 return; | 200 return; |
| 201 | 201 |
| 202 m_requestTimer.stop(); | 202 m_requestTimer.stop(); |
| 203 | 203 |
| 204 servePendingRequests(m_nonHTTPProtocolHost, minimumPriority); | 204 servePendingRequests(m_nonHTTPProtocolHost, minimumPriority); |
| 205 | 205 |
| 206 Vector<HostInformation*> hostsToServe; | 206 Vector<HostInformation*> hostsToServe; |
| 207 m_hosts.checkConsistency(); | 207 m_hosts.checkConsistency(); |
| 208 HostMap::iterator end = m_hosts.end(); | 208 HostMap::iterator end = m_hosts.end(); |
| 209 for (HostMap::iterator iter = m_hosts.begin(); iter != end; ++iter) | 209 for (HostMap::iterator iter = m_hosts.begin(); iter != end; ++iter) |
| 210 hostsToServe.append(iter->value); | 210 hostsToServe.append(iter->value); |
| 211 | 211 |
| 212 int size = hostsToServe.size(); | 212 int size = hostsToServe.size(); |
| 213 for (int i = 0; i < size; ++i) { | 213 for (int i = 0; i < size; ++i) { |
| 214 HostInformation* host = hostsToServe[i]; | 214 HostInformation* host = hostsToServe[i]; |
| 215 if (host->hasRequests()) | 215 if (host->hasRequests()) |
| 216 servePendingRequests(host, minimumPriority); | 216 servePendingRequests(host, minimumPriority); |
| 217 else | 217 else |
| 218 delete m_hosts.take(host->name()); | 218 delete m_hosts.take(host->name()); |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 void ResourceLoadScheduler::servePendingRequests(HostInformation* host, Resource
LoadPriority minimumPriority) | 222 void ResourceLoadScheduler::servePendingRequests(HostInformation* host, Resource
LoadPriority minimumPriority) |
| 223 { | 223 { |
| 224 LOG(ResourceLoading, "ResourceLoadScheduler::servePendingRequests HostInform
ation.m_name='%s'", host->name().latin1().data()); | 224 LOG_INFO(ResourceLoading, "ResourceLoadScheduler::servePendingRequests HostI
nformation.m_name='%s'", host->name().latin1().data()); |
| 225 | 225 |
| 226 for (int priority = ResourceLoadPriorityHighest; priority >= minimumPriority
; --priority) { | 226 for (int priority = ResourceLoadPriorityHighest; priority >= minimumPriority
; --priority) { |
| 227 HostInformation::RequestQueue& requestsPending = host->requestsPending(R
esourceLoadPriority(priority)); | 227 HostInformation::RequestQueue& requestsPending = host->requestsPending(R
esourceLoadPriority(priority)); |
| 228 | 228 |
| 229 while (!requestsPending.isEmpty()) { | 229 while (!requestsPending.isEmpty()) { |
| 230 RefPtr<ResourceLoader> resourceLoader = requestsPending.first(); | 230 RefPtr<ResourceLoader> resourceLoader = requestsPending.first(); |
| 231 | 231 |
| 232 // For named hosts - which are only http(s) hosts - we should always
enforce the connection limit. | 232 // For named hosts - which are only http(s) hosts - we should always
enforce the connection limit. |
| 233 // For non-named hosts - everything but http(s) - we should only enf
orce the limit if the document isn't done parsing | 233 // For non-named hosts - everything but http(s) - we should only enf
orce the limit if the document isn't done parsing |
| 234 // and we don't know all stylesheets yet. | 234 // and we don't know all stylesheets yet. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 254 ASSERT(m_suspendPendingRequestsCount); | 254 ASSERT(m_suspendPendingRequestsCount); |
| 255 --m_suspendPendingRequestsCount; | 255 --m_suspendPendingRequestsCount; |
| 256 if (m_suspendPendingRequestsCount) | 256 if (m_suspendPendingRequestsCount) |
| 257 return; | 257 return; |
| 258 if (!m_hosts.isEmpty() || m_nonHTTPProtocolHost->hasRequests()) | 258 if (!m_hosts.isEmpty() || m_nonHTTPProtocolHost->hasRequests()) |
| 259 scheduleServePendingRequests(); | 259 scheduleServePendingRequests(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void ResourceLoadScheduler::scheduleServePendingRequests() | 262 void ResourceLoadScheduler::scheduleServePendingRequests() |
| 263 { | 263 { |
| 264 LOG(ResourceLoading, "ResourceLoadScheduler::scheduleServePendingRequests, m
_requestTimer.isActive()=%u", m_requestTimer.isActive()); | 264 LOG_INFO(ResourceLoading, "ResourceLoadScheduler::scheduleServePendingReques
ts, m_requestTimer.isActive()=%u", m_requestTimer.isActive()); |
| 265 if (!m_requestTimer.isActive()) | 265 if (!m_requestTimer.isActive()) |
| 266 m_requestTimer.startOneShot(0); | 266 m_requestTimer.startOneShot(0); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void ResourceLoadScheduler::requestTimerFired(Timer<ResourceLoadScheduler>*) | 269 void ResourceLoadScheduler::requestTimerFired(Timer<ResourceLoadScheduler>*) |
| 270 { | 270 { |
| 271 LOG(ResourceLoading, "ResourceLoadScheduler::requestTimerFired\n"); | 271 LOG_INFO(ResourceLoading, "ResourceLoadScheduler::requestTimerFired\n"); |
| 272 servePendingRequests(); | 272 servePendingRequests(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 ResourceLoadScheduler::HostInformation::HostInformation(const String& name, unsi
gned maxRequestsInFlight) | 275 ResourceLoadScheduler::HostInformation::HostInformation(const String& name, unsi
gned maxRequestsInFlight) |
| 276 : m_name(name) | 276 : m_name(name) |
| 277 , m_maxRequestsInFlight(maxRequestsInFlight) | 277 , m_maxRequestsInFlight(maxRequestsInFlight) |
| 278 { | 278 { |
| 279 } | 279 } |
| 280 | 280 |
| 281 ResourceLoadScheduler::HostInformation::~HostInformation() | 281 ResourceLoadScheduler::HostInformation::~HostInformation() |
| 282 { | 282 { |
| 283 ASSERT(m_requestsLoading.isEmpty()); | 283 ASSERT(m_requestsLoading.isEmpty()); |
| 284 for (unsigned p = 0; p <= ResourceLoadPriorityHighest; p++) | 284 for (unsigned p = 0; p <= ResourceLoadPriorityHighest; p++) |
| 285 ASSERT(m_requestsPending[p].isEmpty()); | 285 ASSERT(m_requestsPending[p].isEmpty()); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void ResourceLoadScheduler::HostInformation::schedule(ResourceLoader* resourceLo
ader, ResourceLoadPriority priority) | 288 void ResourceLoadScheduler::HostInformation::schedule(ResourceLoader* resourceLo
ader, ResourceLoadPriority priority) |
| 289 { | 289 { |
| 290 m_requestsPending[priority].append(resourceLoader); | 290 m_requestsPending[priority].append(resourceLoader); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void ResourceLoadScheduler::HostInformation::addLoadInProgress(ResourceLoader* r
esourceLoader) | 293 void ResourceLoadScheduler::HostInformation::addLoadInProgress(ResourceLoader* r
esourceLoader) |
| 294 { | 294 { |
| 295 LOG(ResourceLoading, "HostInformation '%s' loading '%s'. Current count %d",
m_name.latin1().data(), resourceLoader->url().string().latin1().data(), m_reques
tsLoading.size()); | 295 LOG_INFO(ResourceLoading, "HostInformation '%s' loading '%s'. Current count
%d", m_name.latin1().data(), resourceLoader->url().string().latin1().data(), m_r
equestsLoading.size()); |
| 296 m_requestsLoading.add(resourceLoader); | 296 m_requestsLoading.add(resourceLoader); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void ResourceLoadScheduler::HostInformation::remove(ResourceLoader* resourceLoad
er) | 299 void ResourceLoadScheduler::HostInformation::remove(ResourceLoader* resourceLoad
er) |
| 300 { | 300 { |
| 301 if (m_requestsLoading.contains(resourceLoader)) { | 301 if (m_requestsLoading.contains(resourceLoader)) { |
| 302 m_requestsLoading.remove(resourceLoader); | 302 m_requestsLoading.remove(resourceLoader); |
| 303 return; | 303 return; |
| 304 } | 304 } |
| 305 | 305 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 326 } | 326 } |
| 327 | 327 |
| 328 bool ResourceLoadScheduler::HostInformation::limitRequests(ResourceLoadPriority
priority) const | 328 bool ResourceLoadScheduler::HostInformation::limitRequests(ResourceLoadPriority
priority) const |
| 329 { | 329 { |
| 330 if (priority == ResourceLoadPriorityVeryLow && !m_requestsLoading.isEmpty()) | 330 if (priority == ResourceLoadPriorityVeryLow && !m_requestsLoading.isEmpty()) |
| 331 return true; | 331 return true; |
| 332 return m_requestsLoading.size() >= (resourceLoadScheduler()->isSerialLoading
Enabled() ? 1 : m_maxRequestsInFlight); | 332 return m_requestsLoading.size() >= (resourceLoadScheduler()->isSerialLoading
Enabled() ? 1 : m_maxRequestsInFlight); |
| 333 } | 333 } |
| 334 | 334 |
| 335 } // namespace WebCore | 335 } // namespace WebCore |
| OLD | NEW |