diff options
Diffstat (limited to 'Source/WebCore/loader/ResourceLoadNotifier.cpp')
-rw-r--r-- | Source/WebCore/loader/ResourceLoadNotifier.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/Source/WebCore/loader/ResourceLoadNotifier.cpp b/Source/WebCore/loader/ResourceLoadNotifier.cpp index 9d6b70290..63443d36e 100644 --- a/Source/WebCore/loader/ResourceLoadNotifier.cpp +++ b/Source/WebCore/loader/ResourceLoadNotifier.cpp @@ -12,7 +12,7 @@ * 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 + * 3. Neither the name of Apple 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. * @@ -39,6 +39,7 @@ #include "Page.h" #include "ProgressTracker.h" #include "ResourceLoader.h" +#include "RuntimeEnabledFeatures.h" #if USE(QUICK_LOOK) #include "QuickLook.h" @@ -61,16 +62,6 @@ void ResourceLoadNotifier::didReceiveAuthenticationChallenge(unsigned long ident m_frame.loader().client().dispatchDidReceiveAuthenticationChallenge(loader, identifier, currentWebChallenge); } -void ResourceLoadNotifier::didCancelAuthenticationChallenge(ResourceLoader* loader, const AuthenticationChallenge& currentWebChallenge) -{ - didCancelAuthenticationChallenge(loader->identifier(), loader->documentLoader(), currentWebChallenge); -} - -void ResourceLoadNotifier::didCancelAuthenticationChallenge(unsigned long identifier, DocumentLoader* loader, const AuthenticationChallenge& currentWebChallenge) -{ - m_frame.loader().client().dispatchDidCancelAuthenticationChallenge(loader, identifier, currentWebChallenge); -} - void ResourceLoadNotifier::willSendRequest(ResourceLoader* loader, ResourceRequest& clientRequest, const ResourceResponse& redirectResponse) { m_frame.loader().applyUserAgent(clientRequest); @@ -108,6 +99,8 @@ void ResourceLoadNotifier::didFailToLoad(ResourceLoader* loader, const ResourceE if (Page* page = m_frame.page()) page->progress().completeProgress(loader->identifier()); + // Notifying the FrameLoaderClient may cause the frame to be destroyed. + Ref<Frame> protect(m_frame); if (!error.isNull()) m_frame.loader().client().dispatchDidFailLoading(loader->documentLoader(), loader->identifier(), error); @@ -130,6 +123,8 @@ void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsig String oldRequestURL = request.url().string(); m_frame.loader().documentLoader()->didTellClientAboutLoad(request.url()); + // Notifying the FrameLoaderClient may cause the frame to be destroyed. + Ref<Frame> protect(m_frame); 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. @@ -138,24 +133,27 @@ void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsig InspectorInstrumentation::willSendRequest(&m_frame, identifier, loader, request, redirectResponse); - // Report WebTiming for all frames. - if (loader && !request.isNull() && request.url() == loader->requestURL()) + if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled()) request.setReportLoadTiming(true); - -#if ENABLE(RESOURCE_TIMING) - request.setReportLoadTiming(true); -#endif + else if (loader && !request.isNull() && request.url() == loader->url()) { + // Report WebTiming for all frames. + request.setReportLoadTiming(true); + } } void ResourceLoadNotifier::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r, ResourceLoader* resourceLoader) { - InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(&m_frame, identifier, r); + // Notifying the FrameLoaderClient may cause the frame to be destroyed. + Ref<Frame> protect(m_frame); m_frame.loader().client().dispatchDidReceiveResponse(loader, identifier, r); - InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, r, resourceLoader); + + InspectorInstrumentation::didReceiveResourceResponse(m_frame, identifier, loader, r, resourceLoader); } void ResourceLoadNotifier::dispatchDidReceiveData(DocumentLoader* loader, unsigned long identifier, const char* data, int dataLength, int encodedDataLength) { + // Notifying the FrameLoaderClient may cause the frame to be destroyed. + Ref<Frame> protect(m_frame); m_frame.loader().client().dispatchDidReceiveContentLength(loader, identifier, dataLength); InspectorInstrumentation::didReceiveData(&m_frame, identifier, data, dataLength, encodedDataLength); @@ -163,6 +161,8 @@ void ResourceLoadNotifier::dispatchDidReceiveData(DocumentLoader* loader, unsign void ResourceLoadNotifier::dispatchDidFinishLoading(DocumentLoader* loader, unsigned long identifier, double finishTime) { + // Notifying the FrameLoaderClient may cause the frame to be destroyed. + Ref<Frame> protect(m_frame); m_frame.loader().client().dispatchDidFinishLoading(loader, identifier); InspectorInstrumentation::didFinishLoading(&m_frame, loader, identifier, finishTime); @@ -170,6 +170,8 @@ void ResourceLoadNotifier::dispatchDidFinishLoading(DocumentLoader* loader, unsi void ResourceLoadNotifier::dispatchDidFailLoading(DocumentLoader* loader, unsigned long identifier, const ResourceError& error) { + // Notifying the FrameLoaderClient may cause the frame to be destroyed. + Ref<Frame> protect(m_frame); m_frame.loader().client().dispatchDidFailLoading(loader, identifier, error); InspectorInstrumentation::didFailLoading(&m_frame, loader, identifier, error); |