Commit af0f8bdf authored by andersca's avatar andersca
Browse files

Reviewed by Geoff.

        <rdar://problem/5058714>
        http://bugs.webkit.org/show_bug.cgi?id=13050
        
        World leaks seen on Leopard after opening then closing tab (13050)

        Add a hash set to prevent the load count to be increased twice for the same resource.
        
        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::dispatchWillSendRequest):
        (WebFrameLoaderClient::dispatchDidFinishLoading):
        (WebFrameLoaderClient::dispatchDidFailLoading):
        * WebView/WebDocumentLoaderMac.h:
        * WebView/WebDocumentLoaderMac.mm:
        (loadingResources):
        (WebDocumentLoaderMac::increaseLoadCount):
        (WebDocumentLoaderMac::decreaseLoadCount):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20195 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0e45dad8
2007-03-14 Anders Carlsson <acarlsson@apple.com>
Reviewed by Geoff.
<rdar://problem/5058714>
http://bugs.webkit.org/show_bug.cgi?id=13050
World leaks seen on Leopard after opening then closing tab (13050)
Add a hash set to prevent the load count to be increased twice for the same resource.
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::dispatchWillSendRequest):
(WebFrameLoaderClient::dispatchDidFinishLoading):
(WebFrameLoaderClient::dispatchDidFailLoading):
* WebView/WebDocumentLoaderMac.h:
* WebView/WebDocumentLoaderMac.mm:
(loadingResources):
(WebDocumentLoaderMac::increaseLoadCount):
(WebDocumentLoaderMac::decreaseLoadCount):
2007-03-14 Adele Peterson <adele@apple.com>
 
Reviewed by Darin.
......
......@@ -284,7 +284,7 @@ void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader* loader, unsig
WebResourceDelegateImplementationCache implementations = WebViewGetResourceLoadDelegateImplementations(webView);
if (redirectResponse.isNull())
static_cast<WebDocumentLoaderMac*>(loader)->increaseLoadCount();
static_cast<WebDocumentLoaderMac*>(loader)->increaseLoadCount(identifier);
if (implementations.delegateImplementsWillSendRequest)
request = implementations.willSendRequestFunc(resourceLoadDelegate, @selector(webView:resource:willSendRequest:redirectResponse:fromDataSource:), webView, [webView _objectForIdentifier:identifier], request.nsURLRequest(), redirectResponse.nsURLResponse(), dataSource(loader));
......@@ -353,7 +353,7 @@ void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, unsi
implementations.didFinishLoadingFromDataSourceFunc(resourceLoadDelegate, @selector(webView:resource:didFinishLoadingFromDataSource:), webView, [webView _objectForIdentifier:identifier], dataSource(loader));
[webView _removeObjectForIdentifier:identifier];
static_cast<WebDocumentLoaderMac*>(loader)->decreaseLoadCount();
static_cast<WebDocumentLoaderMac*>(loader)->decreaseLoadCount(identifier);
}
void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, unsigned long identifier, const WebCore::ResourceError& error)
......@@ -362,7 +362,7 @@ void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, unsign
[[webView _resourceLoadDelegateForwarder] webView:webView resource:[webView _objectForIdentifier:identifier] didFailLoadingWithError:error fromDataSource:dataSource(loader)];
[webView _removeObjectForIdentifier:identifier];
static_cast<WebDocumentLoaderMac*>(loader)->decreaseLoadCount();
static_cast<WebDocumentLoaderMac*>(loader)->decreaseLoadCount(identifier);
}
void WebFrameLoaderClient::dispatchDidHandleOnloadEvents()
......
......@@ -45,8 +45,8 @@ public:
virtual void attachToFrame();
virtual void detachFromFrame();
void increaseLoadCount();
void decreaseLoadCount();
void increaseLoadCount(unsigned long identifier);
void decreaseLoadCount(unsigned long identifier);
private:
WebDataSource *m_dataSource;
bool m_hasEverBeenDetached;
......
......@@ -34,6 +34,13 @@
using namespace WebCore;
static HashSet<unsigned long>& loadingResources()
{
static HashSet<unsigned long> resources;
return resources;
}
WebDocumentLoaderMac::WebDocumentLoaderMac(const ResourceRequest& request, const SubstituteData& substituteData)
: DocumentLoader(request, substituteData)
, m_dataSource(nil)
......@@ -71,20 +78,27 @@ void WebDocumentLoaderMac::detachFromFrame()
HardRelease(m_dataSource);
}
void WebDocumentLoaderMac::increaseLoadCount()
void WebDocumentLoaderMac::increaseLoadCount(unsigned long identifier)
{
ASSERT(m_dataSource);
if (loadingResources().contains(identifier))
return;
loadingResources().add(identifier);
if (m_loadCount == 0)
HardRetain(m_dataSource);
m_loadCount++;
}
void WebDocumentLoaderMac::decreaseLoadCount()
void WebDocumentLoaderMac::decreaseLoadCount(unsigned long identifier)
{
ASSERT(m_loadCount > 0);
loadingResources().remove(identifier);
m_loadCount--;
if (m_loadCount == 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment