Changeset 143619 in webkit


Ignore:
Timestamp:
Feb 21, 2013 9:50:37 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] Remove subresource leaks from WebKit1 and WebKit2
https://bugs.webkit.org/show_bug.cgi?id=108960

Patch by George McCollister <george.mccollister@gmail.com> on 2013-02-21
Reviewed by Martin Robinson.

  • WebCoreSupport/FrameLoaderClientGtk.cpp:

(WebKit::FrameLoaderClient::dispatchDidFinishLoading): Remove resource
if it isn't the main resource to prevent leak.
(WebKit::FrameLoaderClient::dispatchDidFailLoading): Ditto

  • webkit/webkitwebview.cpp:

(cleanupTemporarilyCachedSubresources): Added to cleanup subresources.
(webkit_web_view_get_subresources): Use getSubresources from the
documentLoader to provide subresources since resources will be removed
from webview after loading.

Location:
trunk/Source/WebKit/gtk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/gtk/ChangeLog

    r143591 r143619  
     12013-02-21  George McCollister  <george.mccollister@gmail.com>
     2
     3        [GTK] Remove subresource leaks from WebKit1 and WebKit2
     4        https://bugs.webkit.org/show_bug.cgi?id=108960
     5
     6        Reviewed by Martin Robinson.
     7
     8        * WebCoreSupport/FrameLoaderClientGtk.cpp:
     9        (WebKit::FrameLoaderClient::dispatchDidFinishLoading): Remove resource
     10        if it isn't the main resource to prevent leak.
     11        (WebKit::FrameLoaderClient::dispatchDidFailLoading): Ditto
     12        * webkit/webkitwebview.cpp:
     13        (cleanupTemporarilyCachedSubresources): Added to cleanup subresources.
     14        (webkit_web_view_get_subresources): Use getSubresources from the
     15        documentLoader to provide subresources since resources will be removed
     16        from webview after loading.
     17
    1182013-02-21  Carlos Garcia Campos  <cgarcia@igalia.com>
    219
  • trunk/Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp

    r140557 r143619  
    10211021    g_signal_emit_by_name(m_frame, "resource-load-finished", webResource);
    10221022    g_signal_emit_by_name(webView, "resource-load-finished", m_frame, webResource);
     1023
     1024    if (!g_str_equal(identifierString.get(), webView->priv->mainResourceIdentifier.data()))
     1025        webkit_web_view_remove_resource(webView, identifierString.get());
    10231026}
    10241027
     
    10431046    g_signal_emit_by_name(m_frame, "resource-load-failed", webResource, webError.get());
    10441047    g_signal_emit_by_name(webView, "resource-load-failed", m_frame, webResource, webError.get());
     1048
     1049    if (!g_str_equal(identifierString.get(), webView->priv->mainResourceIdentifier.data()))
     1050        webkit_web_view_remove_resource(webView, identifierString.get());
    10451051}
    10461052
  • trunk/Source/WebKit/gtk/webkit/webkitwebview.cpp

    r142576 r143619  
    3333
    3434#include "AXObjectCache.h"
     35#include "ArchiveResource.h"
    3536#include "BackForwardListImpl.h"
    3637#include "CairoUtilities.h"
     
    106107#include "webkitwebpolicydecision.h"
    107108#include "webkitwebresource.h"
     109#include "webkitwebresourceprivate.h"
    108110#include "webkitwebsettingsprivate.h"
    109111#include "webkitwebplugindatabaseprivate.h"
     
    51075109}
    51085110
     5111static gboolean cleanupTemporarilyCachedSubresources(gpointer data)
     5112{
     5113    GList* subResources = static_cast<GList*>(data);
     5114    g_list_foreach(subResources, reinterpret_cast<GFunc>(g_object_unref), NULL);
     5115    g_list_free(subResources);
     5116    return FALSE;
     5117}
     5118
    51095119GList* webkit_web_view_get_subresources(WebKitWebView* webView)
    51105120{
    5111     WebKitWebViewPrivate* priv = webView->priv;
    5112     GList* subResources = g_hash_table_get_values(priv->subResources.get());
    5113     return g_list_remove(subResources, priv->mainResource.get());
     5121    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL);
     5122    GList* subResources = 0;
     5123    Vector<PassRefPtr<ArchiveResource> > coreSubResources;
     5124
     5125    core(webView)->mainFrame()->loader()->documentLoader()->getSubresources(coreSubResources);
     5126
     5127    for (unsigned i = 0; i < coreSubResources.size(); i++) {
     5128        WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(g_object_new(WEBKIT_TYPE_WEB_RESOURCE, NULL));
     5129        webkit_web_resource_init_with_core_resource(webResource, coreSubResources[i]);
     5130        subResources = g_list_append(subResources, webResource);
     5131    }
     5132
     5133    if (subResources)
     5134        g_timeout_add(1, cleanupTemporarilyCachedSubresources, g_list_copy(subResources));
     5135
     5136    return subResources;
    51145137}
    51155138
Note: See TracChangeset for help on using the changeset viewer.