diff options
author | Ben Murdoch <benm@google.com> | 2010-10-22 13:02:20 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-10-26 15:21:41 +0100 |
commit | a94275402997c11dd2e778633dacf4b7e630a35d (patch) | |
tree | e66f56c67e3b01f22c9c23cd932271ee9ac558ed /WebCore/loader/loader.cpp | |
parent | 09e26c78506587b3f5d930d7bc72a23287ffbec0 (diff) | |
download | external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.zip external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.gz external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.bz2 |
Merge WebKit at r70209: Initial merge by Git
Change-Id: Id23a68efa36e9d1126bcce0b137872db00892c8e
Diffstat (limited to 'WebCore/loader/loader.cpp')
-rw-r--r-- | WebCore/loader/loader.cpp | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/WebCore/loader/loader.cpp b/WebCore/loader/loader.cpp index 3f6fad2..aa3f246 100644 --- a/WebCore/loader/loader.cpp +++ b/WebCore/loader/loader.cpp @@ -28,10 +28,11 @@ #include "CachedImage.h" #include "CachedResource.h" #include "CachedResourceLoader.h" -#include "InspectorTimelineAgent.h" +#include "InspectorInstrumentation.h" #include "Frame.h" #include "FrameLoader.h" #include "HTMLDocument.h" +#include "Logging.h" #include "Request.h" #include "ResourceHandle.h" #include "ResourceRequest.h" @@ -43,7 +44,6 @@ #include <wtf/Vector.h> #define REQUEST_MANAGEMENT_ENABLED 1 -#define REQUEST_DEBUG 0 namespace WebCore { @@ -123,6 +123,8 @@ Loader::Priority Loader::determinePriority(const CachedResource* resource) const void Loader::load(CachedResourceLoader* cachedResourceLoader, CachedResource* resource, bool incremental, SecurityCheckPolicy securityCheck, bool sendResourceLoadCallbacks) { + LOG(ResourceLoading, "Loader::load resource %p '%s'", resource, resource->url().latin1().data()); + ASSERT(cachedResourceLoader); Request* request = new Request(cachedResourceLoader, resource, incremental, securityCheck, sendResourceLoadCallbacks); @@ -149,30 +151,27 @@ void Loader::load(CachedResourceLoader* cachedResourceLoader, CachedResource* re host->servePendingRequests(priority); } else { // Handle asynchronously so early low priority requests don't get scheduled before later high priority ones -#if ENABLE(INSPECTOR) - if (InspectorTimelineAgent::instanceCount()) { - InspectorTimelineAgent* agent = cachedResourceLoader->doc()->inspectorTimelineAgent(); - if (agent) - agent->didScheduleResourceRequest(resource->url()); - } -#endif // ENABLE(INSPECTOR) + InspectorInstrumentation::didScheduleResourceRequest(cachedResourceLoader->doc(), resource->url()); scheduleServePendingRequests(); } } void Loader::scheduleServePendingRequests() { + LOG(ResourceLoading, "Loader::scheduleServePendingRequests, m_requestTimer.isActive()=%u", m_requestTimer.isActive()); if (!m_requestTimer.isActive()) m_requestTimer.startOneShot(0); } void Loader::requestTimerFired(Timer<Loader>*) { + LOG(ResourceLoading, "Loader::requestTimerFired\n"); servePendingRequests(); } void Loader::servePendingRequests(Priority minimumPriority) { + LOG(ResourceLoading, "Loader::servePendingRequests. m_isSuspendingPendingRequests=%d", m_isSuspendingPendingRequests); if (m_isSuspendingPendingRequests) return; @@ -314,8 +313,11 @@ bool Loader::Host::hasRequests() const void Loader::Host::servePendingRequests(Loader::Priority minimumPriority) { - if (cache()->loader()->isSuspendingPendingRequests()) + LOG(ResourceLoading, "Host::servePendingRequests '%s'", m_name.string().latin1().data()); + if (cache()->loader()->isSuspendingPendingRequests()) { + LOG(ResourceLoading, "...isSuspendingPendingRequests"); return; + } bool serveMore = true; for (int priority = High; priority >= minimumPriority && serveMore; --priority) @@ -364,18 +366,26 @@ void Loader::Host::servePendingRequests(RequestQueue& requestsPending, bool& ser } } +#if ENABLE(LINK_PREFETCH) + if (request->cachedResource()->type() == CachedResource::LinkPrefetch) + resourceRequest.setHTTPHeaderField("X-Purpose", "prefetch"); +#endif + RefPtr<SubresourceLoader> loader = SubresourceLoader::create(cachedResourceLoader->doc()->frame(), this, resourceRequest, request->shouldDoSecurityCheck(), request->sendResourceLoadCallbacks()); if (loader) { m_requestsLoading.add(loader.release(), request); request->cachedResource()->setRequestedFromNetworkingLayer(); -#if REQUEST_DEBUG - printf("HOST %s COUNT %d LOADING %s\n", resourceRequest.url().host().latin1().data(), m_requestsLoading.size(), request->cachedResource()->url().latin1().data()); -#endif - } else { - cachedResourceLoader->decrementRequestCount(request->cachedResource()); + LOG(ResourceLoading, "Host '%s' loading '%s'. Current count %d", m_name.string().latin1().data(), request->cachedResource()->url().latin1().data(), m_requestsLoading.size()); + } else { + // FIXME: What if resources in other frames were waiting for this revalidation? + LOG(ResourceLoading, "Host '%s' cannot start loading '%s'", m_name.string().latin1().data(), request->cachedResource()->url().latin1().data()); + CachedResource* resource = request->cachedResource(); + cachedResourceLoader->decrementRequestCount(resource); cachedResourceLoader->setLoadInProgress(true); - request->cachedResource()->error(); + if (resource->resourceToRevalidate()) + cache()->revalidationFailed(resource); + resource->error(); cachedResourceLoader->setLoadInProgress(false); delete request; } @@ -402,6 +412,8 @@ void Loader::Host::didFinishLoading(SubresourceLoader* loader) CachedResource* resource = request->cachedResource(); ASSERT(!resource->resourceToRevalidate()); + LOG(ResourceLoading, "Host '%s' received %s. Current count %d\n", m_name.string().latin1().data(), resource->url().latin1().data(), m_requestsLoading.size()); + // If we got a 4xx response, we're pretending to have received a network // error, so we can't send the successful data() and finish() callbacks. if (!resource->errorOccurred()) { @@ -416,10 +428,6 @@ void Loader::Host::didFinishLoading(SubresourceLoader* loader) cachedResourceLoader->checkForPendingPreloads(); -#if REQUEST_DEBUG - KURL u(ParsedURLString, resource->url()); - printf("HOST %s COUNT %d RECEIVED %s\n", u.host().latin1().data(), m_requestsLoading.size(), resource->url().latin1().data()); -#endif servePendingRequests(); } @@ -448,7 +456,9 @@ void Loader::Host::didFail(SubresourceLoader* loader, bool cancelled) cachedResourceLoader->decrementRequestCount(request->cachedResource()); CachedResource* resource = request->cachedResource(); - + + LOG(ResourceLoading, "Host '%s' failed to load %s (cancelled=%d). Current count %d\n", m_name.string().latin1().data(), resource->url().latin1().data(), cancelled, m_requestsLoading.size()); + if (resource->resourceToRevalidate()) cache()->revalidationFailed(resource); |