Changeset 118618 in webkit


Ignore:
Timestamp:
May 26, 2012 5:46:11 PM (12 years ago)
Author:
Nate Chapin
Message:

Source/WebCore: Cancel CachedResource loads when the last client is removed.
https://bugs.webkit.org/show_bug.cgi?id=35377

Reviewed by Darin Adler.

Test: http/tests/cache/cancel-in-progress-load.html

  • loader/SubresourceLoader.cpp:

(WebCore::SubresourceLoader::errorLoadingResource):

  • loader/cache/CachedCSSStyleSheet.cpp:

(WebCore::CachedCSSStyleSheet::allClientsRemoved):

  • loader/cache/CachedFont.cpp:

(WebCore::CachedFont::allClientsRemoved):

  • loader/cache/CachedImage.cpp:

(WebCore::CachedImage::allClientsRemoved):

  • loader/cache/CachedRawResource.cpp:

(WebCore):

  • loader/cache/CachedRawResource.h:

(WebCore::CachedRawResource::shouldIgnoreHTTPStatusCodeErrors):

  • loader/cache/CachedResource.cpp:

(WebCore::CachedResource::allClientsRemoved):
(WebCore):

  • loader/cache/CachedResource.h:

(CachedResource):

  • loader/cache/CachedScript.cpp:

(WebCore::CachedScript::allClientsRemoved):

LayoutTests: Test for https://bugs.webkit.org/show_bug.cgi?id=35377.

Reviewed by Darin Adler.

  • http/tests/cache/cancel-in-progress-load-expected.txt: Added.
  • http/tests/cache/cancel-in-progress-load.html: Added.
  • http/tests/misc/write-while-waiting.html: Add waitUntilDone()/notifyDone().

The slow script will now be cancelled when the script element is removed from the document.
Without waitUntilDone(), LayoutTestController will immediately end the test upon cancellation
of the last resource.

Location:
trunk
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r118617 r118618  
     12012-05-26  Nate Chapin  <japhet@chromium.org>
     2
     3        Test for https://bugs.webkit.org/show_bug.cgi?id=35377.
     4
     5        Reviewed by Darin Adler.
     6
     7        * http/tests/cache/cancel-in-progress-load-expected.txt: Added.
     8        * http/tests/cache/cancel-in-progress-load.html: Added.
     9        * http/tests/misc/write-while-waiting.html: Add waitUntilDone()/notifyDone().
     10            The slow script will now be cancelled when the script element is removed from the document.
     11            Without waitUntilDone(), LayoutTestController will immediately end the test upon cancellation
     12            of the last resource.
     13
    1142012-05-26  Simon Fraser  <simon.fraser@apple.com>
    215
  • trunk/LayoutTests/http/tests/misc/write-while-waiting.html

    r63998 r118618  
    33FAIL
    44<script>
    5 if (window.layoutTestController)
     5if (window.layoutTestController) {
    66    layoutTestController.dumpAsText();
     7    layoutTestController.waitUntilDone();
     8}
    79
    8 setTimeout("document.write('PASS');document.close();", 100);
     10setTimeout("document.write('PASS');document.close(); if (window.layoutTestController) layoutTestController.notifyDone();", 100);
    911</script>
    1012<script src="resources/script-slow1.pl"></script>
  • trunk/Source/WebCore/ChangeLog

    r118617 r118618  
     12012-05-26  Nate Chapin  <japhet@chromium.org>
     2
     3        Cancel CachedResource loads when the last client is removed.
     4        https://bugs.webkit.org/show_bug.cgi?id=35377
     5
     6        Reviewed by Darin Adler.
     7
     8        Test: http/tests/cache/cancel-in-progress-load.html
     9
     10        * loader/SubresourceLoader.cpp:
     11        (WebCore::SubresourceLoader::errorLoadingResource):
     12        * loader/cache/CachedCSSStyleSheet.cpp:
     13        (WebCore::CachedCSSStyleSheet::allClientsRemoved):
     14        * loader/cache/CachedFont.cpp:
     15        (WebCore::CachedFont::allClientsRemoved):
     16        * loader/cache/CachedImage.cpp:
     17        (WebCore::CachedImage::allClientsRemoved):
     18        * loader/cache/CachedRawResource.cpp:
     19        (WebCore):
     20        * loader/cache/CachedRawResource.h:
     21        (WebCore::CachedRawResource::shouldIgnoreHTTPStatusCodeErrors):
     22        * loader/cache/CachedResource.cpp:
     23        (WebCore::CachedResource::allClientsRemoved):
     24        (WebCore):
     25        * loader/cache/CachedResource.h:
     26        (CachedResource):
     27        * loader/cache/CachedScript.cpp:
     28        (WebCore::CachedScript::allClientsRemoved):
     29
    1302012-05-26  Simon Fraser  <simon.fraser@apple.com>
    231
  • trunk/Source/WebCore/loader/SubresourceLoader.cpp

    r114976 r118618  
    233233        return false;
    234234
     235    m_state = Finishing;
    235236    m_resource->error(CachedResource::LoadError);
    236     m_state = Finishing;
    237237    cancel();
    238238    return true;
  • trunk/Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp

    r118336 r118618  
    6767    if (!MemoryCache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable())
    6868        makePurgeable(true);
     69    CachedResource::allClientsRemoved();
    6970}
    7071
  • trunk/Source/WebCore/loader/cache/CachedFont.cpp

    r114523 r118618  
    186186    }
    187187#endif
     188    CachedResource::allClientsRemoved();
    188189}
    189190
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r117376 r118618  
    125125    if (double interval = memoryCache()->deadDecodedDataDeletionInterval())
    126126        m_decodedDataDeletionTimer.startOneShot(interval);
     127    CachedResource::allClientsRemoved();
    127128}
    128129
  • trunk/Source/WebCore/loader/cache/CachedRawResource.cpp

    r115236 r118618  
    8888}
    8989
    90 void CachedRawResource::allClientsRemoved()
    91 {
    92     if (m_loader)
    93         m_loader->cancelIfNotFinishing();
    94 }
    95 
    9690void CachedRawResource::willSendRequest(ResourceRequest& request, const ResourceResponse& response)
    9791{
  • trunk/Source/WebCore/loader/cache/CachedRawResource.h

    r110608 r118618  
    5050
    5151    virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return true; }
    52     virtual void allClientsRemoved();
    5352
    5453    virtual void willSendRequest(ResourceRequest&, const ResourceResponse&);
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r117029 r118618  
    388388}
    389389
     390void CachedResource::allClientsRemoved()
     391{
     392    if (m_loader)
     393        m_loader->cancelIfNotFinishing();
     394}
     395
    390396bool CachedResource::addClientToSet(CachedResourceClient* client)
    391397{
  • trunk/Source/WebCore/loader/cache/CachedResource.h

    r118301 r118618  
    127127
    128128    virtual void didAddClient(CachedResourceClient*);
    129     virtual void allClientsRemoved() { }
     129    virtual void allClientsRemoved();
    130130
    131131    unsigned count() const { return m_clients.size(); }
  • trunk/Source/WebCore/loader/cache/CachedScript.cpp

    r112245 r118618  
    6868    if (double interval = memoryCache()->deadDecodedDataDeletionInterval())
    6969        m_decodedDataDeletionTimer.startOneShot(interval);
     70    CachedResource::allClientsRemoved();
    7071}
    7172
Note: See TracChangeset for help on using the changeset viewer.