DocumentLoader.cpp [plain text]
#include "config.h"
#include "DocumentLoader.h"
#include "ApplicationCacheHost.h"
#include "ArchiveResourceCollection.h"
#include "CachedPage.h"
#include "CachedResourceLoader.h"
#include "DOMWindow.h"
#include "Document.h"
#include "DocumentParser.h"
#include "DocumentWriter.h"
#include "Event.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClient.h"
#include "FrameTree.h"
#include "HistoryItem.h"
#include "InspectorInstrumentation.h"
#include "Logging.h"
#include "MainResourceLoader.h"
#include "Page.h"
#include "PlatformString.h"
#include "Settings.h"
#include "SharedBuffer.h"
#include "TextResourceDecoder.h"
#include <wtf/Assertions.h>
#include <wtf/text/CString.h>
#include <wtf/unicode/Unicode.h>
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
#include "ArchiveFactory.h"
#endif
#include "CachedResource.h"
#include "MemoryCache.h"
#include "ResourceHandle.h"
namespace WebCore {
static void cancelAll(const ResourceLoaderSet& loaders)
{
Vector<RefPtr<ResourceLoader> > loadersCopy;
copyToVector(loaders, loadersCopy);
size_t size = loadersCopy.size();
for (size_t i = 0; i < size; ++i)
loadersCopy[i]->cancel();
}
static void setAllDefersLoading(const ResourceLoaderSet& loaders, bool defers)
{
Vector<RefPtr<ResourceLoader> > loadersCopy;
copyToVector(loaders, loadersCopy);
size_t size = loadersCopy.size();
for (size_t i = 0; i < size; ++i)
loadersCopy[i]->setDefersLoading(defers);
}
static bool areAllLoadersPageCacheAcceptable(const ResourceLoaderSet& loaders)
{
Vector<RefPtr<ResourceLoader> > loadersCopy;
copyToVector(loaders, loadersCopy);
size_t size = loadersCopy.size();
for (size_t i = 0; i < size; ++i) {
ResourceHandle* handle = loadersCopy[i]->handle();
if (!handle)
return false;
CachedResource* cachedResource = memoryCache()->resourceForURL(handle->firstRequest().url());
if (!cachedResource)
return false;
if (!cachedResource->isImage())
return false;
}
return true;
}
DocumentLoader::DocumentLoader(const ResourceRequest& req, const SubstituteData& substituteData)
: m_deferMainResourceDataLoad(true)
, m_frame(0)
, m_writer(m_frame)
, m_originalRequest(req)
, m_substituteData(substituteData)
, m_originalRequestCopy(req)
, m_request(req)
, m_committed(false)
, m_isStopping(false)
, m_gotFirstByte(false)
, m_isClientRedirect(false)
, m_wasOnloadHandled(false)
, m_stopRecordingResponses(false)
, m_substituteResourceDeliveryTimer(this, &DocumentLoader::substituteResourceDeliveryTimerFired)
, m_didCreateGlobalHistoryEntry(false)
, m_subresourceLoadersArePageCacheAcceptable(false)
, m_applicationCacheHost(adoptPtr(new ApplicationCacheHost(this)))
{
}
FrameLoader* DocumentLoader::frameLoader() const
{
if (!m_frame)
return 0;
return m_frame->loader();
}
DocumentLoader::~DocumentLoader()
{
ASSERT(!m_frame || frameLoader()->activeDocumentLoader() != this || !frameLoader()->isLoading());
if (m_iconLoadDecisionCallback)
m_iconLoadDecisionCallback->invalidate();
if (m_iconDataCallback)
m_iconDataCallback->invalidate();
}
PassRefPtr<SharedBuffer> DocumentLoader::mainResourceData() const
{
if (m_mainResourceData)
return m_mainResourceData;
if (m_mainResourceLoader)
return m_mainResourceLoader->resourceData();
return 0;
}
const ResourceRequest& DocumentLoader::originalRequest() const
{
return m_originalRequest;
}
const ResourceRequest& DocumentLoader::originalRequestCopy() const
{
return m_originalRequestCopy;
}
const ResourceRequest& DocumentLoader::request() const
{
return m_request;
}
ResourceRequest& DocumentLoader::request()
{
return m_request;
}
const KURL& DocumentLoader::url() const
{
return request().url();
}
void DocumentLoader::replaceRequestURLForSameDocumentNavigation(const KURL& url)
{
m_originalRequestCopy.setURL(url);
m_request.setURL(url);
}
void DocumentLoader::setRequest(const ResourceRequest& req)
{
bool handlingUnreachableURL = false;
handlingUnreachableURL = m_substituteData.isValid() && !m_substituteData.failingURL().isEmpty();
if (handlingUnreachableURL)
m_committed = false;
ASSERT(!m_committed);
KURL oldURL = m_request.url();
m_request = req;
if (!handlingUnreachableURL && !req.url().isNull() && oldURL != req.url())
frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad();
}
void DocumentLoader::setMainDocumentError(const ResourceError& error)
{
m_mainDocumentError = error;
frameLoader()->client()->setMainDocumentError(this, error);
}
void DocumentLoader::mainReceivedError(const ResourceError& error)
{
ASSERT(!error.isNull());
m_applicationCacheHost->failedLoadingMainResource();
if (!frameLoader())
return;
setMainDocumentError(error);
clearMainResourceLoader();
frameLoader()->receivedMainResourceError(error);
}
void DocumentLoader::stopLoading()
{
bool loading = isLoading();
if (loading && m_committed && !m_mainResourceLoader && !m_subresourceLoaders.isEmpty())
m_subresourceLoadersArePageCacheAcceptable = areAllLoadersPageCacheAcceptable(m_subresourceLoaders);
if (m_committed) {
Document* doc = m_frame->document();
if (loading || doc->parsing())
m_frame->loader()->stopLoading(UnloadEventPolicyNone);
}
cancelAll(m_multipartSubresourceLoaders);
m_applicationCacheHost->stopLoadingInFrame(m_frame);
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
clearArchiveResources();
#endif
if (!loading) {
ASSERT(!isLoading());
return;
}
if (m_isStopping)
return;
RefPtr<Frame> protectFrame(m_frame);
RefPtr<DocumentLoader> protectLoader(this);
m_isStopping = true;
FrameLoader* frameLoader = DocumentLoader::frameLoader();
if (m_mainResourceLoader)
m_mainResourceLoader->cancel();
else if (!m_subresourceLoaders.isEmpty())
setMainDocumentError(frameLoader->cancelledError(m_request));
else
mainReceivedError(frameLoader->cancelledError(m_request));
stopLoadingSubresources();
stopLoadingPlugIns();
m_isStopping = false;
}
void DocumentLoader::setupForReplace()
{
frameLoader()->setupForReplace();
m_committed = false;
}
void DocumentLoader::commitIfReady()
{
if (!m_committed) {
m_committed = true;
frameLoader()->commitProvisionalLoad();
}
}
void DocumentLoader::finishedLoading()
{
commitIfReady();
if (!frameLoader() || frameLoader()->stateMachine()->creatingInitialEmptyDocument())
return;
if (!maybeCreateArchive()) {
if (!m_gotFirstByte)
commitData(0, 0);
frameLoader()->client()->finishedLoading(this);
}
m_writer.end();
if (!m_mainDocumentError.isNull())
return;
clearMainResourceLoader();
frameLoader()->checkLoadComplete();
}
void DocumentLoader::commitLoad(const char* data, int length)
{
RefPtr<Frame> protectFrame(m_frame);
RefPtr<DocumentLoader> protectLoader(this);
commitIfReady();
FrameLoader* frameLoader = DocumentLoader::frameLoader();
if (!frameLoader)
return;
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
if (ArchiveFactory::isArchiveMimeType(response().mimeType()))
return;
#endif
frameLoader->client()->committedLoad(this, data, length);
}
void DocumentLoader::commitData(const char* bytes, size_t length)
{
if (!m_gotFirstByte) {
m_gotFirstByte = true;
m_writer.begin(documentURL(), false);
m_writer.setDocumentWasLoadedAsPartOfNavigation();
#if ENABLE(MHTML)
if (m_archive && m_archive->type() == Archive::MHTML)
m_frame->document()->setBaseURLOverride(m_archive->mainResource()->url());
#endif
frameLoader()->receivedFirstData();
bool userChosen = true;
String encoding = overrideEncoding();
if (encoding.isNull()) {
userChosen = false;
encoding = response().textEncodingName();
#if ENABLE(WEB_ARCHIVE)
if (m_archive && m_archive->type() == Archive::WebArchive)
encoding = m_archive->mainResource()->textEncoding();
#endif
}
m_writer.setEncoding(encoding, userChosen);
}
ASSERT(m_frame->document()->parsing());
m_writer.addData(bytes, length);
}
bool DocumentLoader::doesProgressiveLoad(const String& MIMEType) const
{
return !frameLoader()->isReplacing() || MIMEType == "text/html";
}
void DocumentLoader::receivedData(const char* data, int length)
{
if (doesProgressiveLoad(m_response.mimeType()))
commitLoad(data, length);
}
void DocumentLoader::setupForReplaceByMIMEType(const String& newMIMEType)
{
if (!m_gotFirstByte)
return;
String oldMIMEType = m_response.mimeType();
if (!doesProgressiveLoad(oldMIMEType)) {
frameLoader()->client()->revertToProvisionalState(this);
setupForReplace();
RefPtr<SharedBuffer> resourceData = mainResourceData();
commitLoad(resourceData->data(), resourceData->size());
}
maybeCreateArchive();
m_writer.end();
frameLoader()->setReplacing();
m_gotFirstByte = false;
if (doesProgressiveLoad(newMIMEType)) {
frameLoader()->client()->revertToProvisionalState(this);
setupForReplace();
}
stopLoadingSubresources();
stopLoadingPlugIns();
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
clearArchiveResources();
#endif
}
void DocumentLoader::checkLoadComplete()
{
if (!m_frame || isLoading())
return;
ASSERT(this == frameLoader()->activeDocumentLoader());
if (DOMWindow* window = m_frame->existingDOMWindow())
window->finishedLoading();
}
void DocumentLoader::setFrame(Frame* frame)
{
if (m_frame == frame)
return;
ASSERT(frame && !m_frame);
m_frame = frame;
m_writer.setFrame(frame);
attachToFrame();
}
void DocumentLoader::attachToFrame()
{
ASSERT(m_frame);
}
void DocumentLoader::detachFromFrame()
{
ASSERT(m_frame);
RefPtr<Frame> protectFrame(m_frame);
RefPtr<DocumentLoader> protectLoader(this);
stopLoading();
m_applicationCacheHost->setDOMApplicationCache(0);
InspectorInstrumentation::loaderDetachedFromFrame(m_frame, this);
m_frame = 0;
}
void DocumentLoader::clearMainResourceLoader()
{
if (m_mainResourceLoader) {
m_mainResourceData = m_mainResourceLoader->resourceData();
m_mainResourceLoader = 0;
}
if (this == frameLoader()->activeDocumentLoader())
checkLoadComplete();
}
bool DocumentLoader::isLoadingInAPISense() const
{
if (frameLoader()->state() != FrameStateComplete) {
if (m_frame->settings()->needsIsLoadingInAPISenseQuirk() && !m_subresourceLoaders.isEmpty())
return true;
Document* doc = m_frame->document();
if ((m_mainResourceLoader || !m_frame->document()->loadEventFinished()) && isLoading())
return true;
if (doc->cachedResourceLoader()->requestCount())
return true;
if (DocumentParser* parser = doc->parser())
if (parser->processingData())
return true;
}
return frameLoader()->subframeIsLoading();
}
bool DocumentLoader::maybeCreateArchive()
{
#if !ENABLE(WEB_ARCHIVE) && !ENABLE(MHTML)
return false;
#else
m_archive = ArchiveFactory::create(m_response.url(), mainResourceData().get(), m_response.mimeType());
if (!m_archive)
return false;
addAllArchiveResources(m_archive.get());
ArchiveResource* mainResource = m_archive->mainResource();
m_parsedArchiveData = mainResource->data();
m_writer.setMIMEType(mainResource->mimeType());
ASSERT(m_frame->document());
commitData(mainResource->data()->data(), mainResource->data()->size());
return true;
#endif // !ENABLE(WEB_ARCHIVE) && !ENABLE(MHTML)
}
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
void DocumentLoader::setArchive(PassRefPtr<Archive> archive)
{
m_archive = archive;
addAllArchiveResources(m_archive.get());
}
void DocumentLoader::addAllArchiveResources(Archive* archive)
{
if (!m_archiveResourceCollection)
m_archiveResourceCollection = adoptPtr(new ArchiveResourceCollection);
ASSERT(archive);
if (!archive)
return;
m_archiveResourceCollection->addAllResources(archive);
}
void DocumentLoader::addArchiveResource(PassRefPtr<ArchiveResource> resource)
{
if (!m_archiveResourceCollection)
m_archiveResourceCollection = adoptPtr(new ArchiveResourceCollection);
ASSERT(resource);
if (!resource)
return;
m_archiveResourceCollection->addResource(resource);
}
PassRefPtr<Archive> DocumentLoader::popArchiveForSubframe(const String& frameName, const KURL& url)
{
return m_archiveResourceCollection ? m_archiveResourceCollection->popSubframeArchive(frameName, url) : PassRefPtr<Archive>(0);
}
void DocumentLoader::clearArchiveResources()
{
m_archiveResourceCollection.clear();
m_substituteResourceDeliveryTimer.stop();
}
SharedBuffer* DocumentLoader::parsedArchiveData() const
{
return m_parsedArchiveData.get();
}
#endif // ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
ArchiveResource* DocumentLoader::archiveResourceForURL(const KURL& url) const
{
if (!m_archiveResourceCollection)
return 0;
ArchiveResource* resource = m_archiveResourceCollection->archiveResourceForURL(url);
return resource && !resource->shouldIgnoreWhenUnarchiving() ? resource : 0;
}
PassRefPtr<ArchiveResource> DocumentLoader::mainResource() const
{
const ResourceResponse& r = response();
RefPtr<SharedBuffer> mainResourceBuffer = mainResourceData();
if (!mainResourceBuffer)
mainResourceBuffer = SharedBuffer::create();
return ArchiveResource::create(mainResourceBuffer, r.url(), r.mimeType(), r.textEncodingName(), frame()->tree()->uniqueName());
}
PassRefPtr<ArchiveResource> DocumentLoader::subresource(const KURL& url) const
{
if (!isCommitted())
return 0;
CachedResource* resource = m_frame->document()->cachedResourceLoader()->cachedResource(url);
if (!resource || !resource->isLoaded())
return archiveResourceForURL(url);
if (!resource->makePurgeable(false))
return 0;
RefPtr<SharedBuffer> data = resource->data();
if (!data)
return 0;
return ArchiveResource::create(data.release(), url, resource->response());
}
void DocumentLoader::getSubresources(Vector<PassRefPtr<ArchiveResource> >& subresources) const
{
if (!isCommitted())
return;
Document* document = m_frame->document();
const CachedResourceLoader::DocumentResourceMap& allResources = document->cachedResourceLoader()->allCachedResources();
CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end();
for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) {
RefPtr<ArchiveResource> subresource = this->subresource(KURL(ParsedURLString, it->second->url()));
if (subresource)
subresources.append(subresource.release());
}
return;
}
void DocumentLoader::deliverSubstituteResourcesAfterDelay()
{
if (m_pendingSubstituteResources.isEmpty())
return;
ASSERT(m_frame && m_frame->page());
if (m_frame->page()->defersLoading())
return;
if (!m_substituteResourceDeliveryTimer.isActive())
m_substituteResourceDeliveryTimer.startOneShot(0);
}
void DocumentLoader::substituteResourceDeliveryTimerFired(Timer<DocumentLoader>*)
{
if (m_pendingSubstituteResources.isEmpty())
return;
ASSERT(m_frame && m_frame->page());
if (m_frame->page()->defersLoading())
return;
SubstituteResourceMap copy;
copy.swap(m_pendingSubstituteResources);
SubstituteResourceMap::const_iterator end = copy.end();
for (SubstituteResourceMap::const_iterator it = copy.begin(); it != end; ++it) {
RefPtr<ResourceLoader> loader = it->first;
SubstituteResource* resource = it->second.get();
if (resource) {
SharedBuffer* data = resource->data();
loader->didReceiveResponse(resource->response());
if (loader->reachedTerminalState())
return;
loader->didReceiveData(data->data(), data->size(), data->size(), true);
if (loader->reachedTerminalState())
return;
loader->didFinishLoading(0);
} else {
loader->didFail(loader->cannotShowURLError());
}
}
}
#ifndef NDEBUG
bool DocumentLoader::isSubstituteLoadPending(ResourceLoader* loader) const
{
return m_pendingSubstituteResources.contains(loader);
}
#endif
void DocumentLoader::cancelPendingSubstituteLoad(ResourceLoader* loader)
{
if (m_pendingSubstituteResources.isEmpty())
return;
m_pendingSubstituteResources.remove(loader);
if (m_pendingSubstituteResources.isEmpty())
m_substituteResourceDeliveryTimer.stop();
}
#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
bool DocumentLoader::scheduleArchiveLoad(ResourceLoader* loader, const ResourceRequest& request, const KURL& originalURL)
{
if (request.url() == originalURL) {
if (ArchiveResource* resource = archiveResourceForURL(originalURL)) {
m_pendingSubstituteResources.set(loader, resource);
deliverSubstituteResourcesAfterDelay();
return true;
}
}
if (!m_archive)
return false;
switch (m_archive->type()) {
#if ENABLE(WEB_ARCHIVE)
case Archive::WebArchive:
return m_frame->settings() && m_frame->settings()->webArchiveDebugModeEnabled() && ArchiveFactory::isArchiveMimeType(responseMIMEType());
#endif
#if ENABLE(MHTML)
case Archive::MHTML:
return true; #endif
default:
return false;
}
}
#endif // ENABLE(WEB_ARCHIVE)
void DocumentLoader::addResponse(const ResourceResponse& r)
{
if (!m_stopRecordingResponses)
m_responses.append(r);
}
void DocumentLoader::stopRecordingResponses()
{
m_stopRecordingResponses = true;
}
void DocumentLoader::setTitle(const StringWithDirection& title)
{
if (title.isEmpty())
return;
if (m_pageTitle != title) {
frameLoader()->willChangeTitle(this);
m_pageTitle = title;
frameLoader()->didChangeTitle(this);
}
}
KURL DocumentLoader::urlForHistory() const
{
if (m_substituteData.isValid())
return unreachableURL();
return m_originalRequestCopy.url();
}
bool DocumentLoader::urlForHistoryReflectsFailure() const
{
return m_substituteData.isValid() || m_response.httpStatusCode() >= 400;
}
const KURL& DocumentLoader::originalURL() const
{
return m_originalRequestCopy.url();
}
const KURL& DocumentLoader::requestURL() const
{
return request().url();
}
const KURL& DocumentLoader::responseURL() const
{
return m_response.url();
}
KURL DocumentLoader::documentURL() const
{
KURL url = substituteData().responseURL();
#if ENABLE(WEB_ARCHIVE)
if (url.isEmpty() && m_archive && m_archive->type() == Archive::WebArchive)
url = m_archive->mainResource()->url();
#endif
if (url.isEmpty())
url = requestURL();
if (url.isEmpty())
url = responseURL();
if (url.isEmpty())
url = blankURL();
return url;
}
const String& DocumentLoader::responseMIMEType() const
{
return m_response.mimeType();
}
void DocumentLoader::setResponseMIMEType(const String& mimeType)
{
m_response.setMimeType(mimeType);
}
const KURL& DocumentLoader::unreachableURL() const
{
return m_substituteData.failingURL();
}
void DocumentLoader::setDefersLoading(bool defers)
{
if (m_mainResourceLoader)
m_mainResourceLoader->setDefersLoading(defers);
setAllDefersLoading(m_subresourceLoaders, defers);
setAllDefersLoading(m_plugInStreamLoaders, defers);
if (!defers)
deliverSubstituteResourcesAfterDelay();
}
void DocumentLoader::stopLoadingPlugIns()
{
cancelAll(m_plugInStreamLoaders);
}
void DocumentLoader::stopLoadingSubresources()
{
cancelAll(m_subresourceLoaders);
}
void DocumentLoader::addSubresourceLoader(ResourceLoader* loader)
{
m_subresourceLoaders.add(loader);
}
void DocumentLoader::removeSubresourceLoader(ResourceLoader* loader)
{
m_subresourceLoaders.remove(loader);
checkLoadComplete();
if (Frame* frame = m_frame)
frame->loader()->checkLoadComplete();
}
void DocumentLoader::addPlugInStreamLoader(ResourceLoader* loader)
{
m_plugInStreamLoaders.add(loader);
}
void DocumentLoader::removePlugInStreamLoader(ResourceLoader* loader)
{
m_plugInStreamLoaders.remove(loader);
checkLoadComplete();
}
bool DocumentLoader::isLoadingMainResource() const
{
return !!m_mainResourceLoader;
}
bool DocumentLoader::isLoadingMultipartContent() const
{
return m_mainResourceLoader && m_mainResourceLoader->isLoadingMultipartContent();
}
void DocumentLoader::startLoadingMainResource()
{
m_mainDocumentError = ResourceError();
timing()->markNavigationStart(m_frame);
ASSERT(!m_mainResourceLoader);
m_mainResourceLoader = MainResourceLoader::create(m_frame);
frameLoader()->addExtraFieldsToMainResourceRequest(m_request);
RefPtr<MainResourceLoader> protectedMainResourceLoader(m_mainResourceLoader);
if (!protectedMainResourceLoader->load(m_request, m_substituteData)) {
LOG_ERROR("could not create WebResourceHandle for URL %s -- should be caught by policy handler level", m_request.url().string().ascii().data());
m_mainResourceLoader = 0;
ASSERT(!isLoading());
checkLoadComplete();
}
}
void DocumentLoader::cancelMainResourceLoad(const ResourceError& error)
{
m_mainResourceLoader->cancel(error);
}
void DocumentLoader::subresourceLoaderFinishedLoadingOnePart(ResourceLoader* loader)
{
m_multipartSubresourceLoaders.add(loader);
m_subresourceLoaders.remove(loader);
checkLoadComplete();
if (Frame* frame = m_frame)
frame->loader()->checkLoadComplete();
}
void DocumentLoader::maybeFinishLoadingMultipartContent()
{
if (!doesProgressiveLoad(m_response.mimeType())) {
frameLoader()->client()->revertToProvisionalState(this);
setupForReplace();
RefPtr<SharedBuffer> resourceData = mainResourceData();
commitLoad(resourceData->data(), resourceData->size());
}
}
void DocumentLoader::iconLoadDecisionAvailable()
{
if (m_frame)
m_frame->loader()->icon()->loadDecisionReceived(iconDatabase().synchronousLoadDecisionForIconURL(frameLoader()->icon()->url(), this));
}
static void iconLoadDecisionCallback(IconLoadDecision decision, void* context)
{
static_cast<DocumentLoader*>(context)->continueIconLoadWithDecision(decision);
}
void DocumentLoader::getIconLoadDecisionForIconURL(const String& urlString)
{
if (m_iconLoadDecisionCallback)
m_iconLoadDecisionCallback->invalidate();
m_iconLoadDecisionCallback = IconLoadDecisionCallback::create(this, iconLoadDecisionCallback);
iconDatabase().loadDecisionForIconURL(urlString, m_iconLoadDecisionCallback);
}
void DocumentLoader::continueIconLoadWithDecision(IconLoadDecision decision)
{
ASSERT(m_iconLoadDecisionCallback);
m_iconLoadDecisionCallback = 0;
if (m_frame)
m_frame->loader()->icon()->continueLoadWithDecision(decision);
}
static void iconDataCallback(SharedBuffer*, void*)
{
}
void DocumentLoader::getIconDataForIconURL(const String& urlString)
{
if (m_iconDataCallback)
m_iconDataCallback->invalidate();
m_iconDataCallback = IconDataCallback::create(this, iconDataCallback);
iconDatabase().iconDataForIconURL(urlString, m_iconDataCallback);
}
void DocumentLoader::handledOnloadEvents()
{
m_wasOnloadHandled = true;
applicationCacheHost()->stopDeferringEvents();
}
}