Commit c69b85e9 authored by abarth@webkit.org's avatar abarth@webkit.org

2009-10-15 Adam Barth <abarth@webkit.org>

        Reviewed by Darin Adler.

        Factor ResourceLoadNotifier out of FrameLoader
        https://bugs.webkit.org/show_bug.cgi?id=30379

        These methods have virtually no interaction with the rest of
        FrameLoader.

        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * WebCoreSources.bkl:
        * dom/Document.cpp:
        (WebCore::Document::resourceRetrievedByXMLHttpRequest):
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::FrameLoader):
        (WebCore::FrameLoader::continueLoadAfterWillSubmitForm):
        (WebCore::ResourceLoadNotifier::ResourceLoadNotifier):
        (WebCore::ResourceLoadNotifier::activeDocumentLoader):
        (WebCore::ResourceLoadNotifier::assignIdentifierToInitialRequest):
        (WebCore::ResourceLoadNotifier::willSendRequest):
        (WebCore::ResourceLoadNotifier::didReceiveResponse):
        (WebCore::ResourceLoadNotifier::didReceiveData):
        (WebCore::ResourceLoadNotifier::didFailToLoad):
        (WebCore::ResourceLoadNotifier::didLoadResourceByXMLHttpRequest):
        (WebCore::FrameLoader::sendRemainingDelegateMessages):
        (WebCore::FrameLoader::requestFromDelegate):
        (WebCore::ResourceLoadNotifier::didFinishLoad):
        (WebCore::ResourceLoadNotifier::didReceiveAuthenticationChallenge):
        (WebCore::ResourceLoadNotifier::didCancelAuthenticationChallenge):
        (WebCore::ResourceLoadNotifier::dispatchAssignIdentifierToInitialRequest):
        (WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
        (WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):
        (WebCore::ResourceLoadNotifier::dispatchDidReceiveContentLength):
        (WebCore::ResourceLoadNotifier::dispatchDidFinishLoading):
        * loader/FrameLoader.h:
        (WebCore::FrameLoader::notifier):
        * loader/MainResourceLoader.cpp:
        (WebCore::MainResourceLoader::receivedError):
        * loader/ResourceLoadNotifier.cpp: Added.
        (WebCore::ResourceLoadNotifier::ResourceLoadNotifier):
        (WebCore::ResourceLoadNotifier::didReceiveAuthenticationChallenge):
        (WebCore::ResourceLoadNotifier::didCancelAuthenticationChallenge):
        (WebCore::ResourceLoadNotifier::assignIdentifierToInitialRequest):
        (WebCore::ResourceLoadNotifier::willSendRequest):
        (WebCore::ResourceLoadNotifier::didReceiveResponse):
        (WebCore::ResourceLoadNotifier::didReceiveData):
        (WebCore::ResourceLoadNotifier::didFinishLoad):
        (WebCore::ResourceLoadNotifier::didFailToLoad):
        (WebCore::ResourceLoadNotifier::didLoadResourceByXMLHttpRequest):
        (WebCore::ResourceLoadNotifier::dispatchAssignIdentifierToInitialRequest):
        (WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
        (WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):
        (WebCore::ResourceLoadNotifier::dispatchDidReceiveContentLength):
        (WebCore::ResourceLoadNotifier::dispatchDidFinishLoading):
        (WebCore::ResourceLoadNotifier::activeDocumentLoader):
        * loader/ResourceLoadNotifier.h: Added.
        * loader/ResourceLoader.cpp:
        (WebCore::ResourceLoader::willSendRequest):
        (WebCore::ResourceLoader::didReceiveResponse):
        (WebCore::ResourceLoader::didReceiveData):
        (WebCore::ResourceLoader::didFinishLoadingOnePart):
        (WebCore::ResourceLoader::didFail):
        (WebCore::ResourceLoader::didCancel):
        (WebCore::ResourceLoader::didReceiveAuthenticationChallenge):
        (WebCore::ResourceLoader::didCancelAuthenticationChallenge):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49671 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 32183f8f
2009-10-15 Adam Barth <abarth@webkit.org>
Reviewed by Darin Adler.
Factor ResourceLoadNotifier out of FrameLoader
https://bugs.webkit.org/show_bug.cgi?id=30379
These methods have virtually no interaction with the rest of
FrameLoader.
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* WebCoreSources.bkl:
* dom/Document.cpp:
(WebCore::Document::resourceRetrievedByXMLHttpRequest):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::FrameLoader):
(WebCore::FrameLoader::continueLoadAfterWillSubmitForm):
(WebCore::ResourceLoadNotifier::ResourceLoadNotifier):
(WebCore::ResourceLoadNotifier::activeDocumentLoader):
(WebCore::ResourceLoadNotifier::assignIdentifierToInitialRequest):
(WebCore::ResourceLoadNotifier::willSendRequest):
(WebCore::ResourceLoadNotifier::didReceiveResponse):
(WebCore::ResourceLoadNotifier::didReceiveData):
(WebCore::ResourceLoadNotifier::didFailToLoad):
(WebCore::ResourceLoadNotifier::didLoadResourceByXMLHttpRequest):
(WebCore::FrameLoader::sendRemainingDelegateMessages):
(WebCore::FrameLoader::requestFromDelegate):
(WebCore::ResourceLoadNotifier::didFinishLoad):
(WebCore::ResourceLoadNotifier::didReceiveAuthenticationChallenge):
(WebCore::ResourceLoadNotifier::didCancelAuthenticationChallenge):
(WebCore::ResourceLoadNotifier::dispatchAssignIdentifierToInitialRequest):
(WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
(WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):
(WebCore::ResourceLoadNotifier::dispatchDidReceiveContentLength):
(WebCore::ResourceLoadNotifier::dispatchDidFinishLoading):
* loader/FrameLoader.h:
(WebCore::FrameLoader::notifier):
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::receivedError):
* loader/ResourceLoadNotifier.cpp: Added.
(WebCore::ResourceLoadNotifier::ResourceLoadNotifier):
(WebCore::ResourceLoadNotifier::didReceiveAuthenticationChallenge):
(WebCore::ResourceLoadNotifier::didCancelAuthenticationChallenge):
(WebCore::ResourceLoadNotifier::assignIdentifierToInitialRequest):
(WebCore::ResourceLoadNotifier::willSendRequest):
(WebCore::ResourceLoadNotifier::didReceiveResponse):
(WebCore::ResourceLoadNotifier::didReceiveData):
(WebCore::ResourceLoadNotifier::didFinishLoad):
(WebCore::ResourceLoadNotifier::didFailToLoad):
(WebCore::ResourceLoadNotifier::didLoadResourceByXMLHttpRequest):
(WebCore::ResourceLoadNotifier::dispatchAssignIdentifierToInitialRequest):
(WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
(WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):
(WebCore::ResourceLoadNotifier::dispatchDidReceiveContentLength):
(WebCore::ResourceLoadNotifier::dispatchDidFinishLoading):
(WebCore::ResourceLoadNotifier::activeDocumentLoader):
* loader/ResourceLoadNotifier.h: Added.
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::willSendRequest):
(WebCore::ResourceLoader::didReceiveResponse):
(WebCore::ResourceLoader::didReceiveData):
(WebCore::ResourceLoader::didFinishLoadingOnePart):
(WebCore::ResourceLoader::didFail):
(WebCore::ResourceLoader::didCancel):
(WebCore::ResourceLoader::didReceiveAuthenticationChallenge):
(WebCore::ResourceLoader::didCancelAuthenticationChallenge):
2009-10-15 Roland Steiner <rolandsteiner@google.com>
Reviewed by Darin Fisher.
......@@ -1261,6 +1261,8 @@ webcore_sources += \
WebCore/loader/Request.h \
WebCore/loader/ResourceLoader.cpp \
WebCore/loader/ResourceLoader.h \
WebCore/loader/ResourceLoadNotifier.cpp \
WebCore/loader/ResourceLoadNotifier.h \
WebCore/loader/SubresourceLoader.cpp \
WebCore/loader/SubresourceLoader.h \
WebCore/loader/SubresourceLoaderClient.h \
......
......@@ -1647,6 +1647,8 @@
'loader/Request.h',
'loader/ResourceLoader.cpp',
'loader/ResourceLoader.h',
'loader/ResourceLoadNotifier.cpp',
'loader/ResourceLoadNotifier.h',
'loader/SubresourceLoader.cpp',
'loader/SubresourceLoader.h',
'loader/SubresourceLoaderClient.h',
......
......@@ -1122,6 +1122,7 @@ SOURCES += \
loader/RedirectScheduler.cpp \
loader/Request.cpp \
loader/ResourceLoader.cpp \
loader/ResourceLoadNotifier.cpp \
loader/SubresourceLoader.cpp \
loader/TextDocument.cpp \
loader/TextResourceDecoder.cpp \
......
......@@ -17544,6 +17544,14 @@
RelativePath="..\loader\ResourceLoader.h"
>
</File>
<File
RelativePath="..\loader\ResourceLoadNotifier.cpp"
>
</File>
<File
RelativePath="..\loader\ResourceLoadNotifier.h"
>
</File>
<File
RelativePath="..\loader\cf\ResourceLoaderCFNet.cpp"
>
......
......@@ -2357,6 +2357,8 @@
97059978107D975200A50A7C /* PolicyCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059974107D975200A50A7C /* PolicyCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
97059979107D975200A50A7C /* PolicyChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97059975107D975200A50A7C /* PolicyChecker.cpp */; };
9705997A107D975200A50A7C /* PolicyChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059976107D975200A50A7C /* PolicyChecker.h */; settings = {ATTRIBUTES = (Private, ); }; };
973E325610883B7C005BC493 /* ResourceLoadNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */; };
973E325710883B7C005BC493 /* ResourceLoadNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 973E325510883B7C005BC493 /* ResourceLoadNotifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
979F43D31075E44A0000F83B /* RedirectScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 979F43D11075E44A0000F83B /* RedirectScheduler.cpp */; };
979F43D41075E44A0000F83B /* RedirectScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 979F43D21075E44A0000F83B /* RedirectScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
97DCE20110807C750057D394 /* HistoryController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97DCE1FF10807C750057D394 /* HistoryController.cpp */; };
......@@ -7567,6 +7569,8 @@
97059974107D975200A50A7C /* PolicyCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyCallback.h; sourceTree = "<group>"; };
97059975107D975200A50A7C /* PolicyChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyChecker.cpp; sourceTree = "<group>"; };
97059976107D975200A50A7C /* PolicyChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyChecker.h; sourceTree = "<group>"; };
973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadNotifier.cpp; sourceTree = "<group>"; };
973E325510883B7C005BC493 /* ResourceLoadNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadNotifier.h; sourceTree = "<group>"; };
979F43D11075E44A0000F83B /* RedirectScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RedirectScheduler.cpp; sourceTree = "<group>"; };
979F43D21075E44A0000F83B /* RedirectScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RedirectScheduler.h; sourceTree = "<group>"; };
97DCE1FF10807C750057D394 /* HistoryController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HistoryController.cpp; sourceTree = "<group>"; };
......@@ -14656,6 +14660,8 @@
BCB16C160979C3BD00467741 /* Request.h */,
93E227DE0AF589AD00D48324 /* ResourceLoader.cpp */,
656D37270ADBA5DE00A4554D /* ResourceLoader.h */,
973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */,
973E325510883B7C005BC493 /* ResourceLoadNotifier.h */,
93E227DF0AF589AD00D48324 /* SubresourceLoader.cpp */,
656D37300ADBA5DE00A4554D /* SubresourceLoader.h */,
1A3178920B20A81600316987 /* SubresourceLoaderClient.h */,
......@@ -18034,6 +18040,7 @@
93F199ED08245E59001E9ABC /* XSLTProcessor.h in Headers */,
E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
973E325710883B7C005BC493 /* ResourceLoadNotifier.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -20165,6 +20172,7 @@
93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */,
E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
973E325610883B7C005BC493 /* ResourceLoadNotifier.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -733,6 +733,7 @@ This file contains the list of files needed to build WebCore.
loader/RedirectScheduler.cpp
loader/Request.cpp
loader/ResourceLoader.cpp
loader/ResourceLoadNotifier.cpp
loader/SubresourceLoader.cpp
loader/TextDocument.cpp
loader/TextResourceDecoder.cpp
......
......@@ -4502,7 +4502,7 @@ void Document::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const
Frame* frame = this->frame();
if (frame) {
FrameLoader* frameLoader = frame->loader();
frameLoader->didLoadResourceByXMLHttpRequest(identifier, sourceString);
frameLoader->notifier()->didLoadResourceByXMLHttpRequest(identifier, sourceString);
}
}
......
......@@ -168,6 +168,7 @@ FrameLoader::FrameLoader(Frame* frame, FrameLoaderClient* client)
, m_client(client)
, m_policyChecker(frame)
, m_history(frame)
, m_notifer(frame)
, m_state(FrameStateCommittedPage)
, m_loadType(FrameLoadTypeStandard)
, m_delegateIsHandlingProvisionalLoadError(false)
......@@ -2936,7 +2937,7 @@ void FrameLoader::continueLoadAfterWillSubmitForm()
if (Page* page = m_frame->page()) {
identifier = page->progress()->createUniqueIdentifier();
dispatchAssignIdentifierToInitialRequest(identifier, m_provisionalDocumentLoader.get(), m_provisionalDocumentLoader->originalRequest());
notifier()->dispatchAssignIdentifierToInitialRequest(identifier, m_provisionalDocumentLoader.get(), m_provisionalDocumentLoader->originalRequest());
}
if (!m_provisionalDocumentLoader->startLoadingMainResource(identifier))
......@@ -3256,46 +3257,6 @@ unsigned long FrameLoader::loadResourceSynchronously(const ResourceRequest& requ
return identifier;
}
void FrameLoader::assignIdentifierToInitialRequest(unsigned long identifier, const ResourceRequest& clientRequest)
{
return dispatchAssignIdentifierToInitialRequest(identifier, activeDocumentLoader(), clientRequest);
}
void FrameLoader::willSendRequest(ResourceLoader* loader, ResourceRequest& clientRequest, const ResourceResponse& redirectResponse)
{
applyUserAgent(clientRequest);
dispatchWillSendRequest(loader->documentLoader(), loader->identifier(), clientRequest, redirectResponse);
}
void FrameLoader::didReceiveResponse(ResourceLoader* loader, const ResourceResponse& r)
{
activeDocumentLoader()->addResponse(r);
if (Page* page = m_frame->page())
page->progress()->incrementProgress(loader->identifier(), r);
dispatchDidReceiveResponse(loader->documentLoader(), loader->identifier(), r);
}
void FrameLoader::didReceiveData(ResourceLoader* loader, const char* data, int length, int lengthReceived)
{
if (Page* page = m_frame->page())
page->progress()->incrementProgress(loader->identifier(), data, length);
dispatchDidReceiveContentLength(loader->documentLoader(), loader->identifier(), lengthReceived);
}
void FrameLoader::didFailToLoad(ResourceLoader* loader, const ResourceError& error)
{
if (Page* page = m_frame->page())
page->progress()->completeProgress(loader->identifier());
if (!error.isNull())
m_client->dispatchDidFailLoading(loader->documentLoader(), loader->identifier(), error);
}
void FrameLoader::didLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString)
{
m_client->dispatchDidLoadResourceByXMLHttpRequest(identifier, sourceString);
}
const ResourceRequest& FrameLoader::originalRequest() const
{
return activeDocumentLoader()->originalRequestCopy();
......@@ -3508,13 +3469,13 @@ void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& reques
void FrameLoader::sendRemainingDelegateMessages(unsigned long identifier, const ResourceResponse& response, int length, const ResourceError& error)
{
if (!response.isNull())
dispatchDidReceiveResponse(m_documentLoader.get(), identifier, response);
notifier()->dispatchDidReceiveResponse(m_documentLoader.get(), identifier, response);
if (length > 0)
dispatchDidReceiveContentLength(m_documentLoader.get(), identifier, length);
notifier()->dispatchDidReceiveContentLength(m_documentLoader.get(), identifier, length);
if (error.isNull())
dispatchDidFinishLoading(m_documentLoader.get(), identifier);
notifier()->dispatchDidFinishLoading(m_documentLoader.get(), identifier);
else
m_client->dispatchDidFailLoading(m_documentLoader.get(), identifier, error);
}
......@@ -3526,11 +3487,11 @@ void FrameLoader::requestFromDelegate(ResourceRequest& request, unsigned long& i
identifier = 0;
if (Page* page = m_frame->page()) {
identifier = page->progress()->createUniqueIdentifier();
dispatchAssignIdentifierToInitialRequest(identifier, m_documentLoader.get(), request);
notifier()->dispatchAssignIdentifierToInitialRequest(identifier, m_documentLoader.get(), request);
}
ResourceRequest newRequest(request);
dispatchWillSendRequest(m_documentLoader.get(), identifier, newRequest, ResourceResponse());
notifier()->dispatchWillSendRequest(m_documentLoader.get(), identifier, newRequest, ResourceResponse());
if (newRequest.isNull())
error = cancelledError(request);
......@@ -3858,28 +3819,11 @@ ResourceError FrameLoader::fileDoesNotExistError(const ResourceResponse& respons
return m_client->fileDoesNotExistError(response);
}
void FrameLoader::didFinishLoad(ResourceLoader* loader)
{
if (Page* page = m_frame->page())
page->progress()->completeProgress(loader->identifier());
dispatchDidFinishLoading(loader->documentLoader(), loader->identifier());
}
bool FrameLoader::shouldUseCredentialStorage(ResourceLoader* loader)
{
return m_client->shouldUseCredentialStorage(loader->documentLoader(), loader->identifier());
}
void FrameLoader::didReceiveAuthenticationChallenge(ResourceLoader* loader, const AuthenticationChallenge& currentWebChallenge)
{
m_client->dispatchDidReceiveAuthenticationChallenge(loader->documentLoader(), loader->identifier(), currentWebChallenge);
}
void FrameLoader::didCancelAuthenticationChallenge(ResourceLoader* loader, const AuthenticationChallenge& currentWebChallenge)
{
m_client->dispatchDidCancelAuthenticationChallenge(loader->documentLoader(), loader->identifier(), currentWebChallenge);
}
void FrameLoader::setTitle(const String& title)
{
documentLoader()->setTitle(title);
......@@ -3985,63 +3929,6 @@ void FrameLoader::dispatchDidCommitLoad()
#endif
}
void FrameLoader::dispatchAssignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
{
m_client->assignIdentifierToInitialRequest(identifier, loader, request);
#if ENABLE(INSPECTOR)
if (Page* page = m_frame->page())
page->inspectorController()->identifierForInitialRequest(identifier, loader, request);
#endif
}
void FrameLoader::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
{
StringImpl* oldRequestURL = request.url().string().impl();
m_documentLoader->didTellClientAboutLoad(request.url());
m_client->dispatchWillSendRequest(loader, identifier, request, redirectResponse);
// If the URL changed, then we want to put that new URL in the "did tell client" set too.
if (!request.isNull() && oldRequestURL != request.url().string().impl())
m_documentLoader->didTellClientAboutLoad(request.url());
#if ENABLE(INSPECTOR)
if (Page* page = m_frame->page())
page->inspectorController()->willSendRequest(loader, identifier, request, redirectResponse);
#endif
}
void FrameLoader::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
{
m_client->dispatchDidReceiveResponse(loader, identifier, r);
#if ENABLE(INSPECTOR)
if (Page* page = m_frame->page())
page->inspectorController()->didReceiveResponse(loader, identifier, r);
#endif
}
void FrameLoader::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long identifier, int length)
{
m_client->dispatchDidReceiveContentLength(loader, identifier, length);
#if ENABLE(INSPECTOR)
if (Page* page = m_frame->page())
page->inspectorController()->didReceiveContentLength(loader, identifier, length);
#endif
}
void FrameLoader::dispatchDidFinishLoading(DocumentLoader* loader, unsigned long identifier)
{
m_client->dispatchDidFinishLoading(loader, identifier);
#if ENABLE(INSPECTOR)
if (Page* page = m_frame->page())
page->inspectorController()->didFinishLoading(loader, identifier);
#endif
}
void FrameLoader::tellClientAboutPastMemoryCacheLoads()
{
ASSERT(m_frame->page());
......
......@@ -36,6 +36,7 @@
#include "PolicyCallback.h"
#include "PolicyChecker.h"
#include "RedirectScheduler.h"
#include "ResourceLoadNotifier.h"
#include "ResourceRequest.h"
#include "ThreadableLoader.h"
#include "Timer.h"
......@@ -91,6 +92,7 @@ namespace WebCore {
PolicyChecker* policyChecker() const { return &m_policyChecker; }
HistoryController* history() const { return &m_history; }
ResourceLoadNotifier* notifier() const { return &m_notifer; }
// FIXME: This is not cool, people. There are too many different functions that all start loads.
// We should aim to consolidate these into a smaller set of functions, and try to reuse more of
......@@ -141,16 +143,6 @@ namespace WebCore {
static double timeOfLastCompletedLoad();
bool shouldUseCredentialStorage(ResourceLoader*);
void didReceiveAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&);
void didCancelAuthenticationChallenge(ResourceLoader*, const AuthenticationChallenge&);
void assignIdentifierToInitialRequest(unsigned long identifier, const ResourceRequest&);
void willSendRequest(ResourceLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
void didReceiveResponse(ResourceLoader*, const ResourceResponse&);
void didReceiveData(ResourceLoader*, const char*, int, int lengthReceived);
void didFinishLoad(ResourceLoader*);
void didFailToLoad(ResourceLoader*, const ResourceError&);
void didLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString);
const ResourceRequest& originalRequest() const;
const ResourceRequest& initialRequest() const;
void receivedMainResourceError(const ResourceError&, bool isComplete);
......@@ -397,11 +389,6 @@ namespace WebCore {
bool shouldReloadToHandleUnreachableURL(DocumentLoader*);
void dispatchDidCommitLoad();
void dispatchAssignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&);
void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&);
void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int length);
void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier);
void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, PassRefPtr<FormState>); // Calls continueLoadAfterNavigationPolicy
void load(DocumentLoader*); // Calls loadWithDocumentLoader
......@@ -447,6 +434,7 @@ namespace WebCore {
mutable PolicyChecker m_policyChecker;
mutable HistoryController m_history;
mutable ResourceLoadNotifier m_notifer;
FrameState m_state;
FrameLoadType m_loadType;
......
......@@ -77,7 +77,7 @@ void MainResourceLoader::receivedError(const ResourceError& error)
if (!cancelled()) {
ASSERT(!reachedTerminalState());
frameLoader()->didFailToLoad(this, error);
frameLoader()->notifier()->didFailToLoad(this, error);
releaseResources();
}
......
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "ResourceLoadNotifier.h"
#include "DocumentLoader.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClient.h"
#include "InspectorController.h"
#include "Page.h"
#include "ProgressTracker.h"
#include "ResourceLoader.h"
namespace WebCore {
ResourceLoadNotifier::ResourceLoadNotifier(Frame* frame)
: m_frame(frame)
{
}
void ResourceLoadNotifier::didReceiveAuthenticationChallenge(ResourceLoader* loader, const AuthenticationChallenge& currentWebChallenge)
{
m_frame->loader()->client()->dispatchDidReceiveAuthenticationChallenge(loader->documentLoader(), loader->identifier(), currentWebChallenge);
}
void ResourceLoadNotifier::didCancelAuthenticationChallenge(ResourceLoader* loader, const AuthenticationChallenge& currentWebChallenge)
{
m_frame->loader()->client()->dispatchDidCancelAuthenticationChallenge(loader->documentLoader(), loader->identifier(), currentWebChallenge);
}
void ResourceLoadNotifier::assignIdentifierToInitialRequest(unsigned long identifier, const ResourceRequest& clientRequest)
{
dispatchAssignIdentifierToInitialRequest(identifier, activeDocumentLoader(), clientRequest);
}
void ResourceLoadNotifier::willSendRequest(ResourceLoader* loader, ResourceRequest& clientRequest, const ResourceResponse& redirectResponse)
{
m_frame->loader()->applyUserAgent(clientRequest);
dispatchWillSendRequest(loader->documentLoader(), loader->identifier(), clientRequest, redirectResponse);
}
void ResourceLoadNotifier::didReceiveResponse(ResourceLoader* loader, const ResourceResponse& r)
{
activeDocumentLoader()->addResponse(r);
if (Page* page = m_frame->page())
page->progress()->incrementProgress(loader->identifier(), r);
dispatchDidReceiveResponse(loader->documentLoader(), loader->identifier(), r);
}
void ResourceLoadNotifier::didReceiveData(ResourceLoader* loader, const char* data, int length, int lengthReceived)
{
if (Page* page = m_frame->page())
page->progress()->incrementProgress(loader->identifier(), data, length);
dispatchDidReceiveContentLength(loader->documentLoader(), loader->identifier(), lengthReceived);
}
void ResourceLoadNotifier::didFinishLoad(ResourceLoader* loader)
{
if (Page* page = m_frame->page())
page->progress()->completeProgress(loader->identifier());
dispatchDidFinishLoading(loader->documentLoader(), loader->identifier());
}
void ResourceLoadNotifier::didFailToLoad(ResourceLoader* loader, const ResourceError& error)
{
if (Page* page = m_frame->page())
page->progress()->completeProgress(loader->identifier());
if (!error.isNull())
m_frame->loader()->client()->dispatchDidFailLoading(loader->documentLoader(), loader->identifier(), error);
}
void ResourceLoadNotifier::didLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString)
{
m_frame->loader()->client()->dispatchDidLoadResourceByXMLHttpRequest(identifier, sourceString);
}
void ResourceLoadNotifier::dispatchAssignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
{
m_frame->loader()->client()->assignIdentifierToInitialRequest(identifier, loader, request);
#if ENABLE(INSPECTOR)
if (Page* page = m_frame->page())
page->inspectorController()->identifierForInitialRequest(identifier, loader, request);
#endif
}
void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
{
StringImpl* oldRequestURL = request.url().string().impl();
m_frame->loader()->documentLoader()->didTellClientAboutLoad(request.url());
m_frame->loader()->client()->dispatchWillSendRequest(loader, identifier, request, redirectResponse);
// If the URL changed, then we want to put that new URL in the "did tell client" set too.
if (!request.isNull() && oldRequestURL != request.url().string().impl())
m_frame->loader()->documentLoader()->didTellClientAboutLoad(request.url());
#if ENABLE(INSPECTOR)
if (Page* page = m_frame->page())
page->inspectorController()->willSendRequest(loader, identifier, request, redirectResponse);
#endif
}
void ResourceLoadNotifier::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
{
m_frame->loader()->client()->dispatchDidReceiveResponse(loader, identifier, r);
#if ENABLE(INSPECTOR)
if (Page* page = m_frame->page())
page->inspectorController()->didReceiveResponse(loader, identifier, r);
#endif
}
void ResourceLoadNotifier::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long identifier, int length)
{
m_frame->loader()->client()->dispatchDidReceiveContentLength(loader, identifier, length);
#if ENABLE(INSPECTOR)
if (Page* page = m_frame->page())
page->inspectorController()->didReceiveContentLength(loader, identifier, length);
#endif
}
void ResourceLoadNotifier::dispatchDidFinishLoading(DocumentLoader* loader, unsigned long identifier)
{
m_frame->loader()->client()->dispatchDidFinishLoading(loader, identifier);
#if ENABLE(INSPECTOR)
if (Page* page = m_frame->page())
page->inspectorController()->didFinishLoading(loader, identifier);
#endif
}
DocumentLoader* ResourceLoadNotifier::activeDocumentLoader() const
{
return m_frame->loader()->activeDocumentLoader();
}
} // namespace WebCore
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF